Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
No files matched your search
@@ -1,2 +1,4 @@
|
||||
busybox
|
||||
busybox.links
|
||||
_install
|
||||
loop.h
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
--blank-lines-after-declarations
|
||||
--blank-lines-after-procedures
|
||||
--break-before-boolean-operator
|
||||
--no-blank-lines-after-commas
|
||||
--braces-on-if-line
|
||||
--braces-on-struct-decl-line
|
||||
--comment-indentation25
|
||||
--declaration-comment-column25
|
||||
--no-comment-delimiters-on-blank-lines
|
||||
--cuddle-else
|
||||
--continuation-indentation4
|
||||
--case-indentation0
|
||||
--else-endif-column33
|
||||
--space-after-cast
|
||||
--line-comments-indentation0
|
||||
--declaration-indentation1
|
||||
--dont-format-first-column-comments
|
||||
--dont-format-comments
|
||||
--honour-newlines
|
||||
--indent-level4
|
||||
/* changed from 0 to 4 */
|
||||
--parameter-indentation4
|
||||
--line-length78 /* changed from 75 */
|
||||
--continue-at-parentheses
|
||||
--no-space-after-function-call-names
|
||||
--dont-break-procedure-type
|
||||
--dont-star-comments
|
||||
--leave-optional-blank-lines
|
||||
--dont-space-special-semicolon
|
||||
--tab-size4
|
||||
/* additions by Mark */
|
||||
--case-brace-indentation0
|
||||
--leave-preprocessor-space
|
||||
@@ -12,6 +12,9 @@ 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
|
||||
|
||||
@@ -25,12 +28,18 @@ 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
|
||||
|
||||
@@ -40,16 +49,27 @@ Glenn McGrath <bug1@netconnect.com.au>
|
||||
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
|
||||
|
||||
|
||||
@@ -1,3 +1,223 @@
|
||||
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).
|
||||
@@ -22,7 +242,7 @@
|
||||
* 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_STANDALONE_SHELL is defined, all the busybox commands may
|
||||
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
|
||||
@@ -327,7 +547,7 @@
|
||||
* 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 defautl behavior you can
|
||||
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
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
/* 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_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_INIT
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
//#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_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_RPMUNPACK
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
#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_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_UNIX2DOS
|
||||
//#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. 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
|
||||
#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
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f', 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
|
||||
//
|
||||
// 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.
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//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.
|
||||
// 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.
|
||||
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
// Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
//
|
||||
// Attempts to match usernames in a ~-prefixed path
|
||||
// XXX: Doesn't work without NSS, off by default
|
||||
//#define BB_FEATURE_USERNAME_COMPLETION /* require NSS */
|
||||
//
|
||||
//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 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
|
||||
//
|
||||
// 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_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifndef BB_INIT
|
||||
#undef BB_LINUXRC
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#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_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#ifndef BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
+323
@@ -0,0 +1,323 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
|
||||
// NOTE: This file only defines features usefull under the Hurd,
|
||||
// To compile for the Hurd raname this to Config.h prior to make
|
||||
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
//#define BB_CHVT /* not needed */
|
||||
#define BB_CLEAR
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
#define BB_DD
|
||||
//#define BB_DEALLOCVT /* inot needed */
|
||||
//#define BB_DF /* different implementation */
|
||||
#define BB_DIRNAME
|
||||
//#define BB_DMESG /* doesnt compile, different implementation */
|
||||
#define BB_DUTMP
|
||||
#define BB_DU
|
||||
//#define BB_DUMPKMAP /* not needed */
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
//#define BB_FBSET /* not needed, doesnt compile */
|
||||
//#define BB_FDFLUSH /* is this needed? */
|
||||
#define BB_FIND
|
||||
//#define BB_FREE /* doesnt compile */
|
||||
#define BB_FREERAMDISK /* does hurd support ramdisks ? */
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_INIT /* not needed?, doesnt compile */
|
||||
//#define BB_INSMOD /* not needed, doesnt compile */
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_LENGTH
|
||||
#define BB_LN
|
||||
//#define BB_LOADACM /* not needed, doesnt compile */
|
||||
//#define BB_LOADFONT /* not needed, doesnt compile */
|
||||
//#define BB_LOADKMAP /* not needed */
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
//#define BB_LSMOD /* not needed, doesnt compile */
|
||||
//#define BB_MAKEDEVS /* different implementation */
|
||||
#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
//#define BB_MKSWAP /* different impelementation (i think) */
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
#define BB_MORE
|
||||
//#define BB_MOUNT /* different implementation */
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
//#define BB_PING /* doesnt compile, Hurd uses BSD style ip.h */
|
||||
//#define BB_POWEROFF /* different implementation i assume */
|
||||
#define BB_PRINTF
|
||||
//#define BB_PS /* needs /proc */
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
//#define BB_REBOOT /* different implementation */
|
||||
#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_RMMOD /* not needed, doesnt compile */
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES /* is this needed ? */
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_SWAPONOFF /* different implementation, doesnt compile */
|
||||
#define BB_SYNC
|
||||
//#define BB_SYSLOGD /* doesnt compile */
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
#define BB_TELNET
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
//#define BB_UPTIME /* doesnt compile */
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
//#define BB_UMOUNT /* different implementation */
|
||||
#define BB_UNIQ
|
||||
//#define BB_UNAME /* doesnt compile */
|
||||
//#define BB_UPDATE /* doesnt compile */
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names (still a bit buggy)
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
//#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
//#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes
|
||||
//#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox commands as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell
|
||||
//among other thing.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#endif
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@ mini-gzip(gzip), mini-netcat(mnc)
|
||||
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
|
||||
|
||||
Tons of new stuff as noted in header files
|
||||
Copyright (C) 1999 by Lineo, inc. and written by
|
||||
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
|
||||
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org>
|
||||
# Copyright (C) 1999,2000,2001 Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -19,121 +18,271 @@
|
||||
#
|
||||
|
||||
PROG := busybox
|
||||
VERSION := 0.45
|
||||
VERSION := 0.49
|
||||
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
|
||||
|
||||
# If you want a static binary, turn this on.
|
||||
DOSTATIC = 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 = false
|
||||
|
||||
# To compile vs an alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs. This is how I did it...
|
||||
#CFLAGS+=-nostdinc -I/home/andersen/CVS/uC-libc/include -I/usr/include/linux
|
||||
# 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
|
||||
STRIPTOOL = $(CROSS)strip
|
||||
|
||||
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
|
||||
# Isn't that easy? Right now, uClibc needs BB_FEATURE_NFSMOUNT disabled
|
||||
# since uClibc's nfs support isn't ready yet.
|
||||
#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...
|
||||
#LIBCDIR=/usr/i486-linuxlibc1/
|
||||
#LDFLAGS+=-nostdlib
|
||||
#LIBRARIES = /home/andersen/CVS/uC-libc/libc.a
|
||||
#LIBRARIES = $(LIBCDIR)/libc.a -lgcc
|
||||
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
|
||||
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
|
||||
CC = gcc
|
||||
#--------------------------------------------------------
|
||||
|
||||
# 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
|
||||
|
||||
# Allow alternative stripping tools to be used...
|
||||
ifndef $(STRIPTOOL)
|
||||
STRIPTOOL = strip
|
||||
ifeq ($(DOLFS),true)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_FILE_OFFSET_BITS=64
|
||||
endif
|
||||
ifeq ($(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
|
||||
|
||||
# -D_GNU_SOURCE is needed because environ is used in init.c
|
||||
ifeq ($(DODEBUG),true)
|
||||
CFLAGS += -Wall -g -fno-builtin -D_GNU_SOURCE
|
||||
LDFLAGS +=
|
||||
STRIP =
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIP =
|
||||
else
|
||||
CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
|
||||
LDFLAGS += -s
|
||||
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
#Only staticly link when _not_ debugging
|
||||
ifeq ($(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
|
||||
endif
|
||||
ifeq ($(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.
|
||||
# Config.h in the build directory should take precedence over the
|
||||
# copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
#
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
# If it gets in your way, set DISABLE_VPATH=yes
|
||||
ifeq ($(DISABLE_VPATH),yes)
|
||||
CONFIG_H = Config.h
|
||||
else
|
||||
VPATH = .:$(BB_SRC_DIR)
|
||||
CONFIG_LIST = $(addsuffix /Config.h,$(subst :, ,$(VPATH)))
|
||||
CONFIG_H = $(word 1,$(shell ls -f -1 $(CONFIG_LIST) 2>/dev/null))
|
||||
CFLAGS += -I- $(patsubst %,-I%,$(subst :, ,$(VPATH))) $(CROSS_CFLAGS)
|
||||
endif
|
||||
|
||||
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o utility.o
|
||||
OBJECTS = $(shell $(BB_SRC_DIR)/busybox.sh $(CONFIG_H) $(BB_SRC_DIR)) busybox.o messages.o usage.o utility.o
|
||||
CFLAGS += -DBB_VER='"$(VERSION)"'
|
||||
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
|
||||
ifdef BB_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
||||
endif
|
||||
|
||||
ifneq ($(USE_SYSTEM_PWD_GRP),true)
|
||||
PWD_LIB = pwd_grp/libpwd.a
|
||||
LIBRARIES += $(PWD_LIB)
|
||||
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: busybox busybox.links doc
|
||||
|
||||
doc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
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
|
||||
- pod2text docs/busybox.pod > docs/BusyBox.txt
|
||||
-mkdir -p docs
|
||||
-pod2text $(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.txt
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" docs/busybox.pod > docs/BusyBox.1
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.1
|
||||
|
||||
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f docs/BusyBox.html
|
||||
- ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
|
||||
- pod2html docs/busybox.pod > docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f pod2html*
|
||||
-@ mkdir -p docs/busybox.lineo.com
|
||||
- pod2html --noindex $(BB_SRC_DIR)/docs/busybox.pod > \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
-@ rm -f pod2html*
|
||||
|
||||
busybox: $(OBJECTS)
|
||||
|
||||
# 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 $@ $^ $(LIBRARIES)
|
||||
$(STRIP)
|
||||
|
||||
busybox.links: busybox.def.h
|
||||
- ./busybox.mkll | sort >$@
|
||||
$(PWD_LIB):
|
||||
$(MAKE) -eC pwd_grp
|
||||
|
||||
regexp.o nfsmount.o cmdedit.o: %.o: %.h
|
||||
$(OBJECTS): %.o: busybox.def.h internal.h %.c Makefile
|
||||
busybox.links: Config.h applets.h
|
||||
- $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@
|
||||
|
||||
nfsmount.o cmdedit.o: %.o: %.h
|
||||
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
$(CC) $(CFLAGS) -c $*.c -o $*.o
|
||||
|
||||
utility.o: loop.h
|
||||
|
||||
loop.h: mk_loop_h.sh
|
||||
@ sh $<
|
||||
|
||||
test tests:
|
||||
cd tests && $(MAKE) all
|
||||
|
||||
clean:
|
||||
- rm -f busybox.links *~ *.o core
|
||||
- rm -rf _install
|
||||
- cd tests && $(MAKE) clean
|
||||
- rm -f docs/BusyBox.html docs/busybox.lineo.com/BusyBox.html \
|
||||
docs/BusyBox.1 docs/BusyBox.txt pod2html*
|
||||
- cd pwd_grp && $(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 Config.h.ORG bb.def.h busybox.REGRESS.sh.results bb.OptionsAndFeatures
|
||||
- rm -rf docs/busybox _install
|
||||
- rm -f busybox.links loop.h *~ *.o core
|
||||
|
||||
distclean: clean
|
||||
- rm -f busybox
|
||||
- cd tests && $(MAKE) distclean
|
||||
|
||||
install: busybox busybox.links
|
||||
./install.sh $(PREFIX)
|
||||
$(BB_SRC_DIR)/install.sh $(PREFIX)
|
||||
|
||||
install-hardlinks: busybox busybox.links
|
||||
$(BB_SRC_DIR)/install.sh $(PREFIX) --hardlinks
|
||||
|
||||
debug_pristine:
|
||||
@ echo VPATH=\"$(VPATH)\"
|
||||
@ echo CONFIG_LIST=\"$(CONFIG_LIST)\"
|
||||
@ echo CONFIG_H=\"$(CONFIG_H)\"
|
||||
@ echo OBJECTS=\"$(OBJECTS)\"
|
||||
|
||||
dist release: distclean doc
|
||||
cd ..; \
|
||||
@@ -150,4 +299,13 @@ dist release: distclean doc
|
||||
-print \
|
||||
| xargs rm -f; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
| xargs rm -f; \
|
||||
\
|
||||
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
|
||||
|
||||
.PHONY: tags
|
||||
tags:
|
||||
ctags -R .
|
||||
@@ -4,51 +4,103 @@ BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for most of the utilities
|
||||
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
|
||||
tar, etc. BusyBox provides a fairly complete POSIX environment for any small or
|
||||
emdedded system. The utilities in BusyBox generally have fewer options then
|
||||
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 a kernel, a shell (such as ash),
|
||||
and an editor (such as elvis-tiny or ae).
|
||||
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
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
|
||||
As of version 0.20 there is a version number. : ) Also as of version 0.20,
|
||||
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 busybox.def.h and comment out the components you do not
|
||||
need using C++ style (//) comments.
|
||||
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 which is then
|
||||
After the build is complete, a busybox.links file is generated. This is
|
||||
used by 'make install' to create symlinks to the busybox binary for all
|
||||
compiled in functions. By default, 'make install' will place the symlink
|
||||
forest into `pwd`/_install unless you have defined the PREFIX environment
|
||||
variable (i.e. make PREFIX="/tmp/foo" install)
|
||||
variable (i.e., 'make PREFIX=/tmp/foo install')
|
||||
|
||||
----------------
|
||||
|
||||
Supported architectures:
|
||||
|
||||
Busybox in general will build on any architecture supported by gcc. It has
|
||||
a few specialized features added for __sparc__ and __alpha__. insmod
|
||||
functionality is currently limited to x86, ARM, 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, follow the instructions at http://bugs.lineo.com/Reporting.html
|
||||
and submit a bug report. This way, we can be sure nothing falls through the
|
||||
cracks...
|
||||
|
||||
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 publically browsable CVS tree at:
|
||||
|
||||
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:
|
||||
@@ -57,7 +109,6 @@ Anonymous CVS access is available. For instructions, check out:
|
||||
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:
|
||||
@@ -65,7 +116,7 @@ Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
<andersen@lineo.com>
|
||||
<andersee@debian.org>
|
||||
|
||||
<blatent plug>
|
||||
<blatant plug>
|
||||
Many thanks to go to Lineo for paying me to work on busybox.
|
||||
</blatent plug>
|
||||
</blatant plug>
|
||||
|
||||
@@ -6,81 +6,28 @@ around to it some time. If you have any good ideas, please let me know.
|
||||
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
|
||||
needed or wanted in busybox (or else I'd have to link to libcrypt).
|
||||
|
||||
* Networking apps are probably going to be split out some time soon into a
|
||||
separate package (named perhaps netkit-tiny?). This would remove the
|
||||
following items from BusyBox: hostid, hostname, nc, nslookup, telnet,
|
||||
and ping. nfs mounting and syslogd (when it supports network logging)
|
||||
will remain in BusyBox.
|
||||
* We _were_ going to split networking apps into a new package called
|
||||
netkit-tiny. Per discussions on the mailing list, this isn't going
|
||||
to happen. False alarm. Sorry about the confusion.
|
||||
|
||||
* 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
|
||||
|
||||
-----------
|
||||
|
||||
Bugs that need fixing:
|
||||
Possible apps to include some time:
|
||||
|
||||
- 'ln -n' has been disabled for this release, till we can fix a memory
|
||||
corruption bug.
|
||||
- fix 'cp' (or test suite script) so that it passes the last item in
|
||||
the test suite.
|
||||
- ps dirent race bug (need to stat the file before attempting chdir)
|
||||
- Make 'ln -s /tmp/file .' work the way GNU ln does (i.e. makes a link to
|
||||
/tmp/file in the current directory, rather then trying and failing to create
|
||||
a symlink named "." in the current working directory).
|
||||
- Prune sfdisk, graft in std fdisk instead
|
||||
|
||||
|
||||
We will rework these to use libc regex functions instead (as per the mailing
|
||||
list discussion):
|
||||
- 'grep foo$ file' doesn't work
|
||||
- 'grep *foo file' segfaults
|
||||
|
||||
|
||||
-----------
|
||||
|
||||
Linux 2.4.x kernels
|
||||
|
||||
BusyBox 0.45 currently will not work with the Linux 2.4.x kernels.
|
||||
I know of the following problems:
|
||||
|
||||
1) The sysinfo syscall has changed what it does (binary incompatable), breaking
|
||||
init and free.
|
||||
2) BusyBox NFS support is broken with 2.4.x (needs to be adjusted for NFSv3 and
|
||||
kernel header changes).
|
||||
3) mount,umount,and df are all broken by the "none" entries for fake filesystems
|
||||
such as the shared mem one. Al Viro claims these will be disappearing soon...
|
||||
|
||||
I made a kernel patch that reverts the sysinfo changes
|
||||
http://kernelnotes.org/lnxlists/linux-kernel/lk_0006_01/msg00619.html
|
||||
|
||||
and I have been fighting with Alan Cox to get these changes fixed in a binary
|
||||
compatable way, but Alan has so far not been very receptive. I am planning on
|
||||
appealing to Linus (when he gets back from vacation) and then going with
|
||||
whatever he decides...
|
||||
|
||||
So my thought is, 2.4.x just isn't ready for BusyBox to target it, and even if
|
||||
it was, BusyBox isn't ready yet either. Seems to me like this will not be
|
||||
ready for a while, and we should just not worry about it yet.
|
||||
|
||||
As long as I have BB_FEATURE_NFSMOUNT turned off, everything compiles cleanly
|
||||
for me with linux2.4.0test1-ac22-riel (i.e. I don't see the freeramdisk.c
|
||||
problem you reported). I use Debian potato (gcc 2.95.2, GNU libc 2.1.3).
|
||||
Of course, as noted above, compiling != working.
|
||||
|
||||
-----------
|
||||
|
||||
* Make insmod actually work
|
||||
* dnsdomainname
|
||||
* traceroute/netstat
|
||||
* rdate
|
||||
* hwclock
|
||||
* stty
|
||||
* expr
|
||||
* wget (or whatever I call it)
|
||||
* tftp
|
||||
* ftp
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
* consider making a unified option parser (if it can be done
|
||||
modular, small, etc.)
|
||||
|
||||
-----------------------
|
||||
|
||||
@@ -90,19 +37,9 @@ Running the following:
|
||||
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, and
|
||||
then create a microLibc to provide these functions. There is no good reason
|
||||
for GNU libc to be so big. I'm sure it can be a lot better.
|
||||
|
||||
(BTW, this is more informative if BB_FEATURE_NFSMOUNT is turned off...)
|
||||
|
||||
Most wanted list:
|
||||
|
||||
[andersen@slag busybox]$ grep -l getgroups *.[ch]
|
||||
test.c
|
||||
|
||||
Policy violation. getgroups uses libc nss, which is unlikely
|
||||
to be present in an embedded system.
|
||||
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.
|
||||
|
||||
-----------------------
|
||||
|
||||
@@ -111,379 +48,6 @@ and then start with the biggest things and make them smaller...
|
||||
|
||||
-----------------------
|
||||
|
||||
busybox.defs.h is too big and hard to follow.
|
||||
|
||||
Perhaps I need to add a better build system (like the Linux kernel?)
|
||||
|
||||
-----------------------
|
||||
|
||||
Feature request:
|
||||
|
||||
/bin/busybox --install -s which makes all links to commands that it
|
||||
can support (an optionnal -s should be used for symbolic links instead
|
||||
of hard links).
|
||||
|
||||
-----------------------
|
||||
|
||||
|
||||
> Have you ever thought of doig network logging in busybox syslogd ? It
|
||||
> would quite make sense on embedded systems... :)
|
||||
|
||||
So far I had not considered it. Basically, you wish to have
|
||||
messages from the embedded box logged to a remote network
|
||||
syslog box, right? I can see that this would be useful.
|
||||
I'll add this to the TODO list,
|
||||
|
||||
|
||||
-----------------------
|
||||
|
||||
|
||||
I think that the add_inode &c in utility.c needs to also stow the
|
||||
st_dev field, and that du.c should NOT call `reset_inode_list'
|
||||
because there can be hard links from inside one argv/ to inside
|
||||
another argv/. du.c probably ought to have an -x switch like GNU du
|
||||
does also...
|
||||
|
||||
du.c probably ought to have an -x switch like GNU du does...
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
An interesting email listing some apps that use /proc. BusyBox
|
||||
tries to avoid /proc as mush as is possible, so this stuff is
|
||||
interesting (to me at least):
|
||||
|
||||
|
||||
Date: Fri, 25 Feb 2000 08:23:12 +0000 (GMT)
|
||||
From: Riley Williams <rhw@MemAlpha.CX>
|
||||
X-Sender: rhw@moo.cus.org.uk
|
||||
To: almesber@lrc.di.epfl.ch
|
||||
Cc: "Albert D. Cahalan" <acahalan@cs.uml.edu>,
|
||||
Linux Kernel <linux-kernel@vger.rutgers.edu>
|
||||
Subject: Re: What /proc should contain [was: /proc/driver/microcode]
|
||||
In-Reply-To: <20000224165245.A29790@lrc.di.epfl.ch>
|
||||
Message-ID: <Pine.LNX.4.21.0002250806220.8741-100000@moo.cus.org.uk>
|
||||
Sender: owner-linux-kernel@vger.rutgers.edu
|
||||
Precedence: bulk
|
||||
|
||||
Hi there.
|
||||
|
||||
>> Nope, most /proc access is does via programs written in C.
|
||||
|
||||
> That varies a lot from file to file. E.g. I haven't seen any
|
||||
> programs that are specificly designed to read /proc/atm/* yet,
|
||||
> and I know of only one (fuser) that reads /proc/mounts,
|
||||
> extracting only partial information (just to pick two examples
|
||||
> that I'm quite familiar with).
|
||||
|
||||
As a point of reference, here's a slightly tweaked analysis of the
|
||||
programs on the system I'm reading your mail on. Basically, I ran the
|
||||
following script...
|
||||
|
||||
Q> #!/bin/bash
|
||||
Q> function use() {
|
||||
Q> for Z in $* ; do
|
||||
Q> strings $Z | grep /proc | sed "s=^=$Z ="
|
||||
Q> done
|
||||
Q> }
|
||||
Q> use /{,s}bin/* /usr/{,s}bin/* | sort -u | tee proc-usage
|
||||
|
||||
...and then went through it removing comments and print format
|
||||
strings. Replace /proc with /dev and you'd soon have an equivalent
|
||||
list for that - although I can report that such is MUCH larger...
|
||||
|
||||
There are three programs therein that refer to /proc/mounts ...
|
||||
|
||||
/bin/mount
|
||||
/bin/umount
|
||||
/usr/bin/eject
|
||||
|
||||
...and, as you stated, none that refer to /proc/atm on this system.
|
||||
However, as this is a RedHat Linux 5.0 based system, that's not
|
||||
necessarily an up to date reference thereto...
|
||||
|
||||
Here's the list anyway...
|
||||
|
||||
/bin/kill /proc/%d/cmdline
|
||||
/bin/kill /proc/%d/stat
|
||||
|
||||
/bin/mount /proc/devices
|
||||
/bin/mount /proc/filesystems
|
||||
/bin/mount /proc/mounts
|
||||
|
||||
/bin/netstat /proc/net
|
||||
/bin/netstat /proc/net/appletalk
|
||||
/bin/netstat /proc/net/ax25
|
||||
/bin/netstat /proc/net/ax25_route
|
||||
/bin/netstat /proc/net/dev
|
||||
/bin/netstat /proc/net/ip_masquerade
|
||||
/bin/netstat /proc/net/ipx
|
||||
/bin/netstat /proc/net/ipx_route
|
||||
/bin/netstat /proc/net/netstat
|
||||
/bin/netstat /proc/net/nr
|
||||
/bin/netstat /proc/net/nr_neigh
|
||||
/bin/netstat /proc/net/nr_nodes
|
||||
/bin/netstat /proc/net/raw
|
||||
/bin/netstat /proc/net/route
|
||||
/bin/netstat /proc/net/rt_cache
|
||||
/bin/netstat /proc/net/snmp
|
||||
/bin/netstat /proc/net/tcp
|
||||
/bin/netstat /proc/net/udp
|
||||
/bin/netstat /proc/net/unix
|
||||
|
||||
/bin/umount /proc/devices
|
||||
/bin/umount /proc/mounts
|
||||
|
||||
/sbin/arp /proc/net/appletalk
|
||||
/sbin/arp /proc/net/arp
|
||||
/sbin/arp /proc/net/ax25
|
||||
/sbin/arp /proc/net/ipx
|
||||
/sbin/arp /proc/net/nr
|
||||
/sbin/arp /proc/net/unix
|
||||
|
||||
/sbin/cardctl /proc/devices
|
||||
|
||||
/sbin/cardmgr /proc/devices
|
||||
|
||||
/sbin/fdisk /proc/ide/%s/media
|
||||
/sbin/fdisk /proc/scsi/scsi
|
||||
|
||||
/sbin/getty /proc/version
|
||||
|
||||
/sbin/ifconfig /proc/net
|
||||
/sbin/ifconfig /proc/net/appletalk
|
||||
/sbin/ifconfig /proc/net/ax25
|
||||
/sbin/ifconfig /proc/net/dev
|
||||
/sbin/ifconfig /proc/net/ipx
|
||||
/sbin/ifconfig /proc/net/nr
|
||||
/sbin/ifconfig /proc/net/unix
|
||||
|
||||
/sbin/ifup /proc/sys/kernel/modprobe
|
||||
|
||||
/sbin/ipchains /proc/net/ip_fwchains
|
||||
/sbin/ipchains /proc/net/ip_fwnames
|
||||
/sbin/ipchains /proc/net/ip_masquerade
|
||||
/sbin/ipchains /proc/sys/net/ipv4/ip_forward
|
||||
|
||||
/sbin/ipmaddr /proc/net/dev_mcast
|
||||
/sbin/ipmaddr /proc/net/igmp
|
||||
/sbin/ipmaddr /proc/net/igmp6
|
||||
|
||||
/sbin/iptunnel /proc/net/dev
|
||||
|
||||
/sbin/killall5 /proc/%s/cmdline
|
||||
/sbin/killall5 /proc/%s/exe
|
||||
/sbin/killall5 /proc/%s/stat
|
||||
/sbin/killall5 /proc/version
|
||||
|
||||
/sbin/klogd /proc/kmsg
|
||||
|
||||
/sbin/lsmod /proc/modules
|
||||
|
||||
/sbin/modprobe /proc/modules
|
||||
|
||||
/sbin/pidof /proc/%s/cmdline
|
||||
/sbin/pidof /proc/%s/exe
|
||||
/sbin/pidof /proc/%s/stat
|
||||
/sbin/pidof /proc/version
|
||||
|
||||
/sbin/probe /proc/pci
|
||||
|
||||
/sbin/rarp /proc/net/ax25
|
||||
/sbin/rarp /proc/net/nr
|
||||
/sbin/rarp /proc/net/rarp
|
||||
|
||||
/sbin/rmmod /proc/modules
|
||||
|
||||
/sbin/rmmod.static /proc/modules
|
||||
|
||||
/sbin/route /proc/net/appletalk
|
||||
/sbin/route /proc/net/ax25
|
||||
/sbin/route /proc/net/ax25_route
|
||||
/sbin/route /proc/net/ipx
|
||||
/sbin/route /proc/net/ipx_route
|
||||
/sbin/route /proc/net/nr
|
||||
/sbin/route /proc/net/nr_neigh
|
||||
/sbin/route /proc/net/nr_nodes
|
||||
/sbin/route /proc/net/route
|
||||
/sbin/route /proc/net/rt_cache
|
||||
/sbin/route /proc/net/unix
|
||||
|
||||
/sbin/scsi_info /proc/scsi
|
||||
/sbin/scsi_info /proc/scsi/%s
|
||||
/sbin/scsi_info /proc/scsi/scsi
|
||||
|
||||
/sbin/slattach /proc/net/ax25
|
||||
/sbin/slattach /proc/net/nr
|
||||
|
||||
/sbin/swapoff /proc/swaps
|
||||
|
||||
/sbin/swapon /proc/swaps
|
||||
|
||||
/sbin/uugetty /proc/version
|
||||
|
||||
/usr/bin/dig /proc/
|
||||
/usr/bin/dig /proc/interrupts
|
||||
/usr/bin/dig /proc/meminfo
|
||||
/usr/bin/dig /proc/rtc
|
||||
/usr/bin/dig /proc/self/status
|
||||
/usr/bin/dig /proc/stat
|
||||
|
||||
/usr/bin/dnsquery /proc/
|
||||
/usr/bin/dnsquery /proc/interrupts
|
||||
/usr/bin/dnsquery /proc/meminfo
|
||||
/usr/bin/dnsquery /proc/rtc
|
||||
/usr/bin/dnsquery /proc/self/status
|
||||
/usr/bin/dnsquery /proc/stat
|
||||
|
||||
/usr/bin/eject /proc/mounts
|
||||
|
||||
/usr/bin/emacs /proc/loadavg
|
||||
|
||||
/usr/bin/fetchmail /proc/net/dev
|
||||
|
||||
/usr/bin/free /proc/meminfo
|
||||
|
||||
/usr/bin/gmake /proc/loadavg
|
||||
|
||||
/usr/bin/gpm-root /proc/loadavg
|
||||
/usr/bin/gpm-root /proc/meminfo
|
||||
|
||||
/usr/bin/host /proc/
|
||||
/usr/bin/host /proc/interrupts
|
||||
/usr/bin/host /proc/meminfo
|
||||
/usr/bin/host /proc/rtc
|
||||
/usr/bin/host /proc/self/status
|
||||
/usr/bin/host /proc/stat
|
||||
|
||||
/usr/bin/hoststat /proc/loadavg
|
||||
|
||||
/usr/bin/hwdiag /proc/cpuinfo
|
||||
/usr/bin/hwdiag /proc/pci
|
||||
/usr/bin/hwdiag /proc/scsi/scsi
|
||||
/usr/bin/hwdiag /proc/version
|
||||
|
||||
/usr/bin/lsdev /proc/dma
|
||||
/usr/bin/lsdev /proc/interrupts
|
||||
/usr/bin/lsdev /proc/ioports
|
||||
|
||||
/usr/bin/mailq /proc/loadavg
|
||||
|
||||
/usr/bin/make /proc/loadavg
|
||||
|
||||
/usr/bin/mcookie /proc/loadavg
|
||||
/usr/bin/mcookie /proc/stat
|
||||
|
||||
/usr/bin/newaliases /proc/loadavg
|
||||
|
||||
/usr/bin/nslookup /proc/
|
||||
/usr/bin/nslookup /proc/interrupts
|
||||
/usr/bin/nslookup /proc/meminfo
|
||||
/usr/bin/nslookup /proc/rtc
|
||||
/usr/bin/nslookup /proc/self/status
|
||||
/usr/bin/nslookup /proc/stat
|
||||
|
||||
/usr/bin/nsupdate /proc/
|
||||
/usr/bin/nsupdate /proc/interrupts
|
||||
/usr/bin/nsupdate /proc/meminfo
|
||||
/usr/bin/nsupdate /proc/rtc
|
||||
/usr/bin/nsupdate /proc/self/status
|
||||
/usr/bin/nsupdate /proc/stat
|
||||
|
||||
/usr/bin/pgp /proc/version
|
||||
/usr/bin/pgpe /proc/version
|
||||
/usr/bin/pgpk /proc/version
|
||||
/usr/bin/pgps /proc/version
|
||||
/usr/bin/pgpv /proc/version
|
||||
|
||||
/usr/bin/procinfo /proc/cmdline
|
||||
/usr/bin/procinfo /proc/devices
|
||||
/usr/bin/procinfo /proc/dma
|
||||
/usr/bin/procinfo /proc/filesystems
|
||||
/usr/bin/procinfo /proc/interrupts
|
||||
/usr/bin/procinfo /proc/loadavg
|
||||
/usr/bin/procinfo /proc/meminfo
|
||||
/usr/bin/procinfo /proc/modules
|
||||
/usr/bin/procinfo /proc/stat
|
||||
/usr/bin/procinfo /proc/uptime
|
||||
/usr/bin/procinfo /proc/version
|
||||
|
||||
/usr/bin/purgestat /proc/loadavg
|
||||
|
||||
/usr/bin/screen /proc/loadavg
|
||||
|
||||
/usr/bin/strace /proc/%d/stat
|
||||
|
||||
/usr/bin/top /proc/cpuinfo
|
||||
/usr/bin/top /proc/meminfo
|
||||
/usr/bin/top /proc/stat
|
||||
|
||||
/usr/bin/vmstat /proc/%s/stat
|
||||
/usr/bin/vmstat /proc/meminfo
|
||||
/usr/bin/vmstat /proc/stat
|
||||
|
||||
/usr/sbin/atd /proc/loadavg
|
||||
|
||||
/usr/sbin/dnskeygen /proc/
|
||||
/usr/sbin/dnskeygen /proc/interrupts
|
||||
/usr/sbin/dnskeygen /proc/meminfo
|
||||
/usr/sbin/dnskeygen /proc/rtc
|
||||
/usr/sbin/dnskeygen /proc/self/status
|
||||
/usr/sbin/dnskeygen /proc/stat
|
||||
|
||||
/usr/sbin/fuser /proc/%d/stat
|
||||
/usr/sbin/fuser /proc/net/%s
|
||||
/usr/sbin/fuser /proc/net/unix
|
||||
|
||||
/usr/sbin/in.identd /proc/net/tcp
|
||||
|
||||
/usr/sbin/irpd /proc/
|
||||
/usr/sbin/irpd /proc/interrupts
|
||||
/usr/sbin/irpd /proc/meminfo
|
||||
/usr/sbin/irpd /proc/rtc
|
||||
/usr/sbin/irpd /proc/self/status
|
||||
/usr/sbin/irpd /proc/stat
|
||||
|
||||
/usr/sbin/named /proc/
|
||||
/usr/sbin/named /proc/interrupts
|
||||
/usr/sbin/named /proc/meminfo
|
||||
/usr/sbin/named /proc/rtc
|
||||
/usr/sbin/named /proc/self/status
|
||||
/usr/sbin/named /proc/stat
|
||||
|
||||
/usr/sbin/named-xfer /proc/
|
||||
/usr/sbin/named-xfer /proc/interrupts
|
||||
/usr/sbin/named-xfer /proc/meminfo
|
||||
/usr/sbin/named-xfer /proc/rtc
|
||||
/usr/sbin/named-xfer /proc/self/status
|
||||
/usr/sbin/named-xfer /proc/stat
|
||||
|
||||
/usr/sbin/readprofile /proc/profile
|
||||
|
||||
/usr/sbin/rwhod /proc/loadavg
|
||||
/usr/sbin/rwhod /proc/uptime
|
||||
|
||||
/usr/sbin/sendmail /proc/loadavg
|
||||
|
||||
/usr/sbin/setconsole /proc/openprom/options
|
||||
/usr/sbin/setconsole /proc/openprom/options/${console}-mode
|
||||
/usr/sbin/setconsole /proc/openprom/options/input-device
|
||||
/usr/sbin/setconsole /proc/openprom/options/output-device
|
||||
|
||||
Best wishes from Riley.
|
||||
|
||||
* Copyright (C) 1999, Memory Alpha Systems.
|
||||
* All rights and wrongs reserved.
|
||||
|
||||
+----------------------------------------------------------------------+
|
||||
| There is something frustrating about the quality and speed of Linux |
|
||||
| development, ie., the quality is too high and the speed is too high, |
|
||||
| in other words, I can implement this XXXX feature, but I bet someone |
|
||||
| else has already done so and is just about to release their patch. |
|
||||
+----------------------------------------------------------------------+
|
||||
* http://www.memalpha.cx/Linux/Kernel/
|
||||
|
||||
|
||||
-
|
||||
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
|
||||
the body of a message to majordomo@vger.rutgers.edu
|
||||
Please read the FAQ at http://www.tux.org/lkml/
|
||||
|
||||
@@ -0,0 +1,397 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(PROTOTYPES)
|
||||
#define APPLET(a,b,c,d) \
|
||||
extern int b(int argc, char **argv); \
|
||||
extern const char d[];
|
||||
#define APPLET_NOUSAGE(a,b,c) \
|
||||
extern int b(int argc, char **argv);
|
||||
#elif defined(MAKE_LINKS)
|
||||
#define APPLET(a,b,c,d) LINK c a
|
||||
#define APPLET_NOUSAGE(a,b,c) LINK c a
|
||||
#else
|
||||
const struct BB_applet applets[] = {
|
||||
#define APPLET(a,b,c,d) {a,b,c,d},
|
||||
#define APPLET_NOUSAGE(a,b,c) {a,b,c,NULL},
|
||||
#endif
|
||||
|
||||
#ifdef BB_TEST
|
||||
APPLET("[", test_main, _BB_DIR_USR_BIN, test_usage)
|
||||
#endif
|
||||
#ifdef BB_AR
|
||||
APPLET("ar", ar_main, _BB_DIR_USR_BIN, ar_usage)
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
APPLET("basename", basename_main, _BB_DIR_USR_BIN, basename_usage)
|
||||
#endif
|
||||
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
|
||||
#ifdef BB_CAT
|
||||
APPLET("cat", cat_main, _BB_DIR_BIN, cat_usage)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chmod", chmod_chown_chgrp_main, _BB_DIR_BIN, chmod_usage)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chown", chmod_chown_chgrp_main, _BB_DIR_BIN, chown_usage)
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
APPLET("chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage)
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
APPLET("chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage)
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
APPLET("clear", clear_main, _BB_DIR_USR_BIN, clear_usage)
|
||||
#endif
|
||||
#ifdef BB_CMP
|
||||
APPLET("cmp", cmp_main, _BB_DIR_USR_BIN, cmp_usage)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET("cp", cp_mv_main, _BB_DIR_BIN, cp_usage)
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
APPLET("cut", cut_main, _BB_DIR_USR_BIN, cut_usage)
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
APPLET("date", date_main, _BB_DIR_BIN, date_usage)
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
APPLET("dc", dc_main, _BB_DIR_USR_BIN, dc_usage)
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
APPLET("dd", dd_main, _BB_DIR_BIN, dd_usage)
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
APPLET("deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage)
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
APPLET("df", df_main, _BB_DIR_BIN, df_usage)
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
APPLET("dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage)
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
APPLET("dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage)
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
APPLET("dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage)
|
||||
#endif
|
||||
#ifdef BB_DPKG_DEB
|
||||
APPLET("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb_usage)
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
APPLET("du", du_main, _BB_DIR_USR_BIN, du_usage)
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
APPLET("dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage)
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
APPLET("dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage)
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
APPLET("echo", echo_main, _BB_DIR_BIN, echo_usage)
|
||||
#endif
|
||||
#ifdef BB_EXPR
|
||||
APPLET("expr", expr_main, _BB_DIR_USR_BIN, expr_usage)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET("false", false_main, _BB_DIR_BIN, false_usage)
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
APPLET_NOUSAGE("fbset", fbset_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
APPLET("fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage)
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
APPLET("find", find_main, _BB_DIR_USR_BIN, find_usage)
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
APPLET("free", free_main, _BB_DIR_USR_BIN, free_usage)
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
APPLET("freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage)
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
APPLET("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage)
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
APPLET("getopt", getopt_main, _BB_DIR_BIN, getopt_usage)
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
APPLET("grep", grep_main, _BB_DIR_BIN, grep_usage)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET("gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage)
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
APPLET("gzip", gzip_main, _BB_DIR_BIN, gzip_usage)
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
APPLET("halt", halt_main, _BB_DIR_SBIN, halt_usage)
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
APPLET("head", head_main, _BB_DIR_USR_BIN, head_usage)
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
APPLET("hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage)
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
APPLET("hostname", hostname_main, _BB_DIR_BIN, hostname_usage)
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
APPLET("id", id_main, _BB_DIR_USR_BIN, id_usage)
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
APPLET_NOUSAGE("init", init_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
APPLET("insmod", insmod_main, _BB_DIR_SBIN, insmod_usage)
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
APPLET("kill", kill_main, _BB_DIR_BIN, kill_usage)
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
APPLET("killall", kill_main, _BB_DIR_USR_BIN, killall_usage)
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
APPLET("length", length_main, _BB_DIR_USR_BIN, length_usage)
|
||||
#endif
|
||||
#ifdef BB_LINUXRC
|
||||
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
APPLET("ln", ln_main, _BB_DIR_BIN, ln_usage)
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
APPLET("loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage)
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
APPLET("loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage)
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
APPLET("loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage)
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
APPLET("logger", logger_main, _BB_DIR_USR_BIN, logger_usage)
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
APPLET("logname", logname_main, _BB_DIR_USR_BIN, logname_usage)
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
APPLET("ls", ls_main, _BB_DIR_BIN, ls_usage)
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
APPLET("lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage)
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
APPLET("makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage)
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
APPLET("md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage)
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
APPLET("mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage)
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
APPLET("mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage)
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
APPLET("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage)
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
APPLET("mknod", mknod_main, _BB_DIR_BIN, mknod_usage)
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
APPLET("mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage)
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
APPLET("mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage)
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
APPLET("more", more_main, _BB_DIR_BIN, more_usage)
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
APPLET("mount", mount_main, _BB_DIR_BIN, mount_usage)
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
APPLET("mt", mt_main, _BB_DIR_BIN, mt_usage)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET("mv", cp_mv_main, _BB_DIR_BIN, mv_usage)
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
APPLET("nc", nc_main, _BB_DIR_USR_BIN, nc_usage)
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
APPLET("nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage)
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage)
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage)
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
APPLET("printf", printf_main, _BB_DIR_USR_BIN, printf_usage)
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
APPLET("ps", ps_main, _BB_DIR_BIN, ps_usage)
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
APPLET("pwd", pwd_main, _BB_DIR_BIN, pwd_usage)
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
APPLET("rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage)
|
||||
#endif
|
||||
#ifdef BB_READLINK
|
||||
APPLET("readlink", readlink_main, _BB_DIR_USR_BIN, readlink_usage)
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
APPLET("reboot", reboot_main, _BB_DIR_SBIN, reboot_usage)
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
APPLET("renice", renice_main, _BB_DIR_USR_BIN, renice_usage)
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
APPLET("reset", reset_main, _BB_DIR_USR_BIN, reset_usage)
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
APPLET("rm", rm_main, _BB_DIR_BIN, rm_usage)
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
APPLET("rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage)
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
APPLET("rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage)
|
||||
#endif
|
||||
#ifdef BB_RPMUNPACK
|
||||
APPLET("rpmunpack", rpmunpack_main, _BB_DIR_USR_BIN, rpmunpack_usage)
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
APPLET("sed", sed_main, _BB_DIR_BIN, sed_usage)
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
APPLET("setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage)
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
APPLET("sh", shell_main, _BB_DIR_BIN, shell_usage)
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
APPLET("sleep", sleep_main, _BB_DIR_BIN, sleep_usage)
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
APPLET("sort", sort_main, _BB_DIR_USR_BIN, sort_usage)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET("swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET("swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage)
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
APPLET("sync", sync_main, _BB_DIR_BIN, sync_usage)
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
APPLET("syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage)
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
APPLET("tail", tail_main, _BB_DIR_USR_BIN, tail_usage)
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
APPLET("tar", tar_main, _BB_DIR_BIN, tar_usage)
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
APPLET("tee", tee_main, _BB_DIR_USR_BIN, tee_usage)
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
APPLET("telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage)
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
APPLET("test", test_main, _BB_DIR_USR_BIN, test_usage)
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
APPLET("touch", touch_main, _BB_DIR_BIN, touch_usage)
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
APPLET("tr", tr_main, _BB_DIR_USR_BIN, tr_usage)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET("true", true_main, _BB_DIR_BIN, true_usage)
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
APPLET("tty", tty_main, _BB_DIR_USR_BIN, tty_usage)
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
APPLET("umount", umount_main, _BB_DIR_BIN, umount_usage)
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
APPLET("uname", uname_main, _BB_DIR_BIN, uname_usage)
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
APPLET("uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage)
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
APPLET("unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage)
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
APPLET("update", update_main, _BB_DIR_SBIN, update_usage)
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
APPLET("uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage)
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
APPLET("usleep", usleep_main, _BB_DIR_BIN, usleep_usage)
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
APPLET("uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage)
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
APPLET("uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage)
|
||||
#endif
|
||||
#ifdef BB_WATCHDOG
|
||||
APPLET("watchdog", watchdog_main, _BB_DIR_SBIN, watchdog_usage)
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
APPLET("wc", wc_main, _BB_DIR_USR_BIN, wc_usage)
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
APPLET("wget", wget_main, _BB_DIR_USR_BIN, wget_usage)
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
APPLET("which", which_main, _BB_DIR_USR_BIN, which_usage)
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
APPLET("whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage)
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
APPLET("xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage)
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
APPLET("yes", yes_main, _BB_DIR_USR_BIN, yes_usage)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET("zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage)
|
||||
#endif
|
||||
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_LINKS)
|
||||
{ 0,NULL,0,NULL}
|
||||
};
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,NULL} entry above. */
|
||||
size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
#endif
|
||||
+142
-364
@@ -1,405 +1,170 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.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;
|
||||
|
||||
/* It has been alledged that doing such things can
|
||||
* help reduce binary size when staticly linking,
|
||||
* of course with glibc, this is unlikely as long
|
||||
* as we use things like printf -- perhaps a printf
|
||||
* replacement may be in order
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
#if 0
|
||||
void exit(int status) __attribute__ ((noreturn));
|
||||
void exit(int status)
|
||||
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()
|
||||
{
|
||||
_exit(status);
|
||||
};
|
||||
void abort(void) __attribute__ ((__noreturn__));
|
||||
void abort(void)
|
||||
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)
|
||||
{
|
||||
_exit(0);
|
||||
};
|
||||
int atexit(void (*__func) (void))
|
||||
{
|
||||
_exit(0);
|
||||
};
|
||||
void *__libc_stack_end;
|
||||
#endif
|
||||
__link_f Link = link;
|
||||
|
||||
const struct BB_applet applets[] = {
|
||||
char command[256];
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
#ifdef BB_AR
|
||||
{"ar", ar_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
{"basename", basename_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
{"busybox", busybox_main, _BB_DIR_BIN},
|
||||
#ifdef BB_BLOCK_DEVICE
|
||||
{"block_device", block_device_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_CAT
|
||||
{"cat", cat_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
{"chroot", chroot_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
{"clear", clear_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
{"chvt", chvt_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
{"cp", cp_mv_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
{"cut", cut_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
{"date", date_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
{"dc", dc_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
{"dd", dd_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
{"df", df_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
{"dirname", dirname_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
{"dmesg", dmesg_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
{"du", du_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
{"echo", echo_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
{"false", false_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
{"fdflush", fdflush_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
{"find", find_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
{"free", free_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
{"grep", grep_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
{"gunzip", gunzip_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
{"gzip", gzip_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
{"halt", halt_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
{"head", head_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
{"hostid", hostid_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
{"hostname", hostname_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
{"id", id_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
{"init", init_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
{"insmod", insmod_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
{"kill", kill_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
{"killall", kill_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
{"length", length_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LINUXRC
|
||||
{"linuxrc", init_main, _BB_DIR_ROOT},
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
{"ln", ln_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
{"loadacm", loadacm_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
{"loadfont", loadfont_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
{"logger", logger_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
{"logname", logname_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
{"ls", ls_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
{"lsmod", lsmod_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
{"makedevs", makedevs_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
{"md5sum", md5sum_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
{"mkdir", mkdir_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
{"mknod", mknod_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
{"mkswap", mkswap_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
{"mktemp", mktemp_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
{"nc", nc_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
{"more", more_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
{"mount", mount_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
{"mt", mt_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
{"mv", cp_mv_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
{"ping", ping_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
{"poweroff", poweroff_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
{"printf", printf_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
{"ps", ps_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
{"pwd", pwd_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
{"reboot", reboot_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
{"rm", rm_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
{"rmdir", rmdir_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
{"rmmod", rmmod_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
{"sed", sed_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SFDISK
|
||||
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
{"sh", shell_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
{"sleep", sleep_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
{"sort", sort_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
{"sync", sync_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
{"syslogd", syslogd_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
{"swapoff", swap_on_off_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
{"tail", tail_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
{"tar", tar_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
{"telnet", telnet_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
{"test", test_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
{"tee", tee_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
{"touch", touch_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
{"tr", tr_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
{"true", true_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
{"tty", tty_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
{"umount", umount_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
{"uname", uname_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
{"uniq", uniq_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
{"update", update_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
{"uptime", uptime_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
{"uuencode", uuencode_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
{"uudecode", uudecode_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
{"usleep", usleep_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
{"wc", wc_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
{"which", which_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
{"whoami", whoami_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
{"yes", yes_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
{"zcat", gunzip_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
{"[", test_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
{0}
|
||||
};
|
||||
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)
|
||||
{
|
||||
char *s;
|
||||
char *name;
|
||||
const struct BB_applet *a = applets;
|
||||
struct BB_applet search_applet, *applet;
|
||||
const char *s;
|
||||
|
||||
for (s = name = argv[0]; *s != '\0';) {
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
name = s;
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
*argv = name;
|
||||
|
||||
while (a->name != 0) {
|
||||
if (strcmp(name, a->name) == 0) {
|
||||
exit(((*(a->main)) (argc, argv)));
|
||||
}
|
||||
a++;
|
||||
#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)));
|
||||
}
|
||||
return(busybox_main(argc, argv));
|
||||
#endif
|
||||
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
search_applet.name = applet_name;
|
||||
applet = bsearch(&search_applet, applets, NUM_APPLETS,
|
||||
sizeof(struct BB_applet), applet_name_compare);
|
||||
if (applet != NULL) {
|
||||
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(applet->usage);
|
||||
exit((*(applet->main)) (argc, argv));
|
||||
}
|
||||
|
||||
error_msg_and_die("applet not found\n");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0;
|
||||
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--;
|
||||
argv++;
|
||||
|
||||
/* 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, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n"
|
||||
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", BB_VER, BB_BT);
|
||||
"\nCurrently defined functions:\n", full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
@@ -413,8 +178,21 @@ int busybox_main(int argc, char **argv)
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
}
|
||||
/* If we've already been here once, exit now */
|
||||
|
||||
/* 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));
|
||||
}
|
||||
|
||||
|
||||
+16
-14
@@ -1,19 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
DF="busybox.def.h"
|
||||
MF="busybox.c"
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
for def in ${LIST}; do
|
||||
i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
|
||||
for j in $i; do
|
||||
if [ -z $j ] ; then
|
||||
continue;
|
||||
fi;
|
||||
echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
|
||||
-e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
|
||||
-e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
|
||||
done;
|
||||
done
|
||||
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
|
||||
}'
|
||||
+8
-5
@@ -1,10 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
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:-.}
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 ` \
|
||||
gcc -E -dM busybox.def.h | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr [:upper:] [:lower:] | sort
|
||||
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
|
||||
+38
-10
@@ -1,21 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$1" = "" ]; then
|
||||
prefix=$1
|
||||
if [ "$prefix" = "" ]; then
|
||||
echo "No installation directory, aborting."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
linkopts="-f"
|
||||
else
|
||||
linkopts="-fs"
|
||||
fi
|
||||
h=`sort busybox.links | uniq`
|
||||
|
||||
|
||||
rm -f $prefix/bin/busybox || exit 1
|
||||
mkdir -p $prefix/bin || exit 1
|
||||
install -m 755 busybox $prefix/bin/busybox || exit 1
|
||||
|
||||
for i in $h ; do
|
||||
echo " $1$i -> /bin/busybox"
|
||||
mkdir -p $1/`echo $i | sed -e 's/\/[^\/]*$//' `
|
||||
ln -fs /bin/busybox $1$i
|
||||
appdir=`dirname $i`
|
||||
mkdir -p $prefix/$appdir || exit 1
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
bb_path="$prefix/bin/busybox"
|
||||
else
|
||||
case "$appdir" in
|
||||
/)
|
||||
bb_path="bin/busybox"
|
||||
;;
|
||||
/bin)
|
||||
bb_path="busybox"
|
||||
;;
|
||||
/sbin)
|
||||
bb_path="../bin/busybox"
|
||||
;;
|
||||
/usr/bin|/usr/sbin)
|
||||
bb_path="../../bin/busybox"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown installation directory: $appdir"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
echo " $prefix$i -> $bb_path"
|
||||
ln $linkopts $bb_path $prefix$i || exit 1
|
||||
done
|
||||
rm -f $1/bin/busybox
|
||||
mkdir -p $1/bin
|
||||
install -m 755 busybox $1/bin/busybox
|
||||
|
||||
exit 0
|
||||
+1560
File diff suppressed because it is too large.
Load diff
@@ -3,8 +3,8 @@
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
|
||||
*
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,312 +21,203 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Last modified 10 June 2000
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <sys/types.h>
|
||||
#include "internal.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define AR_BLOCK_SIZE 60
|
||||
#define AR_PRESERVE_DATE 1
|
||||
#define AR_VERBOSE 2
|
||||
#define AR_DISPLAY 4
|
||||
#define AR_EXT_TO_FILE 8
|
||||
#define AR_EXT_TO_STDOUT 16
|
||||
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_io_error
|
||||
#include "messages.c"
|
||||
|
||||
struct ArHeader { /* Byte Offset */
|
||||
char ar_name[16]; /* 0-15 */
|
||||
char ar_date[12]; /* 16-27 */
|
||||
char ar_uid[6], ar_gid[6]; /* 28-39 */
|
||||
char ar_mode[8]; /* 40-47 */
|
||||
char ar_size[10]; /* 48-57 */
|
||||
char ar_fmag[2]; /* 58-59 */
|
||||
};
|
||||
typedef struct ArHeader ArHeader;
|
||||
|
||||
struct ArInfo {
|
||||
char name[17]; /* File name */
|
||||
time_t date; /* long int, No of seconds since epoch */
|
||||
uid_t uid; /* unsigned int, Numeric UID */
|
||||
gid_t gid; /* unsigned int, Numeric GID */
|
||||
mode_t mode; /* unsigned int, Unix mode */
|
||||
size_t size; /* int, Size of the file */
|
||||
};
|
||||
typedef struct ArInfo ArInfo;
|
||||
|
||||
static const char ar_usage[] = "ar [optxvV] archive [filenames] \n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nExtract or list files from an ar archive.\n\n"
|
||||
"Options:\n"
|
||||
"\to\t\tpreserve original dates\n"
|
||||
"\tp\t\textract to stdout\n"
|
||||
"\tt\t\tlist\n"
|
||||
"\tx\t\textract\n"
|
||||
"\tv\t\tverbosely list files processed\n"
|
||||
#endif
|
||||
;
|
||||
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;
|
||||
|
||||
/*
|
||||
* Display details of a file, verbosly if funct=2
|
||||
* return the headerL_t struct for the filename descriptor
|
||||
*/
|
||||
static void displayEntry(struct ArInfo *entry, int funct)
|
||||
extern ar_headers_t get_headers(int srcFd)
|
||||
{
|
||||
/* TODO convert mode to string */
|
||||
if ((funct & AR_VERBOSE) == AR_VERBOSE)
|
||||
printf("%i %i/%i %8i %s ", entry->mode, entry->uid, entry->gid,
|
||||
entry->size, timeString(entry->date));
|
||||
printf("%s\n", entry->name);
|
||||
}
|
||||
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;
|
||||
|
||||
/* this is from tar.c remove later*/
|
||||
static long getOctal(const char *cp, int size)
|
||||
{
|
||||
long val = 0;
|
||||
|
||||
for(;(size > 0) && (*cp == ' '); cp++, size--);
|
||||
if ((size == 0) || !isOctal(*cp))
|
||||
return -1;
|
||||
for(; (size > 0) && isOctal(*cp); size--) {
|
||||
val = val * 8 + *cp++ - '0';
|
||||
}
|
||||
for (;(size > 0) && (*cp == ' '); cp++, size--);
|
||||
if ((size > 0) && *cp)
|
||||
return -1;
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts from the char based struct to a new struct with stricter types
|
||||
*/
|
||||
static int processArHeader(struct ArHeader *rawHeader, struct ArInfo *header)
|
||||
{
|
||||
int count2;
|
||||
int count;
|
||||
ar_headers_t *head, *entry;
|
||||
char ar_magic[8];
|
||||
char *long_name=NULL;
|
||||
|
||||
/* check end of header marker is valid */
|
||||
if ((rawHeader->ar_fmag[0]!='`') || (rawHeader->ar_fmag[1]!='\n'))
|
||||
return(FALSE);
|
||||
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\n");
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0)
|
||||
error_msg_and_die("invalid magic\n");
|
||||
|
||||
/* convert filename */
|
||||
for (count = 0; count < 16; count++) {
|
||||
/* allow spaces in filename except at the end */
|
||||
if (rawHeader->ar_name[count] == ' ') {
|
||||
for (count2 = count; count2 < 16; count2++)
|
||||
if (!isspace(rawHeader->ar_name[count2]))
|
||||
break;
|
||||
if (count2 >= 16)
|
||||
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[1];
|
||||
if (raw_ar_header.fmag[1]!='`') {
|
||||
break;
|
||||
}
|
||||
/* GNU ar uses '/' as an end of filename marker */
|
||||
if (rawHeader->ar_name[count] == '/')
|
||||
break;
|
||||
header->name[count] = rawHeader->ar_name[count];
|
||||
}
|
||||
header->name[count] = '\0';
|
||||
header->date = atoi(rawHeader->ar_date);
|
||||
header->uid = atoi(rawHeader->ar_uid);
|
||||
header->gid = atoi(rawHeader->ar_gid);
|
||||
header->mode = getOctal(rawHeader->ar_mode, sizeof(rawHeader->ar_mode));
|
||||
header->size = atoi(rawHeader->ar_size);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy size bytes from current position if srcFd to current position in dstFd
|
||||
* taken from tarExtractRegularFile in tar.c, remove later
|
||||
*/
|
||||
static int copySubFile(int srcFd, int dstFd, int copySize)
|
||||
{
|
||||
int readSize, writeSize, doneSize;
|
||||
char buffer[BUFSIZ];
|
||||
|
||||
while (copySize > 0) {
|
||||
if (copySize > BUFSIZ)
|
||||
readSize = BUFSIZ;
|
||||
else
|
||||
readSize = copySize;
|
||||
writeSize = fullRead(srcFd, buffer, readSize);
|
||||
if (writeSize <= 0) {
|
||||
errorMsg(io_error, "copySubFile :", strerror(errno));
|
||||
return (FALSE);
|
||||
}
|
||||
doneSize = fullWrite(dstFd, buffer, writeSize);
|
||||
if (doneSize <= 0) {
|
||||
errorMsg(io_error, "copySubFile :", strerror(errno));
|
||||
return (FALSE);
|
||||
}
|
||||
copySize -= doneSize;
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract the file described in ArInfo to the specified path
|
||||
* set the new files uid, gid and mode
|
||||
*/
|
||||
static int extractToFile(struct ArInfo *file, int funct, int srcFd, const char *path)
|
||||
{
|
||||
int dstFd, temp;
|
||||
struct stat tmpStat;
|
||||
char *pathname = NULL;
|
||||
struct utimbuf newtime;
|
||||
|
||||
if ((temp = isDirectory(path, TRUE, &tmpStat)) != TRUE) {
|
||||
if (!createPath(path, 0777)) {
|
||||
fatalError("Cannot extract to specified path");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
temp = (strlen(path) + 16);
|
||||
pathname = (char *) xmalloc(temp);
|
||||
pathname = strcpy(pathname, path);
|
||||
pathname = strcat(pathname, file->name);
|
||||
dstFd = device_open(pathname, O_WRONLY | O_CREAT);
|
||||
temp = copySubFile(srcFd, dstFd, file->size);
|
||||
fchown(dstFd, file->uid, file->gid);
|
||||
fchmod(dstFd, file->mode);
|
||||
close(dstFd);
|
||||
if ((funct&AR_PRESERVE_DATE)==AR_PRESERVE_DATE)
|
||||
newtime.modtime=file->date;
|
||||
else
|
||||
newtime.modtime=time(0);
|
||||
newtime.actime=time(0);
|
||||
temp = utime(pathname, &newtime);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a file descriptor for the specified file and do error checks
|
||||
*/
|
||||
static int getArFd(char *filename)
|
||||
{
|
||||
int arFd;
|
||||
char arVersion[8];
|
||||
|
||||
arFd = open(filename, O_RDONLY);
|
||||
if (arFd < 0) {
|
||||
errorMsg("Error opening '%s': %s\n", filename, strerror(errno));
|
||||
return (FALSE);
|
||||
}
|
||||
if (fullRead(arFd, arVersion, 8) <= 0) {
|
||||
errorMsg( "ar: Unexpected EOF in archive\n");
|
||||
return (FALSE);
|
||||
}
|
||||
if (strncmp(arVersion,"!<arch>",7) != 0) {
|
||||
errorMsg("ar header fails check ");
|
||||
return(FALSE);
|
||||
}
|
||||
return arFd;
|
||||
}
|
||||
|
||||
/*
|
||||
* Step through the ar file and process it one entry at a time
|
||||
* fileList[0] is the name of the ar archive
|
||||
* fileList[1] and up are filenames to extract from the archive
|
||||
* funct contains flags to specify the actions to be performed
|
||||
*/
|
||||
static int readArFile(char *fileList[16], int fileListSize, int funct)
|
||||
{
|
||||
int arFd, status, extFileFlag, i, lastOffset=0;
|
||||
ArHeader rawArHeader;
|
||||
ArInfo arEntry;
|
||||
|
||||
/* open the ar archive */
|
||||
arFd=getArFd(fileList[0]);
|
||||
|
||||
/* read the first header, then loop until ono more headers */
|
||||
while ((status = fullRead(arFd, (char *) &rawArHeader, AR_BLOCK_SIZE))
|
||||
== AR_BLOCK_SIZE) {
|
||||
|
||||
/* check the header is valid, if not try reading the header
|
||||
agian with an offset of 1, needed as some ar archive end
|
||||
with a '\n' which isnt counted in specified file size */
|
||||
if ((status=processArHeader(&rawArHeader, &arEntry))==FALSE ) {
|
||||
if ((i=lseek(arFd, 0, SEEK_CUR))==(lastOffset+60))
|
||||
lseek(arFd, lastOffset+1, SEEK_SET);
|
||||
else
|
||||
return(FALSE);
|
||||
}
|
||||
else {
|
||||
extFileFlag=0;
|
||||
|
||||
if (funct&AR_DISPLAY)
|
||||
displayEntry(&arEntry, funct);
|
||||
|
||||
/* check file was specified to be extracted only if
|
||||
some file were specified */
|
||||
if ((funct&AR_EXT_TO_FILE) || (funct&AR_EXT_TO_STDOUT)){
|
||||
if (fileListSize==1)
|
||||
extFileFlag=1;
|
||||
else {
|
||||
for( i=1; i<=fileListSize; i++)
|
||||
if ((status=(strcmp(fileList[i],arEntry.name)))==0)
|
||||
extFileFlag=1;
|
||||
}
|
||||
}
|
||||
if (extFileFlag==1) {
|
||||
if (funct&AR_EXT_TO_FILE)
|
||||
extractToFile(&arEntry, funct, arFd, "./");
|
||||
else
|
||||
copySubFile(arFd,fileno(stdout),arEntry.size);
|
||||
}
|
||||
else
|
||||
lseek(arFd, arEntry.size, SEEK_CUR);
|
||||
lastOffset=lseek(arFd, 0, SEEK_CUR);
|
||||
} /* if processArHeader */
|
||||
} /* while */
|
||||
return (TRUE);
|
||||
/* some version of ar, have an extra '\n' after each entry */
|
||||
read(srcFd, newline, 1);
|
||||
if (newline[0]!='\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)
|
||||
{
|
||||
int funct = 0, ret=0, i=0;
|
||||
char *fileList[16], c, *opt_ptr;
|
||||
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 */
|
||||
|
||||
if (argc < 2)
|
||||
usage(ar_usage);
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
|
||||
opt_ptr = argv[1];
|
||||
if (*opt_ptr == '-')
|
||||
++opt_ptr;
|
||||
while ((c = *opt_ptr++) != '\0') {
|
||||
switch (c) {
|
||||
case 'o': /* preserver original dates */
|
||||
funct = funct | 1;
|
||||
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 'p': /* extract to stdout */
|
||||
funct = funct | 16;
|
||||
case 'v':
|
||||
funct |= verbose;
|
||||
break;
|
||||
case 't': /* display contents */
|
||||
funct = funct | 4;
|
||||
case 't':
|
||||
funct |= display;
|
||||
break;
|
||||
case 'x': /* extract contents of archive */
|
||||
funct = funct | 8;
|
||||
case 'p':
|
||||
funct |= extract_to_stdout;
|
||||
break;
|
||||
case 'v': /* be verbose */
|
||||
funct = funct | 2;
|
||||
case 'x':
|
||||
funct |= extract_to_file;
|
||||
break;
|
||||
default:
|
||||
usage(ar_usage);
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
usage(ar_usage);
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s\n", argv[optind]);
|
||||
|
||||
for(i=0; i<(argc-2); i++)
|
||||
fileList[i]=argv[i+2];
|
||||
optind++;
|
||||
head = get_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;
|
||||
}
|
||||
|
||||
if (funct > 3)
|
||||
ret = readArFile(fileList, (argc-2), funct);
|
||||
|
||||
return (ret);
|
||||
/* 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;
|
||||
}
|
||||
+172
-281
@@ -3,8 +3,8 @@
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
|
||||
*
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,312 +21,203 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Last modified 10 June 2000
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <sys/types.h>
|
||||
#include "internal.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define AR_BLOCK_SIZE 60
|
||||
#define AR_PRESERVE_DATE 1
|
||||
#define AR_VERBOSE 2
|
||||
#define AR_DISPLAY 4
|
||||
#define AR_EXT_TO_FILE 8
|
||||
#define AR_EXT_TO_STDOUT 16
|
||||
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_io_error
|
||||
#include "messages.c"
|
||||
|
||||
struct ArHeader { /* Byte Offset */
|
||||
char ar_name[16]; /* 0-15 */
|
||||
char ar_date[12]; /* 16-27 */
|
||||
char ar_uid[6], ar_gid[6]; /* 28-39 */
|
||||
char ar_mode[8]; /* 40-47 */
|
||||
char ar_size[10]; /* 48-57 */
|
||||
char ar_fmag[2]; /* 58-59 */
|
||||
};
|
||||
typedef struct ArHeader ArHeader;
|
||||
|
||||
struct ArInfo {
|
||||
char name[17]; /* File name */
|
||||
time_t date; /* long int, No of seconds since epoch */
|
||||
uid_t uid; /* unsigned int, Numeric UID */
|
||||
gid_t gid; /* unsigned int, Numeric GID */
|
||||
mode_t mode; /* unsigned int, Unix mode */
|
||||
size_t size; /* int, Size of the file */
|
||||
};
|
||||
typedef struct ArInfo ArInfo;
|
||||
|
||||
static const char ar_usage[] = "ar [optxvV] archive [filenames] \n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nExtract or list files from an ar archive.\n\n"
|
||||
"Options:\n"
|
||||
"\to\t\tpreserve original dates\n"
|
||||
"\tp\t\textract to stdout\n"
|
||||
"\tt\t\tlist\n"
|
||||
"\tx\t\textract\n"
|
||||
"\tv\t\tverbosely list files processed\n"
|
||||
#endif
|
||||
;
|
||||
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;
|
||||
|
||||
/*
|
||||
* Display details of a file, verbosly if funct=2
|
||||
* return the headerL_t struct for the filename descriptor
|
||||
*/
|
||||
static void displayEntry(struct ArInfo *entry, int funct)
|
||||
extern ar_headers_t get_headers(int srcFd)
|
||||
{
|
||||
/* TODO convert mode to string */
|
||||
if ((funct & AR_VERBOSE) == AR_VERBOSE)
|
||||
printf("%i %i/%i %8i %s ", entry->mode, entry->uid, entry->gid,
|
||||
entry->size, timeString(entry->date));
|
||||
printf("%s\n", entry->name);
|
||||
}
|
||||
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;
|
||||
|
||||
/* this is from tar.c remove later*/
|
||||
static long getOctal(const char *cp, int size)
|
||||
{
|
||||
long val = 0;
|
||||
|
||||
for(;(size > 0) && (*cp == ' '); cp++, size--);
|
||||
if ((size == 0) || !isOctal(*cp))
|
||||
return -1;
|
||||
for(; (size > 0) && isOctal(*cp); size--) {
|
||||
val = val * 8 + *cp++ - '0';
|
||||
}
|
||||
for (;(size > 0) && (*cp == ' '); cp++, size--);
|
||||
if ((size > 0) && *cp)
|
||||
return -1;
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts from the char based struct to a new struct with stricter types
|
||||
*/
|
||||
static int processArHeader(struct ArHeader *rawHeader, struct ArInfo *header)
|
||||
{
|
||||
int count2;
|
||||
int count;
|
||||
ar_headers_t *head, *entry;
|
||||
char ar_magic[8];
|
||||
char *long_name=NULL;
|
||||
|
||||
/* check end of header marker is valid */
|
||||
if ((rawHeader->ar_fmag[0]!='`') || (rawHeader->ar_fmag[1]!='\n'))
|
||||
return(FALSE);
|
||||
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\n");
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0)
|
||||
error_msg_and_die("invalid magic\n");
|
||||
|
||||
/* convert filename */
|
||||
for (count = 0; count < 16; count++) {
|
||||
/* allow spaces in filename except at the end */
|
||||
if (rawHeader->ar_name[count] == ' ') {
|
||||
for (count2 = count; count2 < 16; count2++)
|
||||
if (!isspace(rawHeader->ar_name[count2]))
|
||||
break;
|
||||
if (count2 >= 16)
|
||||
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[1];
|
||||
if (raw_ar_header.fmag[1]!='`') {
|
||||
break;
|
||||
}
|
||||
/* GNU ar uses '/' as an end of filename marker */
|
||||
if (rawHeader->ar_name[count] == '/')
|
||||
break;
|
||||
header->name[count] = rawHeader->ar_name[count];
|
||||
}
|
||||
header->name[count] = '\0';
|
||||
header->date = atoi(rawHeader->ar_date);
|
||||
header->uid = atoi(rawHeader->ar_uid);
|
||||
header->gid = atoi(rawHeader->ar_gid);
|
||||
header->mode = getOctal(rawHeader->ar_mode, sizeof(rawHeader->ar_mode));
|
||||
header->size = atoi(rawHeader->ar_size);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy size bytes from current position if srcFd to current position in dstFd
|
||||
* taken from tarExtractRegularFile in tar.c, remove later
|
||||
*/
|
||||
static int copySubFile(int srcFd, int dstFd, int copySize)
|
||||
{
|
||||
int readSize, writeSize, doneSize;
|
||||
char buffer[BUFSIZ];
|
||||
|
||||
while (copySize > 0) {
|
||||
if (copySize > BUFSIZ)
|
||||
readSize = BUFSIZ;
|
||||
else
|
||||
readSize = copySize;
|
||||
writeSize = fullRead(srcFd, buffer, readSize);
|
||||
if (writeSize <= 0) {
|
||||
errorMsg(io_error, "copySubFile :", strerror(errno));
|
||||
return (FALSE);
|
||||
}
|
||||
doneSize = fullWrite(dstFd, buffer, writeSize);
|
||||
if (doneSize <= 0) {
|
||||
errorMsg(io_error, "copySubFile :", strerror(errno));
|
||||
return (FALSE);
|
||||
}
|
||||
copySize -= doneSize;
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract the file described in ArInfo to the specified path
|
||||
* set the new files uid, gid and mode
|
||||
*/
|
||||
static int extractToFile(struct ArInfo *file, int funct, int srcFd, const char *path)
|
||||
{
|
||||
int dstFd, temp;
|
||||
struct stat tmpStat;
|
||||
char *pathname = NULL;
|
||||
struct utimbuf newtime;
|
||||
|
||||
if ((temp = isDirectory(path, TRUE, &tmpStat)) != TRUE) {
|
||||
if (!createPath(path, 0777)) {
|
||||
fatalError("Cannot extract to specified path");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
temp = (strlen(path) + 16);
|
||||
pathname = (char *) xmalloc(temp);
|
||||
pathname = strcpy(pathname, path);
|
||||
pathname = strcat(pathname, file->name);
|
||||
dstFd = device_open(pathname, O_WRONLY | O_CREAT);
|
||||
temp = copySubFile(srcFd, dstFd, file->size);
|
||||
fchown(dstFd, file->uid, file->gid);
|
||||
fchmod(dstFd, file->mode);
|
||||
close(dstFd);
|
||||
if ((funct&AR_PRESERVE_DATE)==AR_PRESERVE_DATE)
|
||||
newtime.modtime=file->date;
|
||||
else
|
||||
newtime.modtime=time(0);
|
||||
newtime.actime=time(0);
|
||||
temp = utime(pathname, &newtime);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a file descriptor for the specified file and do error checks
|
||||
*/
|
||||
static int getArFd(char *filename)
|
||||
{
|
||||
int arFd;
|
||||
char arVersion[8];
|
||||
|
||||
arFd = open(filename, O_RDONLY);
|
||||
if (arFd < 0) {
|
||||
errorMsg("Error opening '%s': %s\n", filename, strerror(errno));
|
||||
return (FALSE);
|
||||
}
|
||||
if (fullRead(arFd, arVersion, 8) <= 0) {
|
||||
errorMsg( "ar: Unexpected EOF in archive\n");
|
||||
return (FALSE);
|
||||
}
|
||||
if (strncmp(arVersion,"!<arch>",7) != 0) {
|
||||
errorMsg("ar header fails check ");
|
||||
return(FALSE);
|
||||
}
|
||||
return arFd;
|
||||
}
|
||||
|
||||
/*
|
||||
* Step through the ar file and process it one entry at a time
|
||||
* fileList[0] is the name of the ar archive
|
||||
* fileList[1] and up are filenames to extract from the archive
|
||||
* funct contains flags to specify the actions to be performed
|
||||
*/
|
||||
static int readArFile(char *fileList[16], int fileListSize, int funct)
|
||||
{
|
||||
int arFd, status, extFileFlag, i, lastOffset=0;
|
||||
ArHeader rawArHeader;
|
||||
ArInfo arEntry;
|
||||
|
||||
/* open the ar archive */
|
||||
arFd=getArFd(fileList[0]);
|
||||
|
||||
/* read the first header, then loop until ono more headers */
|
||||
while ((status = fullRead(arFd, (char *) &rawArHeader, AR_BLOCK_SIZE))
|
||||
== AR_BLOCK_SIZE) {
|
||||
|
||||
/* check the header is valid, if not try reading the header
|
||||
agian with an offset of 1, needed as some ar archive end
|
||||
with a '\n' which isnt counted in specified file size */
|
||||
if ((status=processArHeader(&rawArHeader, &arEntry))==FALSE ) {
|
||||
if ((i=lseek(arFd, 0, SEEK_CUR))==(lastOffset+60))
|
||||
lseek(arFd, lastOffset+1, SEEK_SET);
|
||||
else
|
||||
return(FALSE);
|
||||
}
|
||||
else {
|
||||
extFileFlag=0;
|
||||
|
||||
if (funct&AR_DISPLAY)
|
||||
displayEntry(&arEntry, funct);
|
||||
|
||||
/* check file was specified to be extracted only if
|
||||
some file were specified */
|
||||
if ((funct&AR_EXT_TO_FILE) || (funct&AR_EXT_TO_STDOUT)){
|
||||
if (fileListSize==1)
|
||||
extFileFlag=1;
|
||||
else {
|
||||
for( i=1; i<=fileListSize; i++)
|
||||
if ((status=(strcmp(fileList[i],arEntry.name)))==0)
|
||||
extFileFlag=1;
|
||||
}
|
||||
}
|
||||
if (extFileFlag==1) {
|
||||
if (funct&AR_EXT_TO_FILE)
|
||||
extractToFile(&arEntry, funct, arFd, "./");
|
||||
else
|
||||
copySubFile(arFd,fileno(stdout),arEntry.size);
|
||||
}
|
||||
else
|
||||
lseek(arFd, arEntry.size, SEEK_CUR);
|
||||
lastOffset=lseek(arFd, 0, SEEK_CUR);
|
||||
} /* if processArHeader */
|
||||
} /* while */
|
||||
return (TRUE);
|
||||
/* some version of ar, have an extra '\n' after each entry */
|
||||
read(srcFd, newline, 1);
|
||||
if (newline[0]!='\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)
|
||||
{
|
||||
int funct = 0, ret=0, i=0;
|
||||
char *fileList[16], c, *opt_ptr;
|
||||
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 */
|
||||
|
||||
if (argc < 2)
|
||||
usage(ar_usage);
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
|
||||
opt_ptr = argv[1];
|
||||
if (*opt_ptr == '-')
|
||||
++opt_ptr;
|
||||
while ((c = *opt_ptr++) != '\0') {
|
||||
switch (c) {
|
||||
case 'o': /* preserver original dates */
|
||||
funct = funct | 1;
|
||||
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 'p': /* extract to stdout */
|
||||
funct = funct | 16;
|
||||
case 'v':
|
||||
funct |= verbose;
|
||||
break;
|
||||
case 't': /* display contents */
|
||||
funct = funct | 4;
|
||||
case 't':
|
||||
funct |= display;
|
||||
break;
|
||||
case 'x': /* extract contents of archive */
|
||||
funct = funct | 8;
|
||||
case 'p':
|
||||
funct |= extract_to_stdout;
|
||||
break;
|
||||
case 'v': /* be verbose */
|
||||
funct = funct | 2;
|
||||
case 'x':
|
||||
funct |= extract_to_file;
|
||||
break;
|
||||
default:
|
||||
usage(ar_usage);
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
usage(ar_usage);
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s\n", argv[optind]);
|
||||
|
||||
for(i=0; i<(argc-2); i++)
|
||||
fileList[i]=argv[i+2];
|
||||
optind++;
|
||||
head = get_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;
|
||||
}
|
||||
|
||||
if (funct > 3)
|
||||
ret = readArFile(fileList, (argc-2), funct);
|
||||
|
||||
return (ret);
|
||||
/* 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;
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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 <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_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);
|
||||
|
||||
extern int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
const int dpkg_deb_contents = 1;
|
||||
const int dpkg_deb_control = 2;
|
||||
// const int dpkg_deb_info = 4;
|
||||
const int dpkg_deb_extract = 8;
|
||||
const int dpkg_deb_verbose_extract = 16;
|
||||
int opt=0;
|
||||
int optflag=0;
|
||||
int extract_flag = FALSE;
|
||||
int list_flag = FALSE;
|
||||
int verbose_flag = FALSE;
|
||||
int extract_to_stdout = FALSE;
|
||||
char ar_filename[15];
|
||||
int srcFd=0;
|
||||
int status=0;
|
||||
ar_headers_t *ar_headers = NULL;
|
||||
char **extract_list=NULL;
|
||||
char *target_dir=NULL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "cexX")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
optflag |= dpkg_deb_contents;
|
||||
break;
|
||||
case 'e':
|
||||
optflag |= dpkg_deb_control;
|
||||
break;
|
||||
/* case 'I':
|
||||
optflag |= dpkg_deb_info;
|
||||
break;
|
||||
*/
|
||||
case 'x':
|
||||
optflag |= dpkg_deb_extract;
|
||||
break;
|
||||
case 'X':
|
||||
optflag |= dpkg_deb_verbose_extract;
|
||||
break;
|
||||
default:
|
||||
usage(dpkg_deb_usage);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (((optind + 1 ) > argc) || (optflag == 0)) {
|
||||
usage(dpkg_deb_usage);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (optflag & dpkg_deb_contents) {
|
||||
list_flag = TRUE;
|
||||
verbose_flag = TRUE;
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
}
|
||||
else if (optflag & dpkg_deb_control) {
|
||||
extract_flag = TRUE;
|
||||
strcpy(ar_filename, "control.tar.gz");
|
||||
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]);
|
||||
}
|
||||
}
|
||||
/* 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]);
|
||||
}
|
||||
*/
|
||||
else if (optflag & dpkg_deb_extract) {
|
||||
extract_flag = TRUE;
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
if ( (optind + 2) > argc ) {
|
||||
error_msg_and_die("No directory specified\n");
|
||||
}
|
||||
target_dir = (char *) xmalloc(strlen(argv[optind+1]));
|
||||
strcpy(target_dir, argv[optind+1]);
|
||||
}
|
||||
else if (optflag & dpkg_deb_verbose_extract) {
|
||||
extract_flag = TRUE;
|
||||
list_flag = TRUE;
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
if ( (optind + 2) > argc ) {
|
||||
error_msg_and_die("No directory specified\n");
|
||||
}
|
||||
target_dir = (char *) xmalloc(strlen(argv[optind+1]));
|
||||
strcpy(target_dir, argv[optind+1]);
|
||||
}
|
||||
|
||||
ar_headers = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
srcFd = open(argv[optind], O_RDONLY);
|
||||
|
||||
*ar_headers = get_headers(srcFd);
|
||||
if (ar_headers->next==NULL)
|
||||
error_msg_and_die("Couldnt find %s in %s\n",ar_filename, argv[optind]);
|
||||
|
||||
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 ( target_dir != NULL) {
|
||||
if (is_directory(target_dir, TRUE, NULL)==FALSE) {
|
||||
mkdir(target_dir, 0755);
|
||||
}
|
||||
if (chdir(target_dir)==-1) {
|
||||
error_msg_and_die("Cannot change to dir %s\n",argv[optind+1]);
|
||||
}
|
||||
}
|
||||
status = readTarFile(srcFd, extract_flag, list_flag, extract_to_stdout, verbose_flag, NULL, extract_list);
|
||||
close (srcFd);
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
+696
-1533
File diff suppressed because it is too large.
Load diff
+66
-70
@@ -29,7 +29,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
@@ -40,24 +40,12 @@
|
||||
#define SMALL_MEM
|
||||
#define DYN_ALLOC
|
||||
|
||||
|
||||
static const char gzip_usage[] =
|
||||
"gzip [OPTION]... FILE\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCompress FILE with maximum compression.\n"
|
||||
"When FILE is '-', reads standard input. Implies -c.\n\n"
|
||||
|
||||
"Options:\n"
|
||||
"\t-c\tWrite output to standard output instead of FILE.gz\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
/* I don't like nested includes, but the string and io functions are used
|
||||
* too often
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#define memzero(s, n) memset ((void *)(s), 0, (n))
|
||||
|
||||
#ifndef RETSIGTYPE
|
||||
@@ -127,7 +115,7 @@ extern int method; /* compression method */
|
||||
# define DECLARE(type, array, size) type * array
|
||||
# define ALLOC(type, array, size) { \
|
||||
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
|
||||
if (array == NULL) errorMsg(memory_exhausted, "gzip"); \
|
||||
if (array == NULL) error_msg(memory_exhausted); \
|
||||
}
|
||||
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
|
||||
#else
|
||||
@@ -264,7 +252,7 @@ extern int save_orig_name; /* set if original name must be saved */
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef DEBUG
|
||||
# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);}
|
||||
# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
|
||||
# define Trace(x) fprintf x
|
||||
# define Tracev(x) {if (verbose) fprintf x ;}
|
||||
# define Tracevv(x) {if (verbose>1) fprintf x ;}
|
||||
@@ -1394,7 +1382,7 @@ int length;
|
||||
(char *) window + start, length) != EQUAL) {
|
||||
fprintf(stderr,
|
||||
" start %d, match %d, length %d\n", start, match, length);
|
||||
errorMsg("invalid match");
|
||||
error_msg("invalid match\n");
|
||||
}
|
||||
if (verbose > 1) {
|
||||
fprintf(stderr, "\\[%d,%d]", start - match, length);
|
||||
@@ -1622,7 +1610,6 @@ ulg deflate()
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* configuration */
|
||||
@@ -1768,34 +1755,23 @@ DECLARE(ush, tab_prefix1, 1L << (BITS - 1));
|
||||
|
||||
/* local variables */
|
||||
|
||||
int ascii = 0; /* convert end-of-lines to local OS conventions */
|
||||
int decompress = 0; /* decompress (-d) */
|
||||
int no_name = -1; /* don't save or restore the original file name */
|
||||
int no_time = -1; /* don't save or restore the original file time */
|
||||
int foreground; /* set if program run in foreground */
|
||||
char *progname; /* program name */
|
||||
static int foreground; /* set if program run in foreground */
|
||||
static int method = DEFLATED; /* compression method */
|
||||
static int exit_code = OK; /* program exit code */
|
||||
int save_orig_name; /* set if original name must be saved */
|
||||
int last_member; /* set for .zip and .Z files */
|
||||
int part_nb; /* number of parts in .gz file */
|
||||
long time_stamp; /* original time stamp (modification time) */
|
||||
long ifile_size; /* input file size, -1 for devices (debug only) */
|
||||
char *env; /* contents of GZIP env variable */
|
||||
char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
|
||||
int z_len; /* strlen(z_suffix) */
|
||||
static int part_nb; /* number of parts in .gz file */
|
||||
static long time_stamp; /* original time stamp (modification time) */
|
||||
static long ifile_size; /* input file size, -1 for devices (debug only) */
|
||||
static char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
|
||||
static int z_len; /* strlen(z_suffix) */
|
||||
|
||||
long bytes_in; /* number of input bytes */
|
||||
long bytes_out; /* number of output bytes */
|
||||
char ifname[MAX_PATH_LEN]; /* input file name */
|
||||
char ofname[MAX_PATH_LEN]; /* output file name */
|
||||
int remove_ofname = 0; /* remove output file on error */
|
||||
struct stat istat; /* status for input file */
|
||||
int ifd; /* input file descriptor */
|
||||
int ofd; /* output file descriptor */
|
||||
unsigned insize; /* valid bytes in inbuf */
|
||||
unsigned inptr; /* index of next byte to be processed in inbuf */
|
||||
unsigned outcnt; /* bytes in output buffer */
|
||||
static long bytes_in; /* number of input bytes */
|
||||
static long bytes_out; /* number of output bytes */
|
||||
static char ifname[MAX_PATH_LEN]; /* input file name */
|
||||
static char ofname[MAX_PATH_LEN]; /* output file name */
|
||||
static int ifd; /* input file descriptor */
|
||||
static int ofd; /* output file descriptor */
|
||||
static unsigned insize; /* valid bytes in inbuf */
|
||||
static unsigned outcnt; /* bytes in output buffer */
|
||||
|
||||
/* local functions */
|
||||
|
||||
@@ -1814,14 +1790,11 @@ int gzip_main(int argc, char **argv)
|
||||
char *delFileName;
|
||||
int tostdout = 0;
|
||||
int fromstdin = 0;
|
||||
|
||||
if (argc == 1)
|
||||
usage(gzip_usage);
|
||||
int force = 0;
|
||||
|
||||
/* Parse any options */
|
||||
while (--argc > 0 && **(++argv) == '-') {
|
||||
if (*((*argv) + 1) == '\0') {
|
||||
fromstdin = 1;
|
||||
tostdout = 1;
|
||||
}
|
||||
while (*(++(*argv))) {
|
||||
@@ -1829,11 +1802,29 @@ int gzip_main(int argc, char **argv)
|
||||
case 'c':
|
||||
tostdout = 1;
|
||||
break;
|
||||
case 'f':
|
||||
force = 1;
|
||||
break;
|
||||
/* Ignore 1-9 (compression level) options */
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
break;
|
||||
case 'd':
|
||||
exit(gunzip_main(argc, argv));
|
||||
default:
|
||||
usage(gzip_usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argc <= 0 ) {
|
||||
fromstdin = 1;
|
||||
tostdout = 1;
|
||||
}
|
||||
|
||||
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
|
||||
error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
|
||||
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
|
||||
error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
|
||||
|
||||
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
|
||||
if (foreground) {
|
||||
@@ -1873,22 +1864,17 @@ int gzip_main(int argc, char **argv)
|
||||
ifile_size = -1L; /* convention for unknown size */
|
||||
} else {
|
||||
/* Open up the input file */
|
||||
if (*argv == '\0')
|
||||
if (argc <= 0)
|
||||
usage(gzip_usage);
|
||||
strncpy(ifname, *argv, MAX_PATH_LEN);
|
||||
|
||||
/* Open input fille */
|
||||
/* Open input file */
|
||||
inFileNum = open(ifname, O_RDONLY);
|
||||
if (inFileNum < 0) {
|
||||
perror(ifname);
|
||||
exit(WARNING);
|
||||
}
|
||||
if (inFileNum < 0)
|
||||
perror_msg_and_die("%s", ifname);
|
||||
/* Get the time stamp on the input file. */
|
||||
result = stat(ifname, &statBuf);
|
||||
if (result < 0) {
|
||||
perror(ifname);
|
||||
exit(WARNING);
|
||||
}
|
||||
if (stat(ifname, &statBuf) < 0)
|
||||
perror_msg_and_die("%s", ifname);
|
||||
time_stamp = statBuf.st_ctime;
|
||||
ifile_size = statBuf.st_size;
|
||||
}
|
||||
@@ -1919,10 +1905,8 @@ int gzip_main(int argc, char **argv)
|
||||
#else
|
||||
outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL);
|
||||
#endif
|
||||
if (outFileNum < 0) {
|
||||
perror(ofname);
|
||||
exit(WARNING);
|
||||
}
|
||||
if (outFileNum < 0)
|
||||
perror_msg_and_die("%s", ofname);
|
||||
SET_BINARY_MODE(outFileNum);
|
||||
/* Set permissions on the file */
|
||||
fchmod(outFileNum, statBuf.st_mode);
|
||||
@@ -1940,10 +1924,8 @@ int gzip_main(int argc, char **argv)
|
||||
else
|
||||
delFileName = ofname;
|
||||
|
||||
if (unlink(delFileName) < 0) {
|
||||
perror(delFileName);
|
||||
exit(FALSE);
|
||||
}
|
||||
if (unlink(delFileName) < 0)
|
||||
perror_msg_and_die("%s", delFileName);
|
||||
}
|
||||
|
||||
return(exit_code);
|
||||
@@ -2912,7 +2894,7 @@ int eof; /* true if this is the last block for a file */
|
||||
#endif
|
||||
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
|
||||
if (buf == (char *) 0)
|
||||
errorMsg("block vanished");
|
||||
error_msg("block vanished\n");
|
||||
|
||||
copy_block(buf, (unsigned) stored_len, 0); /* without header */
|
||||
compressed_len = stored_len << 3;
|
||||
@@ -3095,7 +3077,7 @@ local void set_file_type()
|
||||
bin_freq += dyn_ltree[n++].Freq;
|
||||
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
|
||||
if (*file_type == BINARY && translate_eol) {
|
||||
errorMsg("-l used on binary file");
|
||||
error_msg("-l used on binary file\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3251,13 +3233,13 @@ char *env; /* name of environment variable */
|
||||
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
|
||||
|
||||
if (nargv == NULL)
|
||||
errorMsg(memory_exhausted, "gzip");
|
||||
error_msg(memory_exhausted);
|
||||
oargv = *argvp;
|
||||
*argvp = nargv;
|
||||
|
||||
/* Copy the program name first */
|
||||
if (oargc-- < 0)
|
||||
errorMsg("argc<=0");
|
||||
error_msg("argc<=0\n");
|
||||
*(nargv++) = *(oargv++);
|
||||
|
||||
/* Then copy the environment args */
|
||||
@@ -3392,3 +3374,17 @@ unsigned size;
|
||||
isize += (ulg) len;
|
||||
return (int) len;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Write the output buffer outbuf[0..outcnt-1] and update bytes_out.
|
||||
* (used for the compressed data only)
|
||||
*/
|
||||
void flush_outbuf()
|
||||
{
|
||||
if (outcnt == 0)
|
||||
return;
|
||||
|
||||
write_buf(ofd, (char *) outbuf, outcnt);
|
||||
bytes_out += (ulg) outcnt;
|
||||
outcnt = 0;
|
||||
}
|
||||
+501
-297
File diff suppressed because it is too large.
Load diff
+7
-22
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,21 +21,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char *basename_usage="basename FILE [SUFFIX]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nStrips directory path and suffixes from FILE.\n"
|
||||
"If specified, also removes any trailing SUFFIX.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
int m, n;
|
||||
char *s, *s1;
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(basename_usage);
|
||||
@@ -43,14 +36,7 @@ extern int basename_main(int argc, char **argv)
|
||||
|
||||
argv++;
|
||||
|
||||
s1=*argv+strlen(*argv)-1;
|
||||
while (s1 && *s1 == '/') {
|
||||
*s1 = '\0';
|
||||
s1--;
|
||||
}
|
||||
s = strrchr(*argv, '/');
|
||||
if (s==NULL) s=*argv;
|
||||
else s++;
|
||||
s = get_last_path_component(*argv);
|
||||
|
||||
if (argc>2) {
|
||||
argv++;
|
||||
@@ -60,6 +46,5 @@ extern int basename_main(int argc, char **argv)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,405 +1,170 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.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;
|
||||
|
||||
/* It has been alledged that doing such things can
|
||||
* help reduce binary size when staticly linking,
|
||||
* of course with glibc, this is unlikely as long
|
||||
* as we use things like printf -- perhaps a printf
|
||||
* replacement may be in order
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
#if 0
|
||||
void exit(int status) __attribute__ ((noreturn));
|
||||
void exit(int status)
|
||||
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()
|
||||
{
|
||||
_exit(status);
|
||||
};
|
||||
void abort(void) __attribute__ ((__noreturn__));
|
||||
void abort(void)
|
||||
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)
|
||||
{
|
||||
_exit(0);
|
||||
};
|
||||
int atexit(void (*__func) (void))
|
||||
{
|
||||
_exit(0);
|
||||
};
|
||||
void *__libc_stack_end;
|
||||
#endif
|
||||
__link_f Link = link;
|
||||
|
||||
const struct BB_applet applets[] = {
|
||||
char command[256];
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
#ifdef BB_AR
|
||||
{"ar", ar_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
{"basename", basename_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
{"busybox", busybox_main, _BB_DIR_BIN},
|
||||
#ifdef BB_BLOCK_DEVICE
|
||||
{"block_device", block_device_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_CAT
|
||||
{"cat", cat_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
{"chroot", chroot_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
{"clear", clear_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
{"chvt", chvt_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
{"cp", cp_mv_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
{"cut", cut_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
{"date", date_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
{"dc", dc_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
{"dd", dd_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
{"df", df_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
{"dirname", dirname_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
{"dmesg", dmesg_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
{"du", du_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
{"echo", echo_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
{"false", false_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
{"fbset", fbset_main, _BB_DIR_USR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
{"fdflush", fdflush_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
{"find", find_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
{"free", free_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
{"grep", grep_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
{"gunzip", gunzip_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
{"gzip", gzip_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
{"halt", halt_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
{"head", head_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
{"hostid", hostid_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
{"hostname", hostname_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
{"id", id_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
{"init", init_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
{"insmod", insmod_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
{"kill", kill_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
{"killall", kill_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
{"length", length_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LINUXRC
|
||||
{"linuxrc", init_main, _BB_DIR_ROOT},
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
{"ln", ln_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
{"loadacm", loadacm_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
{"loadfont", loadfont_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
{"loadkmap", loadkmap_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
{"logger", logger_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
{"logname", logname_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
{"ls", ls_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
{"lsmod", lsmod_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
{"makedevs", makedevs_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
{"md5sum", md5sum_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
{"mkdir", mkdir_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
{"mknod", mknod_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
{"mkswap", mkswap_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
{"mktemp", mktemp_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
{"nc", nc_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
{"more", more_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
{"mount", mount_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
{"mt", mt_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
{"mv", cp_mv_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
{"nslookup", nslookup_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
{"ping", ping_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
{"poweroff", poweroff_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
{"printf", printf_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
{"ps", ps_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
{"pwd", pwd_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
{"reboot", reboot_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
{"rm", rm_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
{"rmdir", rmdir_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
{"rmmod", rmmod_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
{"sed", sed_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SFDISK
|
||||
{"sfdisk", sfdisk_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
{"sh", shell_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
{"sleep", sleep_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
{"sort", sort_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
{"sync", sync_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
{"syslogd", syslogd_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
{"swapon", swap_on_off_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
{"swapoff", swap_on_off_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
{"tail", tail_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
{"tar", tar_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
{"telnet", telnet_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
{"test", test_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
{"tee", tee_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
{"touch", touch_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
{"tr", tr_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
{"true", true_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
{"tty", tty_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
{"umount", umount_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
{"uname", uname_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
{"uniq", uniq_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
{"update", update_main, _BB_DIR_SBIN},
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
{"uptime", uptime_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
{"uuencode", uuencode_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
{"uudecode", uudecode_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
{"usleep", usleep_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
{"wc", wc_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
{"which", which_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
{"whoami", whoami_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
{"yes", yes_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
{"zcat", gunzip_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
{"[", test_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
{0}
|
||||
};
|
||||
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)
|
||||
{
|
||||
char *s;
|
||||
char *name;
|
||||
const struct BB_applet *a = applets;
|
||||
struct BB_applet search_applet, *applet;
|
||||
const char *s;
|
||||
|
||||
for (s = name = argv[0]; *s != '\0';) {
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
name = s;
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
*argv = name;
|
||||
|
||||
while (a->name != 0) {
|
||||
if (strcmp(name, a->name) == 0) {
|
||||
exit(((*(a->main)) (argc, argv)));
|
||||
}
|
||||
a++;
|
||||
#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)));
|
||||
}
|
||||
return(busybox_main(argc, argv));
|
||||
#endif
|
||||
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
search_applet.name = applet_name;
|
||||
applet = bsearch(&search_applet, applets, NUM_APPLETS,
|
||||
sizeof(struct BB_applet), applet_name_compare);
|
||||
if (applet != NULL) {
|
||||
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(applet->usage);
|
||||
exit((*(applet->main)) (argc, argv));
|
||||
}
|
||||
|
||||
error_msg_and_die("applet not found\n");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0;
|
||||
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--;
|
||||
argv++;
|
||||
|
||||
/* 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, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n"
|
||||
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", BB_VER, BB_BT);
|
||||
"\nCurrently defined functions:\n", full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
@@ -413,8 +178,21 @@ int busybox_main(int argc, char **argv)
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
}
|
||||
/* If we've already been here once, exit now */
|
||||
|
||||
/* 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));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/* 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
|
||||
|
||||
/* 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;
|
||||
const char* usage;
|
||||
};
|
||||
/* 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 int applet_name_compare(const void *x, const void *y);
|
||||
|
||||
extern void usage(const char *usage) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
|
||||
const char *mode_string(int mode);
|
||||
const char *time_string(time_t timeVal);
|
||||
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
|
||||
int isDevice(const char *name);
|
||||
|
||||
typedef struct ino_dev_hash_bucket_struct {
|
||||
struct ino_dev_hash_bucket_struct *next;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
char name[1];
|
||||
} ino_dev_hashtable_bucket_t;
|
||||
int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
|
||||
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
|
||||
void reset_ino_dev_hashtable(void);
|
||||
|
||||
int copy_file(const char *srcName, const char *destName,
|
||||
int setModes, int followLinks, int forceFlag);
|
||||
int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
|
||||
char *buildName(const char *dirName, const char *fileName);
|
||||
int makeString(int argc, const char **argv, char *buf, int bufLen);
|
||||
char *getChunk(int size);
|
||||
char *chunkstrdup(const char *str);
|
||||
void freeChunks(void);
|
||||
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);
|
||||
|
||||
#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);
|
||||
|
||||
struct suffix_mult {
|
||||
char *suffix;
|
||||
int mult;
|
||||
};
|
||||
|
||||
extern unsigned long parse_number(const char *numstr, 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(char *name);
|
||||
extern long my_getgrnam(char *name);
|
||||
extern void my_getpwuid(char *name, long uid);
|
||||
extern void my_getgrgid(char *group, long gid);
|
||||
extern long my_getpwnamegid(char *name);
|
||||
|
||||
extern int device_open(char *device, int mode);
|
||||
|
||||
#if defined BB_FEATURE_MOUNT_LOOP
|
||||
extern int del_loop(const char *device);
|
||||
extern int set_loop(const char *device, const char *file, int offset, int *loopro);
|
||||
extern char *find_unused_loop_device (void);
|
||||
#endif
|
||||
|
||||
|
||||
#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
|
||||
extern int vdprintf(int d, const char *format, va_list ap);
|
||||
#endif
|
||||
|
||||
#if defined BB_NFSMOUNT
|
||||
int nfsmount(const char *spec, const char *node, int *flags,
|
||||
char **extra_opts, char **mount_opts, int running_bg);
|
||||
#endif
|
||||
|
||||
#ifndef RB_POWER_OFF
|
||||
/* Stop system and switch power off if possible. */
|
||||
#define RB_POWER_OFF 0x4321fedc
|
||||
#endif
|
||||
|
||||
/* Include our own copy of struct sysinfo to avoid binary compatability
|
||||
* problems with Linux 2.4, which changed things. Grumble, grumble. */
|
||||
struct sysinfo {
|
||||
long uptime; /* Seconds since boot */
|
||||
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
unsigned long totalram; /* Total usable main memory size */
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long totalswap; /* Total swap space size */
|
||||
unsigned long freeswap; /* swap space still available */
|
||||
unsigned short procs; /* Number of current processes */
|
||||
unsigned long totalhigh; /* Total high memory size */
|
||||
unsigned long freehigh; /* Available high memory size */
|
||||
unsigned int mem_unit; /* Memory unit size in bytes */
|
||||
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
|
||||
};
|
||||
extern int sysinfo (struct sysinfo* info);
|
||||
|
||||
/* Bit map related macros -- libc5 doens't provide these... sigh. */
|
||||
#ifndef setbit
|
||||
#define NBBY CHAR_BIT
|
||||
#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
|
||||
char *format(unsigned long val, unsigned long hr);
|
||||
#define KILOBYTE 1024
|
||||
#define MEGABYTE (KILOBYTE*1024)
|
||||
#define GIGABYTE (MEGABYTE*1024)
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#endif /* _BB_INTERNAL_H_ */
|
||||
+16
-14
@@ -1,19 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
DF="busybox.def.h"
|
||||
MF="busybox.c"
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
for def in ${LIST}; do
|
||||
i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
|
||||
for j in $i; do
|
||||
if [ -z $j ] ; then
|
||||
continue;
|
||||
fi;
|
||||
echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
|
||||
-e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
|
||||
-e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
|
||||
done;
|
||||
done
|
||||
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
|
||||
}'
|
||||
+8
-5
@@ -1,10 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
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:-.}
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 ` \
|
||||
gcc -E -dM busybox.def.h | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr [:upper:] [:lower:] | sort
|
||||
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
Name: busybox
|
||||
Version: 0.45
|
||||
Version: 0.49
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,47 +21,26 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
static void print_file(FILE * file)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = getc(file)) != EOF)
|
||||
putc(c, stdout);
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
}
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
FILE *file;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
exit(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
if (**(argv + 1) == '-') {
|
||||
usage("cat [FILE ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nConcatenates FILE(s) and prints them to the standard output.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
argc--;
|
||||
|
||||
while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) {
|
||||
file = fopen(*argv, "r");
|
||||
if (file == NULL) {
|
||||
perror(*argv);
|
||||
exit(FALSE);
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
print_file(file);
|
||||
}
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+26
-48
@@ -3,7 +3,7 @@
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,21 +22,21 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_option
|
||||
#define bb_need_too_few_args
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static unsigned long uid = -1;
|
||||
static unsigned long gid = -1;
|
||||
static long uid = -1;
|
||||
static long gid = -1;
|
||||
static int whichApp;
|
||||
static char *invocationName = NULL;
|
||||
static char *theMode = NULL;
|
||||
|
||||
|
||||
@@ -44,29 +44,6 @@ static char *theMode = NULL;
|
||||
#define CHOWN_APP 2
|
||||
#define CHMOD_APP 3
|
||||
|
||||
static const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChange the group membership of each FILE to GROUP.\n"
|
||||
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
|
||||
#endif
|
||||
;
|
||||
static const char chown_usage[] =
|
||||
"chown [OPTION]... OWNER[<.|:>[GROUP] FILE...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChange the owner and/or group of each FILE to OWNER and/or GROUP.\n"
|
||||
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
|
||||
#endif
|
||||
;
|
||||
static const char chmod_usage[] =
|
||||
"chmod [-R] MODE[,MODE]... FILE...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nEach MODE is one or more of the letters ugoa, one of the symbols +-= and\n"
|
||||
"one or more of the letters rwxst.\n\n"
|
||||
"\nOptions:\n\t-R\tChanges files and directories recursively.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
switch (whichApp) {
|
||||
@@ -88,7 +65,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
case CHMOD_APP:
|
||||
/* Parse the specified modes */
|
||||
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
|
||||
fatalError( "%s: unknown mode: %s\n", invocationName, theMode);
|
||||
error_msg_and_die( "unknown mode: %s\n", theMode);
|
||||
}
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
@@ -100,13 +77,14 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
{
|
||||
int stopIt = FALSE;
|
||||
int recursiveFlag = FALSE;
|
||||
char *groupName=NULL;
|
||||
char *p=NULL;
|
||||
const char *appUsage;
|
||||
|
||||
whichApp = (strcmp(*argv, "chown") == 0)?
|
||||
CHOWN_APP : (strcmp(*argv, "chmod") == 0)?
|
||||
whichApp = (strcmp(applet_name, "chown") == 0)?
|
||||
CHOWN_APP : (strcmp(applet_name, "chmod") == 0)?
|
||||
CHMOD_APP : CHGRP_APP;
|
||||
|
||||
appUsage = (whichApp == CHOWN_APP)?
|
||||
@@ -114,31 +92,32 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
|
||||
if (argc < 2)
|
||||
usage(appUsage);
|
||||
invocationName = *argv;
|
||||
argv++;
|
||||
|
||||
/* Parse options */
|
||||
while (--argc >= 0 && *argv && (**argv == '-')) {
|
||||
while (*++(*argv)) {
|
||||
while (stopIt==FALSE && *++(*argv)) {
|
||||
switch (**argv) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, invalid_option, invocationName, **argv);
|
||||
usage(appUsage);
|
||||
theMode=*argv-1;
|
||||
stopIt = TRUE;
|
||||
}
|
||||
}
|
||||
if (stopIt==TRUE)
|
||||
break;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (argc == 0 || *argv == NULL) {
|
||||
fprintf(stderr, too_few_args, invocationName);
|
||||
usage(appUsage);
|
||||
error_msg(too_few_args);
|
||||
}
|
||||
|
||||
if (whichApp == CHMOD_APP) {
|
||||
theMode = *argv;
|
||||
if (theMode==NULL)
|
||||
theMode = *argv;
|
||||
} else {
|
||||
|
||||
/* Find the selected group */
|
||||
@@ -171,25 +150,24 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
if (*argv == p)
|
||||
uid = my_getpwnam(*argv);
|
||||
if (uid == -1) {
|
||||
fatalError( "%s: unknown user name: %s\n",
|
||||
invocationName, *argv);
|
||||
error_msg_and_die( "unknown user name: %s\n", *argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
if (argc <= 1) {
|
||||
fatalError( "%s: too few arguments\n", invocationName);
|
||||
if (argc < 1) {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
while (argc-- > 1) {
|
||||
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
|
||||
if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE)
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
bad_group:
|
||||
fatalError( "%s: unknown group name: %s\n", invocationName, groupName);
|
||||
error_msg_and_die( "unknown group name: %s\n", groupName);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,20 +22,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRun COMMAND with root directory set to NEWROOT.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
@@ -47,8 +39,7 @@ int chroot_main(int argc, char **argv)
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
fatalError("chroot: cannot change root directory to %s: %s\n",
|
||||
*argv, strerror(errno));
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
@@ -57,13 +48,17 @@ int chroot_main(int argc, char **argv)
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#ifndef BB_SH
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
shell_main(argc, argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
fatalError("chroot: cannot execute %s: %s\n",
|
||||
prog, strerror(errno));
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,36 +4,30 @@
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/vt.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-')) {
|
||||
usage ("chvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage (chvt_usage);
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
exit(FALSE);
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
exit(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,12 +22,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,37 +1,13 @@
|
||||
#ifndef GETLINE_H
|
||||
#define GETLINE_H
|
||||
#ifndef CMDEDIT_H
|
||||
#define CMDEDIT_H
|
||||
|
||||
/* unix systems can #define POSIX to use termios, otherwise
|
||||
* the bsd or sysv interface will be used
|
||||
*/
|
||||
|
||||
#ifdef __STDC__
|
||||
#ifdef BB_FEATURE_SH_COMMAND_EDITING
|
||||
#include <stddef.h>
|
||||
|
||||
typedef size_t (*cmdedit_strwidth_proc)(char *);
|
||||
|
||||
void cmdedit_init(void);
|
||||
void cmdedit_terminate(void);
|
||||
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
|
||||
void cmdedit_setwidth(int); /* specify width of screen */
|
||||
void cmdedit_histadd(char *); /* adds entries to hist */
|
||||
void cmdedit_strwidth(cmdedit_strwidth_proc); /* to bind cmdedit_strlen */
|
||||
|
||||
extern int (*cmdedit_in_hook)(char *);
|
||||
extern int (*cmdedit_out_hook)(char *);
|
||||
extern int (*cmdedit_tab_hook)(char *, int, int *);
|
||||
#endif /* BB_FEATURE_SH_COMMAND_EDITING */
|
||||
|
||||
#else /* not __STDC__ */
|
||||
|
||||
void cmdedit_init(void);
|
||||
void cmdedit_read_input(char* promptStr, char* command);
|
||||
void cmdedit_setwidth();
|
||||
void cmdedit_histadd();
|
||||
void cmdedit_strwidth();
|
||||
|
||||
extern int (*cmdedit_in_hook)();
|
||||
extern int (*cmdedit_out_hook)();
|
||||
extern int (*cmdedit_tab_hook)();
|
||||
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#endif /* GETLINE_H */
|
||||
#endif /* CMDEDIT_H */
|
||||
@@ -0,0 +1,66 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1 = argv[1], *filename2 = "-";
|
||||
int c1, c2, char_pos = 1, line_pos = 1;
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
usage(cmp_usage);
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
fp2 = xfopen(argv[2], "r");
|
||||
filename2 = argv[2];
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+14
-20
@@ -4,36 +4,30 @@
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/vt.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-')) {
|
||||
usage ("chvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChanges the foreground virtual terminal to /dev/ttyN\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage (chvt_usage);
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
exit(FALSE);
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
exit(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,12 +22,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+17
-29
@@ -3,53 +3,41 @@
|
||||
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
|
||||
* Renamed deallocvt.
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/vt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *progname;
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
int fd, num, i;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-')) {
|
||||
usage
|
||||
("deallocvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDeallocate unused virtual terminal /dev/ttyN\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
progname = argv[0];
|
||||
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
|
||||
if (argc > 2)
|
||||
usage(deallocvt_usage);
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
if (argc == 1) {
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
exit( FALSE);
|
||||
}
|
||||
} else
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
fprintf(stderr, "%s: 0: illegal VT number\n", progname);
|
||||
error_msg("0: illegal VT number\n");
|
||||
else if (num == 1)
|
||||
fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
|
||||
progname);
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
fprintf(stderr, "%s: could not deallocate console %d\n",
|
||||
progname, num);
|
||||
exit( FALSE);
|
||||
}
|
||||
error_msg("VT 1 cannot be deallocated\n");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini dumpkmap implementation for busybox
|
||||
*
|
||||
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
unsigned char kb_table;
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
usage(dumpkmap_usage);
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg("Error opening /dev/tty0");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
write(1, magic, 7);
|
||||
|
||||
for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0;
|
||||
flags[0]=1;
|
||||
flags[1]=1;
|
||||
flags[2]=1;
|
||||
flags[4]=1;
|
||||
flags[5]=1;
|
||||
flags[6]=1;
|
||||
flags[8]=1;
|
||||
flags[9]=1;
|
||||
flags[10]=1;
|
||||
flags[12]=1;
|
||||
|
||||
/* dump flags */
|
||||
for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
|
||||
error_msg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
}
|
||||
else {
|
||||
write(1,(void*)&ke.kb_value,2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+29
-52
@@ -7,7 +7,7 @@
|
||||
* Peter Novodvorsky <petya@logic.ru>
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
@@ -18,16 +18,9 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
|
||||
static const char loadacm_usage[] = "loadacm\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nLoads an acm from standard input.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
typedef unsigned short unicode;
|
||||
|
||||
static long int ctoi(unsigned char *s, int *is_unicode);
|
||||
@@ -46,18 +39,16 @@ int loadacm_main(int argc, char **argv)
|
||||
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno));
|
||||
return( FALSE);
|
||||
perror_msg_and_die("Error opening /dev/tty1");
|
||||
}
|
||||
|
||||
if (screen_map_load(fd, stdin)) {
|
||||
fprintf(stderr, "Error loading acm: %s\n", strerror(errno));
|
||||
return( FALSE);
|
||||
perror_msg_and_die("Error loading acm");
|
||||
}
|
||||
|
||||
write(fd, "\033(K", 3);
|
||||
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int screen_map_load(int fd, FILE * fp)
|
||||
@@ -68,8 +59,8 @@ int screen_map_load(int fd, FILE * fp)
|
||||
int parse_failed = 0;
|
||||
int is_unicode;
|
||||
|
||||
if (fstat(fp->_fileno, &stbuf))
|
||||
perror("Cannot stat map file"), exit(1);
|
||||
if (fstat(fileno(fp), &stbuf))
|
||||
perror_msg_and_die("Cannot stat map file");
|
||||
|
||||
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
|
||||
if (!
|
||||
@@ -79,19 +70,16 @@ int screen_map_load(int fd, FILE * fp)
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
fprintf(stderr,
|
||||
"16bit screen-map MUST be a regular file.\n"),
|
||||
exit(1);
|
||||
error_msg_and_die("16bit screen-map MUST be a regular file.\n");
|
||||
else
|
||||
perror("fseek failed reading binary 16bit screen-map"),
|
||||
exit(1);
|
||||
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
|
||||
perror("Cannot read [new] map from file"), exit(1);
|
||||
perror_msg_and_die("Cannot read [new] map from file");
|
||||
#if 0
|
||||
else
|
||||
fprintf(stderr, "Input screen-map is binary.\n");
|
||||
error_msg("Input screen-map is binary.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -99,7 +87,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
/* same if it was binary, ie. if parse_failed */
|
||||
if (parse_failed || is_unicode) {
|
||||
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
|
||||
perror("PIO_UNISCRNMAP ioctl"), exit(1);
|
||||
perror_msg_and_die("PIO_UNISCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -108,11 +96,10 @@ int screen_map_load(int fd, FILE * fp)
|
||||
/* rewind... */
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
fprintf(stderr,
|
||||
"Assuming 8bit screen-map - MUST be a regular file.\n"),
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
|
||||
exit(1);
|
||||
else
|
||||
perror("fseek failed assuming 8bit screen-map"), exit(1);
|
||||
perror_msg_and_die("fseek failed assuming 8bit screen-map");
|
||||
}
|
||||
|
||||
/* ... and try an old 8-bit screen-map */
|
||||
@@ -122,26 +109,25 @@ int screen_map_load(int fd, FILE * fp)
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
/* should not - it succedeed above */
|
||||
fprintf(stderr, "fseek() returned ESPIPE !\n"),
|
||||
exit(1);
|
||||
error_msg_and_die("fseek() returned ESPIPE !\n");
|
||||
else
|
||||
perror("fseek for binary 8bit screen-map"), exit(1);
|
||||
perror_msg_and_die("fseek for binary 8bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror("Cannot read [old] map from file"), exit(1);
|
||||
perror_msg_and_die("Cannot read [old] map from file");
|
||||
#if 0
|
||||
else
|
||||
fprintf(stderr, "Input screen-map is binary.\n");
|
||||
error_msg("Input screen-map is binary.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ioctl(fd, PIO_SCRNMAP, buf))
|
||||
perror("PIO_SCRNMAP ioctl"), exit(1);
|
||||
perror_msg_and_die("PIO_SCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
fprintf(stderr, "Error parsing symbolic map\n");
|
||||
error_msg("Error parsing symbolic map\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -185,10 +171,8 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
|
||||
if (feof(fp))
|
||||
break;
|
||||
else {
|
||||
perror("uni_screen_map_read_ascii() can't read line");
|
||||
exit(2);
|
||||
}
|
||||
else
|
||||
perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
|
||||
}
|
||||
|
||||
/* get "charset-relative charcode", stripping leading spaces */
|
||||
@@ -328,32 +312,25 @@ void saveoldmap(int fd, char *omfil)
|
||||
int is_old_map = 0;
|
||||
|
||||
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
|
||||
perror("GIO_UNISCRNMAP ioctl error");
|
||||
perror_msg("GIO_UNISCRNMAP ioctl error");
|
||||
#endif
|
||||
if (ioctl(fd, GIO_SCRNMAP, buf)) {
|
||||
perror("GIO_SCRNMAP ioctl error");
|
||||
exit(1);
|
||||
} else
|
||||
if (ioctl(fd, GIO_SCRNMAP, buf))
|
||||
perror_msg_and_die("GIO_SCRNMAP ioctl error");
|
||||
else
|
||||
is_old_map = 1;
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((fp = fopen(omfil, "w")) == NULL) {
|
||||
perror(omfil);
|
||||
exit(1);
|
||||
}
|
||||
fp = xfopen(omfil, "w");
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
if (is_old_map) {
|
||||
#endif
|
||||
if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
|
||||
perror("Error writing map to file");
|
||||
exit(1);
|
||||
}
|
||||
if (fwrite(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Error writing map to file");
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
|
||||
perror("Error writing map to file");
|
||||
exit(1);
|
||||
perror_msg_and_die("Error writing map to file");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+35
-67
@@ -7,7 +7,7 @@
|
||||
* Loads the console font, and possibly the corresponding screen map(s).
|
||||
* (Adapted for busybox by Matej Vela.)
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@@ -15,26 +15,19 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include <endian.h>
|
||||
|
||||
#define PSF_MAGIC1 0x36
|
||||
#define PSF_MAGIC2 0x04
|
||||
static const int PSF_MAGIC1 = 0x36;
|
||||
static const int PSF_MAGIC2 = 0x04;
|
||||
|
||||
#define PSF_MODE512 0x01
|
||||
#define PSF_MODEHASTAB 0x02
|
||||
#define PSF_MAXMODE 0x03
|
||||
#define PSF_SEPARATOR 0xFFFF
|
||||
|
||||
static const char loadfont_usage[] = "loadfont\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"Loads a console font from standard input.\n"
|
||||
#endif
|
||||
;
|
||||
static const int PSF_MODE512 = 0x01;
|
||||
static const int PSF_MODEHASTAB = 0x02;
|
||||
static const int PSF_MAXMODE = 0x03;
|
||||
static const int PSF_SEPARATOR = 0xFFFF;
|
||||
|
||||
struct psf_header {
|
||||
unsigned char magic1, magic2; /* Magic number */
|
||||
@@ -50,18 +43,15 @@ extern int loadfont_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
if (argc != 1)
|
||||
usage(loadfont_usage);
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
loadnewfont(fd);
|
||||
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
@@ -71,10 +61,8 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32) {
|
||||
fprintf(stderr, "Bad character size %d\n", unit);
|
||||
exit(1);
|
||||
}
|
||||
if (unit < 1 || unit > 32)
|
||||
error_msg_and_die("Bad character size %d\n", unit);
|
||||
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
@@ -89,13 +77,11 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
|
||||
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
|
||||
return; /* success */
|
||||
perror("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
}
|
||||
#endif
|
||||
if (ioctl(fd, PIO_FONT, buf)) {
|
||||
perror("PIO_FONT ioctl error");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, PIO_FONT, buf))
|
||||
perror_msg_and_die("PIO_FONT ioctl error");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -109,12 +95,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
u_short unicode;
|
||||
|
||||
maxct = tailsz; /* more than enough */
|
||||
up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
|
||||
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
|
||||
|
||||
if (!up) {
|
||||
fprintf(stderr, "Out of memory?\n");
|
||||
exit(1);
|
||||
}
|
||||
for (glyph = 0; glyph < fontsize; glyph++) {
|
||||
while (tailsz >= 2) {
|
||||
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
|
||||
@@ -137,12 +119,11 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
#ifdef ENOIOCTLCMD
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
|
||||
fprintf(stderr, "No Unicode mapping table loaded.\n");
|
||||
error_msg("It seems this kernel is older than 1.1.92\n");
|
||||
error_msg_and_die("No Unicode mapping table loaded.\n");
|
||||
} else
|
||||
#endif
|
||||
perror("PIO_UNIMAPCLR");
|
||||
exit(1);
|
||||
perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
}
|
||||
ud.entry_ct = ct;
|
||||
ud.entries = up;
|
||||
@@ -152,8 +133,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
/* change advice parameters */
|
||||
}
|
||||
#endif
|
||||
perror("PIO_UNIMAP");
|
||||
exit(1);
|
||||
perror_msg_and_die("PIO_UNIMAP");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +141,7 @@ static void loadnewfont(int fd)
|
||||
{
|
||||
int unit;
|
||||
char inbuf[32768]; /* primitive */
|
||||
int inputlth, offset;
|
||||
unsigned int inputlth, offset;
|
||||
|
||||
/*
|
||||
* We used to look at the length of the input file
|
||||
@@ -169,25 +149,21 @@ static void loadnewfont(int fd)
|
||||
* just read the entire file.
|
||||
*/
|
||||
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
|
||||
if (ferror(stdin)) {
|
||||
perror("Error reading input font");
|
||||
exit(1);
|
||||
}
|
||||
if (ferror(stdin))
|
||||
perror_msg_and_die("Error reading input font");
|
||||
/* use malloc/realloc in case of giant files;
|
||||
maybe these do not occur: 16kB for the font,
|
||||
and 16kB for the map leaves 32 unicode values
|
||||
for each font position */
|
||||
if (!feof(stdin)) {
|
||||
perror("Font too large");
|
||||
exit(1);
|
||||
}
|
||||
if (!feof(stdin))
|
||||
perror_msg_and_die("Font too large");
|
||||
|
||||
/* test for psf first */
|
||||
{
|
||||
struct psf_header psfhdr;
|
||||
int fontsize;
|
||||
int hastable;
|
||||
int head0, head;
|
||||
unsigned int head0, head;
|
||||
|
||||
if (inputlth < sizeof(struct psf_header))
|
||||
goto no_psf;
|
||||
@@ -197,26 +173,20 @@ static void loadnewfont(int fd)
|
||||
if (!PSF_MAGIC_OK(psfhdr))
|
||||
goto no_psf;
|
||||
|
||||
if (psfhdr.mode > PSF_MAXMODE) {
|
||||
fprintf(stderr, "Unsupported psf file mode\n");
|
||||
exit(1);
|
||||
}
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
error_msg_and_die("Unsupported psf file mode\n");
|
||||
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
|
||||
#if !defined( PIO_FONTX ) || defined( __sparc__ )
|
||||
if (fontsize != 256) {
|
||||
fprintf(stderr, "Only fontsize 256 supported\n");
|
||||
exit(1);
|
||||
}
|
||||
if (fontsize != 256)
|
||||
error_msg_and_die("Only fontsize 256 supported\n");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
head0 = sizeof(struct psf_header);
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth)) {
|
||||
fprintf(stderr, "Input file: bad length\n");
|
||||
exit(1);
|
||||
}
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
error_msg_and_die("Input file: bad length\n");
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
@@ -230,10 +200,8 @@ static void loadnewfont(int fd)
|
||||
unit = 16;
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377) {
|
||||
fprintf(stderr, "Bad input file size\n");
|
||||
exit(1);
|
||||
}
|
||||
if (inputlth & 0377)
|
||||
error_msg_and_die("Bad input file size\n");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
|
||||
+27
-36
@@ -20,67 +20,58 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/kd.h>
|
||||
#include <linux/keyboard.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
|
||||
static const char loadkmap_usage[] = "loadkmap\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"Loads a binary keyboard translation table from standard input.\n"
|
||||
#endif
|
||||
;
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
unsigned char kb_table;
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int loadkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
u_short *ibuff;
|
||||
int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short);
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap", buff[7];
|
||||
char flags[MAX_NR_KEYMAPS], buff[7];
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
if (argc != 1)
|
||||
usage(loadkmap_usage);
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
exit(FALSE);
|
||||
}
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
|
||||
read(0, buff, 7);
|
||||
if (0 != strncmp(buff, magic, 7)) {
|
||||
fprintf(stderr, "This is not a valid binary keymap.\n");
|
||||
exit(FALSE);
|
||||
}
|
||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
error_msg_and_die("This is not a valid binary keymap.\n");
|
||||
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) {
|
||||
fprintf(stderr, "Error reading keymap flags: %s\n",
|
||||
strerror(errno));
|
||||
exit(FALSE);
|
||||
}
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
|
||||
perror_msg_and_die("Error reading keymap flags");
|
||||
|
||||
ibuff = (u_short *) malloc(ibuffsz);
|
||||
if (!ibuff) {
|
||||
fprintf(stderr, "Out of memory.\n");
|
||||
exit(FALSE);
|
||||
}
|
||||
ibuff = (u_short *) xmalloc(ibuffsz);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
pos = 0;
|
||||
while (pos < ibuffsz) {
|
||||
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
|
||||
< 0) {
|
||||
fprintf(stderr, "Error reading keymap: %s\n",
|
||||
strerror(errno));
|
||||
exit(FALSE);
|
||||
}
|
||||
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
|
||||
perror_msg_and_die("Error reading keymap");
|
||||
pos += readsz;
|
||||
}
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
@@ -94,5 +85,5 @@ int loadkmap_main(int argc, char **argv)
|
||||
/* Don't bother to close files. Exit does that
|
||||
* automagically, so we can save a few bytes */
|
||||
/* close(fd); */
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* and Kent Robotti <robotti@metconnect.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int reset_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033c");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+11
-15
@@ -22,22 +22,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/kd.h>
|
||||
|
||||
static const char setkeycodes_usage[] =
|
||||
"setkeycodes SCANCODE KEYCODE ...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nSet entries into the kernel's scancode-to-keycode map,\n"
|
||||
"allowing unusual keyboards to generate usable keycodes.\n\n"
|
||||
"SCANCODE may be either xx or e0xx (hexadecimal),\n"
|
||||
"and KEYCODE is given in decimal\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbkeycode {
|
||||
unsigned int scancode, keycode;
|
||||
};
|
||||
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
|
||||
|
||||
extern int
|
||||
setkeycodes_main(int argc, char** argv)
|
||||
@@ -56,21 +52,21 @@ setkeycodes_main(int argc, char** argv)
|
||||
a.keycode = atoi(argv[2]);
|
||||
a.scancode = sc = strtol(argv[1], &ep, 16);
|
||||
if (*ep) {
|
||||
fatalError("error reading SCANCODE: '%s'\n", argv[1]);
|
||||
error_msg_and_die("error reading SCANCODE: '%s'\n", argv[1]);
|
||||
}
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
}
|
||||
if (a.scancode > 255 || a.keycode > 127) {
|
||||
fatalError("SCANCODE or KEYCODE outside bounds\n");
|
||||
error_msg_and_die("SCANCODE or KEYCODE outside bounds\n");
|
||||
}
|
||||
if (ioctl(fd,KDSETKEYCODE,&a)) {
|
||||
perror("KDSETKEYCODE");
|
||||
fatalError("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+7
-22
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,21 +21,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char *basename_usage="basename FILE [SUFFIX]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nStrips directory path and suffixes from FILE.\n"
|
||||
"If specified, also removes any trailing SUFFIX.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
int m, n;
|
||||
char *s, *s1;
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(basename_usage);
|
||||
@@ -43,14 +36,7 @@ extern int basename_main(int argc, char **argv)
|
||||
|
||||
argv++;
|
||||
|
||||
s1=*argv+strlen(*argv)-1;
|
||||
while (s1 && *s1 == '/') {
|
||||
*s1 = '\0';
|
||||
s1--;
|
||||
}
|
||||
s = strrchr(*argv, '/');
|
||||
if (s==NULL) s=*argv;
|
||||
else s++;
|
||||
s = get_last_path_component(*argv);
|
||||
|
||||
if (argc>2) {
|
||||
argv++;
|
||||
@@ -60,6 +46,5 @@ extern int basename_main(int argc, char **argv)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+11
-32
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,47 +21,26 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
static void print_file(FILE * file)
|
||||
{
|
||||
int c;
|
||||
|
||||
while ((c = getc(file)) != EOF)
|
||||
putc(c, stdout);
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
}
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
FILE *file;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
exit(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
if (**(argv + 1) == '-') {
|
||||
usage("cat [FILE ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nConcatenates FILE(s) and prints them to the standard output.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
argc--;
|
||||
|
||||
while (argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) {
|
||||
file = fopen(*argv, "r");
|
||||
if (file == NULL) {
|
||||
perror(*argv);
|
||||
exit(FALSE);
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
print_file(file);
|
||||
}
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+10
-15
@@ -3,7 +3,7 @@
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,20 +22,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
static const char chroot_usage[] = "chroot NEWROOT [COMMAND...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRun COMMAND with root directory set to NEWROOT.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
@@ -47,8 +39,7 @@ int chroot_main(int argc, char **argv)
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
fatalError("chroot: cannot change root directory to %s: %s\n",
|
||||
*argv, strerror(errno));
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
@@ -57,13 +48,17 @@ int chroot_main(int argc, char **argv)
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#ifndef BB_SH
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
shell_main(argc, argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
fatalError("chroot: cannot execute %s: %s\n",
|
||||
prog, strerror(errno));
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1 = argv[1], *filename2 = "-";
|
||||
int c1, c2, char_pos = 1, line_pos = 1;
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
usage(cmp_usage);
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
fp2 = xfopen(argv[2], "r");
|
||||
filename2 = argv[2];
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+217
-343
@@ -1,11 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* cut implementation for busybox
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* Copyright (c) Michael J. Holme
|
||||
*
|
||||
* This version of cut is adapted from Minix cut and was modified
|
||||
* by Erik Andersen <andersee@debian.org> to be used in busybox.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,353 +17,230 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_help
|
||||
#include "messages.c"
|
||||
|
||||
#define MAX_FIELD 80 /* Pointers to the beginning of each field
|
||||
* are stored in columns[], if a line holds
|
||||
* more than MAX_FIELD columns the array
|
||||
* boundary is exceed. But unlikely at 80 */
|
||||
|
||||
#define MAX_ARGS 32 /* Maximum number of fields following -f or
|
||||
* -c switches */
|
||||
int args[MAX_ARGS * 2];
|
||||
int num_args;
|
||||
|
||||
/* Lots of new defines, should easen maintainance... */
|
||||
#define DUMP_STDIN 0 /* define for mode: no options */
|
||||
#define OPTIONF 1 /* define for mode: option -f */
|
||||
#define OPTIONC 2 /* define for mode: option -c */
|
||||
#define OPTIONB 3 /* define for mode: option -b */
|
||||
#define NOTSET 0 /* option not selected */
|
||||
#define SET 1 /* option selected */
|
||||
|
||||
/* Defines for the warnings */
|
||||
#define DELIMITER_NOT_APPLICABLE 0
|
||||
#define OVERRIDING_PREVIOUS_MODE 1
|
||||
#define OPTION_NOT_APPLICABLE 2
|
||||
#define UNKNOWN_OPTION 3
|
||||
#define FILE_NOT_READABLE 4
|
||||
|
||||
/* Defines for the fatal errors */
|
||||
#define SYNTAX_ERROR 101
|
||||
#define POSITION_ERROR 102
|
||||
#define LINE_TO_LONG_ERROR 103
|
||||
#define RANGE_ERROR 104
|
||||
#define MAX_FIELDS_EXEEDED_ERROR 105
|
||||
#define MAX_ARGS_EXEEDED_ERROR 106
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> /* getopt */
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
|
||||
char delim = '\t'; /* default delimiting character */
|
||||
FILE *fd;
|
||||
char *name;
|
||||
char line[BUFSIZ];
|
||||
int exit_status;
|
||||
|
||||
int cut_main(int argc, char **argv);
|
||||
void warn(int warn_number, char *option);
|
||||
void cuterror(int err);
|
||||
void get_args(void);
|
||||
void cut(void);
|
||||
|
||||
void warn(int warn_number, char *option)
|
||||
{
|
||||
static char *warn_msg[] = {
|
||||
"%s: Option -d allowed only with -f\n",
|
||||
"%s: -%s overrides earlier option\n",
|
||||
"%s: -%s not allowed in current mode\n",
|
||||
"%s: Cannot open %s\n"
|
||||
};
|
||||
|
||||
fprintf(stderr, warn_msg[warn_number], name, option);
|
||||
exit_status = warn_number + 1;
|
||||
|
||||
}
|
||||
|
||||
void cuterror(int err)
|
||||
{
|
||||
static char *err_mes[] = {
|
||||
"%s: syntax error\n",
|
||||
"%s: position must be >0\n",
|
||||
"%s: line longer than BUFSIZ\n",
|
||||
"%s: range must not decrease from left to right\n",
|
||||
"%s: MAX_FIELD exceeded\n",
|
||||
"%s: MAX_ARGS exceeded\n"
|
||||
};
|
||||
|
||||
fprintf(stderr, err_mes[err - 101], name);
|
||||
exit(err);
|
||||
}
|
||||
/* globals from other files */
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
|
||||
void get_args()
|
||||
{
|
||||
int i = 0;
|
||||
int arg_ptr = 0;
|
||||
int flag;
|
||||
/* globals in this file only */
|
||||
static char part = 0; /* (b)yte, (c)har, (f)ields */
|
||||
static int startpos = 1;
|
||||
static int endpos = -1;
|
||||
static char delim = '\t'; /* delimiter, default is tab */
|
||||
static unsigned int supress_non_delimited_lines = 0;
|
||||
|
||||
num_args = 0;
|
||||
do {
|
||||
if (num_args == MAX_ARGS)
|
||||
cuterror(MAX_ARGS_EXEEDED_ERROR);
|
||||
if (!isdigit(line[i]) && line[i] != '-')
|
||||
cuterror(SYNTAX_ERROR);
|
||||
|
||||
args[arg_ptr] = 1;
|
||||
args[arg_ptr + 1] = BUFSIZ;
|
||||
flag = 1;
|
||||
|
||||
while (line[i] != ',' && line[i] != 0) {
|
||||
if (isdigit(line[i])) {
|
||||
args[arg_ptr] = 0;
|
||||
while (isdigit(line[i]))
|
||||
args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
|
||||
if (!args[arg_ptr])
|
||||
cuterror(POSITION_ERROR);
|
||||
arg_ptr++;
|
||||
}
|
||||
if (line[i] == '-') {
|
||||
arg_ptr |= 1;
|
||||
i++;
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
if (flag && arg_ptr & 1)
|
||||
args[arg_ptr] = args[arg_ptr - 1];
|
||||
if (args[num_args * 2] > args[num_args * 2 + 1])
|
||||
cuterror(RANGE_ERROR);
|
||||
num_args++;
|
||||
arg_ptr = num_args * 2;
|
||||
}
|
||||
while (line[i++]);
|
||||
}
|
||||
|
||||
|
||||
void cut()
|
||||
{
|
||||
int i, j, length, maxcol=0;
|
||||
char *columns[MAX_FIELD];
|
||||
|
||||
while (fgets(line, BUFSIZ, fd)) {
|
||||
length = strlen(line) - 1;
|
||||
*(line + length) = 0;
|
||||
switch (mode) {
|
||||
case DUMP_STDIN:
|
||||
printf("%s", line);
|
||||
break;
|
||||
case OPTIONF:
|
||||
columns[maxcol++] = line;
|
||||
for (i = 0; i < length; i++) {
|
||||
if (*(line + i) == delim) {
|
||||
*(line + i) = 0;
|
||||
if (maxcol == MAX_FIELD)
|
||||
cuterror(MAX_FIELDS_EXEEDED_ERROR);
|
||||
columns[maxcol] = line + i + 1;
|
||||
maxcol++;
|
||||
}
|
||||
}
|
||||
if (maxcol != 1) {
|
||||
for (i = 0; i < num_args; i++) {
|
||||
for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
|
||||
if (j <= maxcol) {
|
||||
printf("%s", columns[j - 1]);
|
||||
if (i != num_args - 1 || j != args[i * 2 + 1])
|
||||
putchar(delim);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OPTIONC:
|
||||
for (i = 0; i < num_args; i++) {
|
||||
for (j = args[i * 2];
|
||||
j <= (args[i * 2 + 1] >
|
||||
length ? length : args[i * 2 + 1]); j++)
|
||||
putchar(*(line + j - 1));
|
||||
}
|
||||
}
|
||||
if (maxcol != 1)
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int cut_main(int argc, char **argv)
|
||||
{
|
||||
int i = 1;
|
||||
int numberFilenames = 0;
|
||||
|
||||
name = argv[0];
|
||||
|
||||
if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
|
||||
usage( "cut [OPTION]... [FILE]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints selected fields from each input FILE to standard output.\n\n"
|
||||
"Options:\n"
|
||||
"\t-b LIST\tOutput only bytes from LIST\n"
|
||||
"\t-c LIST\tOutput only characters from LIST\n"
|
||||
"\t-d DELIM\tUse DELIM instead of tab as the field delimiter\n"
|
||||
"\t-f N\tPrint only these fields\n"
|
||||
"\t-n\tIgnored\n"
|
||||
#endif
|
||||
);
|
||||
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '-') {
|
||||
switch (argv[i++][1]) {
|
||||
case 'd':
|
||||
if (mode == OPTIONC || mode == OPTIONB)
|
||||
warn(DELIMITER_NOT_APPLICABLE, "d");
|
||||
delim = argv[i++][0];
|
||||
break;
|
||||
case 'f':
|
||||
sprintf(line, "%s", argv[i++]);
|
||||
if (mode == OPTIONC || mode == OPTIONB)
|
||||
warn(OVERRIDING_PREVIOUS_MODE, "f");
|
||||
mode = OPTIONF;
|
||||
break;
|
||||
case 'b':
|
||||
sprintf(line, "%s", argv[i++]);
|
||||
if (mode == OPTIONF || mode == OPTIONC)
|
||||
warn(OVERRIDING_PREVIOUS_MODE, "b");
|
||||
mode = OPTIONB;
|
||||
break;
|
||||
case 'c':
|
||||
sprintf(line, "%s", argv[i++]);
|
||||
if (mode == OPTIONF || mode == OPTIONB)
|
||||
warn(OVERRIDING_PREVIOUS_MODE, "c");
|
||||
mode = OPTIONC;
|
||||
break;
|
||||
case '\0': /* - means: read from stdin */
|
||||
numberFilenames++;
|
||||
break;
|
||||
case 'n': /* needed for Posix, but no effect here */
|
||||
if (mode != OPTIONB)
|
||||
warn(OPTION_NOT_APPLICABLE, "n");
|
||||
break;
|
||||
default:
|
||||
warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
numberFilenames++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Here follow the checks, if the selected options are reasonable. */
|
||||
if (mode == OPTIONB) /* since in Minix char := byte */
|
||||
mode = OPTIONC;
|
||||
get_args();
|
||||
if (numberFilenames != 0) {
|
||||
i = 1;
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '-') {
|
||||
switch (argv[i][1]) {
|
||||
case 'f':
|
||||
case 'c':
|
||||
case 'b':
|
||||
case 'd':
|
||||
i += 2;
|
||||
break;
|
||||
case 'n':
|
||||
case 'i':
|
||||
case 's':
|
||||
i++;
|
||||
break;
|
||||
case '\0':
|
||||
fd = stdin;
|
||||
i++;
|
||||
cut();
|
||||
break;
|
||||
default:
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
if ((fd = fopen(argv[i++], "r")) == NULL) {
|
||||
warn(FILE_NOT_READABLE, argv[i - 1]);
|
||||
} else {
|
||||
cut();
|
||||
fclose(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fd = stdin;
|
||||
cut();
|
||||
}
|
||||
|
||||
return(exit_status);
|
||||
}
|
||||
|
||||
/* cut - extract columns from a file or stdin. Author: Michael J. Holme
|
||||
*
|
||||
* Copyright 1989, Michael John Holme, All rights reserved.
|
||||
* This code may be freely distributed, provided that this notice
|
||||
* remains intact.
|
||||
*
|
||||
* V1.1: 6th September 1989
|
||||
*
|
||||
* Bugs, criticisms, etc,
|
||||
* c/o Mark Powell
|
||||
* JANET sq79@uk.ac.liv
|
||||
* ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
|
||||
* UUCP ...!mcvax!ukc!liv.ac.uk!sq79
|
||||
*-------------------------------------------------------------------------
|
||||
* Changed for POSIX1003.2/Draft10 conformance
|
||||
* Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
|
||||
* Changes:
|
||||
* - separation of error messages ( stderr) and output (stdout).
|
||||
* - support for -b and -n (no effect, -b acts as -c)
|
||||
* - support for -s
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987,1997, Prentice Hall
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use of the MINIX operating system in source and
|
||||
* binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Neither the name of Prentice Hall nor the names of the software
|
||||
* authors or contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, 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 PRENTICE HALL OR ANY AUTHORS 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.
|
||||
*
|
||||
* decompose_list() - parses a list and puts values into startpos and endpos.
|
||||
* valid list formats: N, N-, N-M, -M
|
||||
*/
|
||||
static void decompose_list(const char *list)
|
||||
{
|
||||
unsigned int nminus = 0;
|
||||
char *ptr;
|
||||
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* handle single value 'N' case */
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
error_msg_and_die("missing list of fields\n");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
/* handle multi-value cases */
|
||||
else if (nminus == 1) {
|
||||
/* handle 'N-' case */
|
||||
if (list[strlen(list) - 1] == '-') {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
}
|
||||
/* handle '-M' case */
|
||||
else if (list[0] == '-') {
|
||||
endpos = strtol(&list[1], NULL, 10);
|
||||
}
|
||||
/* handle 'N-M' case */
|
||||
else {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
endpos = strtol(ptr+1, &ptr, 10);
|
||||
}
|
||||
|
||||
/* a sanity check */
|
||||
if (startpos == 0) {
|
||||
startpos = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* snippy-snip
|
||||
*/
|
||||
static void cut_file(FILE *file)
|
||||
{
|
||||
char *line;
|
||||
unsigned int cr_hits = 0;
|
||||
|
||||
/* go through every line in the file */
|
||||
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
|
||||
/* cut based on chars/bytes */
|
||||
if (part == 'c' || part == 'b') {
|
||||
int i;
|
||||
/* a valid end position has been specified */
|
||||
if (endpos > 0) {
|
||||
for (i = startpos-1; i < endpos; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* otherwise, just go to the end of the line */
|
||||
else {
|
||||
for (i = startpos-1; line[i]; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* cut based on fields */
|
||||
else if (part == 'f') {
|
||||
char *ptr;
|
||||
char *start = line;
|
||||
unsigned int delims_hit = 0;
|
||||
|
||||
if (delim == '\n') {
|
||||
cr_hits++;
|
||||
if (cr_hits >= startpos && cr_hits <= endpos) {
|
||||
while (*start && *start != '\n') {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern int cut_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'f':
|
||||
/* make sure they didn't ask for two types of lists */
|
||||
if (part != 0) {
|
||||
error_msg_and_die("only one type of list may be specified\n");
|
||||
}
|
||||
part = (char)opt;
|
||||
decompose_list(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character\n");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
case 'n':
|
||||
/* no-op */
|
||||
break;
|
||||
case 's':
|
||||
supress_non_delimited_lines++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense"
|
||||
" only when operating on fields\n");
|
||||
|
||||
}
|
||||
|
||||
if (delim != '\t' && part != 'f') {
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields\n");
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
* files were specified or '-' was specified, take input from stdin.
|
||||
* Otherwise, we process all the files specified. */
|
||||
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
|
||||
cut_file(stdin);
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
FILE *file;
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+82
-108
@@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_date
|
||||
#define bb_need_memory_exhausted
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
|
||||
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
@@ -39,17 +41,6 @@
|
||||
an RFC 822 complient date output for shell scripting
|
||||
mail commands */
|
||||
|
||||
static const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
|
||||
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDisplays the current time in the given FORMAT, or sets the system date.\n"
|
||||
"\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n"
|
||||
"\t-s\tSets time described by STRING\n"
|
||||
"\t-u\tPrints or sets Coordinated Universal Time\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
/* Input parsing code is always bulky - used heavy duty libc stuff as
|
||||
much as possible, missed out a lot of bounds checking */
|
||||
|
||||
@@ -66,7 +57,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
&(tm_time->tm_min), &(tm_time->tm_year));
|
||||
|
||||
if (nr < 4 || nr > 5) {
|
||||
fatalError(invalid_date, "date", t_string);
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
@@ -84,73 +75,57 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
|
||||
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
struct tm itm_time, jtm_time, ktm_time, ltm_time, mtm_time, ntm_time;
|
||||
|
||||
itm_time = *tm_time;
|
||||
jtm_time = *tm_time;
|
||||
ktm_time = *tm_time;
|
||||
ltm_time = *tm_time;
|
||||
mtm_time = *tm_time;
|
||||
ntm_time = *tm_time;
|
||||
struct tm t;
|
||||
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if (sscanf(t_string, "%d:%d:%d",
|
||||
&itm_time.tm_hour, &itm_time.tm_min, &itm_time.tm_sec) == 3) {
|
||||
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
|
||||
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
|
||||
*tm_time = itm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
|
||||
&t.tm_hour, &t.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
|
||||
} else if (sscanf(t_string, "%d:%d",
|
||||
&jtm_time.tm_hour, &jtm_time.tm_min) == 2) {
|
||||
|
||||
*tm_time = jtm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 5) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&ktm_time.tm_mon,
|
||||
&ktm_time.tm_mday,
|
||||
&ktm_time.tm_hour,
|
||||
&ktm_time.tm_min, &ktm_time.tm_sec) == 5) {
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
ktm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ktm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 4) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d",
|
||||
<m_time.tm_mon,
|
||||
<m_time.tm_mday,
|
||||
<m_time.tm_hour, <m_time.tm_min) == 4) {
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
ltm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ltm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 6) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&mtm_time.tm_year,
|
||||
&mtm_time.tm_mon,
|
||||
&mtm_time.tm_mday,
|
||||
&mtm_time.tm_hour,
|
||||
&mtm_time.tm_min, &mtm_time.tm_sec) == 6) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
mtm_time.tm_year -= 1900; /* Adjust years */
|
||||
mtm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = mtm_time;
|
||||
return (tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&ntm_time.tm_year,
|
||||
&ntm_time.tm_mon,
|
||||
&ntm_time.tm_mday,
|
||||
&ntm_time.tm_hour, &ntm_time.tm_min) == 5) {
|
||||
ntm_time.tm_year -= 1900; /* Adjust years */
|
||||
ntm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ntm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 5) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else {
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
fatalError(invalid_date, "date", t_string);
|
||||
*tm_time = t;
|
||||
return (tm_time);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +134,7 @@ int date_main(int argc, char **argv)
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *t_buff;
|
||||
int i;
|
||||
int c;
|
||||
int set_time = 0;
|
||||
int rfc822 = 0;
|
||||
int utc = 0;
|
||||
@@ -168,49 +143,44 @@ int date_main(int argc, char **argv)
|
||||
struct tm tm_time;
|
||||
|
||||
/* Interpret command line args */
|
||||
i = --argc;
|
||||
argv++;
|
||||
while (i > 0 && **argv) {
|
||||
if (**argv == '-') {
|
||||
while (i > 0 && *++(*argv))
|
||||
switch (**argv) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if (date_str != NULL)
|
||||
usage(date_usage);
|
||||
date_str = *argv;
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
fatalError(memory_exhausted, "date");
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if (date_str != NULL)
|
||||
usage(date_usage);
|
||||
date_str = *argv;
|
||||
break;
|
||||
case '-':
|
||||
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
usage(date_usage);
|
||||
}
|
||||
} else {
|
||||
if ((date_fmt == NULL) && (**argv == '+'))
|
||||
date_fmt = *argv + 1; /* Skip over the '+' */
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = *argv;
|
||||
} else {
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
}
|
||||
}
|
||||
i--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
|
||||
date_fmt = &argv[optind][1]; /* Skip over the '+' */
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = argv[optind];
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
usage(date_usage);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
@@ -236,12 +206,16 @@ int date_main(int argc, char **argv)
|
||||
/* Correct any day of week and day of year etc fields */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0)
|
||||
fatalError(invalid_date, "date", date_str);
|
||||
error_msg_and_die(invalid_date, date_str);
|
||||
if ( utc ) {
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if (set_time) {
|
||||
if (stime(&tm) < 0) {
|
||||
fatalError("date: can't set date.\n");
|
||||
perror_msg("cannot set date");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,7 +233,7 @@ int date_main(int argc, char **argv)
|
||||
} else if (*date_fmt == '\0') {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf("\n");
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Handle special conversions */
|
||||
@@ -273,5 +247,5 @@ int date_main(int argc, char **argv)
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
printf("%s\n", t_buff);
|
||||
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+114
-163
@@ -2,15 +2,8 @@
|
||||
/*
|
||||
* Mini dd implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999, 2000 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Based in part on code taken from sash.
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Permission to distribute this code under the GPL has been granted.
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,180 +21,138 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#include "internal.h"
|
||||
#include <features.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
typedef unsigned long long int uintmax_t;
|
||||
#endif
|
||||
|
||||
static const char dd_usage[] =
|
||||
"dd [if=FILE] [of=FILE] [bs=N] [count=N] [skip=N] [seek=N]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCopy a file, converting and formatting according to options\n\n"
|
||||
"\tif=FILE\tread from FILE instead of stdin\n"
|
||||
"\tof=FILE\twrite to FILE instead of stdout\n"
|
||||
"\tbs=N\tread and write N bytes at a time\n"
|
||||
"\tcount=N\tcopy only N input blocks\n"
|
||||
"\tskip=N\tskip N input blocks\n"
|
||||
"\tseek=N\tskip N output blocks\n"
|
||||
"\n"
|
||||
"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n"
|
||||
#endif
|
||||
;
|
||||
static struct suffix_mult dd_suffixes[] = {
|
||||
{ "c", 1 },
|
||||
{ "w", 2 },
|
||||
{ "b", 512 },
|
||||
{ "kD", 1000 },
|
||||
{ "k", 1024 },
|
||||
{ "MD", 1000000 },
|
||||
{ "M", 1048576 },
|
||||
{ "GD", 1000000000 },
|
||||
{ "G", 1073741824 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern int dd_main(int argc, char **argv)
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
char *inFile = NULL;
|
||||
char *outFile = NULL;
|
||||
char *cp;
|
||||
int inFd;
|
||||
int outFd;
|
||||
int inCc = 0;
|
||||
int outCc;
|
||||
long blockSize = 512;
|
||||
uintmax_t skipBlocks = 0;
|
||||
uintmax_t seekBlocks = 0;
|
||||
uintmax_t count = (uintmax_t) - 1;
|
||||
uintmax_t intotal;
|
||||
uintmax_t outTotal;
|
||||
unsigned char *buf;
|
||||
int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
|
||||
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
|
||||
size_t bs = 512, count = -1;
|
||||
ssize_t n;
|
||||
off_t seek = 0, skip = 0;
|
||||
FILE *statusfp;
|
||||
char *infile = NULL, *outfile = NULL, *buf;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strncmp("bs=", argv[i], 3) == 0)
|
||||
bs = parse_number(argv[i]+3, dd_suffixes);
|
||||
else if (strncmp("count=", argv[i], 6) == 0)
|
||||
count = parse_number(argv[i]+6, dd_suffixes);
|
||||
else if (strncmp("seek=", argv[i], 5) == 0)
|
||||
seek = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("skip=", argv[i], 5) == 0)
|
||||
skip = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("if=", argv[i], 3) == 0)
|
||||
infile = argv[i]+3;
|
||||
else if (strncmp("of=", argv[i], 3) == 0)
|
||||
outfile = argv[i]+3;
|
||||
else if (strncmp("conv=", argv[i], 5) == 0) {
|
||||
buf = argv[i]+5;
|
||||
while (1) {
|
||||
if (strncmp("notrunc", buf, 7) == 0) {
|
||||
trunc = FALSE;
|
||||
buf += 7;
|
||||
} else if (strncmp("sync", buf, 4) == 0) {
|
||||
sync = TRUE;
|
||||
buf += 4;
|
||||
} else {
|
||||
error_msg_and_die("invalid conversion `%s'\n", argv[i]+5);
|
||||
}
|
||||
if (buf[0] == '\0')
|
||||
break;
|
||||
if (buf[0] == ',')
|
||||
buf++;
|
||||
}
|
||||
} else
|
||||
usage(dd_usage);
|
||||
}
|
||||
|
||||
/* Parse any options */
|
||||
while (argc) {
|
||||
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
|
||||
inFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
|
||||
outFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (strncmp("count", *argv, 5) == 0) {
|
||||
count = getNum((strchr(*argv, '=')) + 1);
|
||||
if (count <= 0) {
|
||||
fprintf(stderr, "Bad count value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "bs", 2) == 0) {
|
||||
blockSize = getNum((strchr(*argv, '=')) + 1);
|
||||
if (blockSize <= 0) {
|
||||
fprintf(stderr, "Bad block size value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "skip", 4) == 0) {
|
||||
skipBlocks = getNum((strchr(*argv, '=')) + 1);
|
||||
if (skipBlocks <= 0) {
|
||||
fprintf(stderr, "Bad skip value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
buf = xmalloc(bs);
|
||||
|
||||
} else if (strncmp(*argv, "seek", 4) == 0) {
|
||||
seekBlocks = getNum((strchr(*argv, '=')) + 1);
|
||||
if (seekBlocks <= 0) {
|
||||
fprintf(stderr, "Bad seek value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
if (infile != NULL) {
|
||||
if ((ifd = open(infile, O_RDONLY)) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
} else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = "standard input";
|
||||
}
|
||||
|
||||
} else {
|
||||
goto usage;
|
||||
if (outfile != NULL) {
|
||||
oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
if (!seek && trunc)
|
||||
oflag |= O_TRUNC;
|
||||
|
||||
if ((ofd = open(outfile, oflag, 0666)) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
|
||||
if (seek && trunc) {
|
||||
if (ftruncate(ofd, seek * bs) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
statusfp = stdout;
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
statusfp = stderr;
|
||||
}
|
||||
|
||||
buf = xmalloc(blockSize);
|
||||
|
||||
intotal = 0;
|
||||
outTotal = 0;
|
||||
|
||||
if (inFile == NULL)
|
||||
inFd = fileno(stdin);
|
||||
else
|
||||
inFd = open(inFile, 0);
|
||||
|
||||
if (inFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* free(buf); */
|
||||
fatalError( inFile);
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
outFd = fileno(stdout);
|
||||
else
|
||||
outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
if (outFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* close(inFd);
|
||||
free(buf); */
|
||||
fatalError( outFile);
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
lseek(inFd, skipBlocks * blockSize, SEEK_SET);
|
||||
lseek(outFd, seekBlocks * blockSize, SEEK_SET);
|
||||
//
|
||||
//TODO: Convert to using fullRead & fullWrite
|
||||
// from utility.c
|
||||
// -Erik
|
||||
while (outTotal < count * blockSize) {
|
||||
inCc = read(inFd, buf, blockSize);
|
||||
if (inCc < 0) {
|
||||
perror(inFile);
|
||||
goto cleanup;
|
||||
} else if (inCc == 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
intotal += inCc;
|
||||
cp = buf;
|
||||
|
||||
while (intotal > outTotal) {
|
||||
if (outTotal + inCc > count * blockSize)
|
||||
inCc = count * blockSize - outTotal;
|
||||
outCc = write(outFd, cp, inCc);
|
||||
if (outCc < 0) {
|
||||
perror(outFile);
|
||||
goto cleanup;
|
||||
} else if (outCc == 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
inCc -= outCc;
|
||||
cp += outCc;
|
||||
outTotal += outCc;
|
||||
while (in_full + in_part != count) {
|
||||
n = safe_read(ifd, buf, bs);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (n == bs)
|
||||
in_full++;
|
||||
else
|
||||
in_part++;
|
||||
if (sync) {
|
||||
memset(buf + n, '\0', bs - n);
|
||||
n = bs;
|
||||
}
|
||||
n = full_write(ofd, buf, n);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (n == bs)
|
||||
out_full++;
|
||||
else
|
||||
out_part++;
|
||||
}
|
||||
|
||||
if (inCc < 0)
|
||||
perror(inFile);
|
||||
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
|
||||
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
|
||||
|
||||
cleanup:
|
||||
/* Note that we are not freeing memory or closing
|
||||
* files here, to save a few bytes. */
|
||||
#if 0
|
||||
close(inFd);
|
||||
close(outFd);
|
||||
free(buf);
|
||||
#endif
|
||||
|
||||
printf("%ld+%d records in\n", (long) (intotal / blockSize),
|
||||
(intotal % blockSize) != 0);
|
||||
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
|
||||
(outTotal % blockSize) != 0);
|
||||
exit(TRUE);
|
||||
usage:
|
||||
|
||||
usage(dd_usage);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+70
-34
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini df implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
@@ -22,19 +22,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vfs.h>
|
||||
|
||||
static const char df_usage[] = "df [filesystem ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrint the filesystem space used and space available.\n"
|
||||
#endif
|
||||
;
|
||||
#include <getopt.h>
|
||||
|
||||
extern const char mtab_file[]; /* Defined in utility.c */
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
unsigned long disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
static int df(char *device, const char *mountPoint)
|
||||
{
|
||||
@@ -43,25 +41,38 @@ static int df(char *device, const char *mountPoint)
|
||||
long blocks_percent_used;
|
||||
|
||||
if (statfs(mountPoint, &s) != 0) {
|
||||
perror(mountPoint);
|
||||
perror_msg("%s", mountPoint);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (s.f_blocks > 0) {
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
if(0 == blocks_used)
|
||||
blocks_percent_used = 0;
|
||||
else
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
if (strcmp(device, "/dev/root") == 0) {
|
||||
/* Adjusts device to be the real root device,
|
||||
* or leaves device alone if it can't find it */
|
||||
find_real_root_device_name( device);
|
||||
}
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
printf("%-20s %9s",
|
||||
device,
|
||||
format((s.f_blocks * s.f_bsize), disp_hr));
|
||||
printf(" %9s", format((s.f_blocks - s.f_bfree) * s.f_bsize, disp_hr));
|
||||
printf(" %9s %3ld%% %s\n",
|
||||
format(s.f_bavail * s.f_bsize, disp_hr),
|
||||
blocks_percent_used, mountPoint);
|
||||
#else
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
|
||||
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
|
||||
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
|
||||
blocks_percent_used, mountPoint);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -70,45 +81,70 @@ static int df(char *device, const char *mountPoint)
|
||||
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int opt = 0;
|
||||
int i = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "?"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
"k"
|
||||
)) > 0)
|
||||
{
|
||||
switch (opt) {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h': disp_hr = 0; break;
|
||||
case 'm': disp_hr = MEGABYTE; break;
|
||||
case 'k': disp_hr = KILOBYTE; break;
|
||||
#else
|
||||
case 'k': break;
|
||||
#endif
|
||||
case '?': goto print_df_usage; break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
|
||||
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
(KILOBYTE == disp_hr) ? "1k-blocks" : " Size",
|
||||
#else
|
||||
"1k-blocks",
|
||||
#endif
|
||||
"Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
if (argc > 1) {
|
||||
|
||||
if(optind < argc) {
|
||||
struct mntent *mountEntry;
|
||||
int status;
|
||||
|
||||
if (**(argv + 1) == '-') {
|
||||
usage(df_usage);
|
||||
for(i = optind; i < argc; i++)
|
||||
{
|
||||
if ((mountEntry = find_mount_point(argv[i], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.\n", argv[i]);
|
||||
status = EXIT_FAILURE;
|
||||
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
while (argc > 1) {
|
||||
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
|
||||
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
|
||||
exit(FALSE);
|
||||
}
|
||||
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if (status != 0)
|
||||
exit(status);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
exit(TRUE);
|
||||
} else {
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
|
||||
mountTable = setmntent(mtab_file, "r");
|
||||
if (mountTable == 0) {
|
||||
perror(mtab_file);
|
||||
exit(FALSE);
|
||||
perror_msg("%s", mtab_file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((mountEntry = getmntent(mountTable))) {
|
||||
df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return status;
|
||||
|
||||
print_df_usage:
|
||||
usage(df_usage);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+13
-15
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini dirname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -20,30 +20,28 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int dirname_main(int argc, char **argv)
|
||||
{
|
||||
char* s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage("dirname [FILENAME ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nStrips non-directory suffix from FILENAME\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if ((argc < 2) || (**(argv + 1) == '-'))
|
||||
usage(dirname_usage);
|
||||
argv++;
|
||||
|
||||
s=*argv+strlen(*argv)-1;
|
||||
while (s && *s == '/') {
|
||||
*s = '\0';
|
||||
s=*argv+strlen(*argv)-1;
|
||||
while (s != *argv && *s == '/') {
|
||||
*s-- = '\0';
|
||||
}
|
||||
s = strrchr(*argv, '/');
|
||||
if (s && *s)
|
||||
if (s != NULL && s == *argv)
|
||||
s[1] = '\0';
|
||||
else if (s != NULL)
|
||||
*s = '\0';
|
||||
printf("%s\n", (s)? *argv : ".");
|
||||
return(TRUE);
|
||||
puts(s ? *argv : ".");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Mini dos2unix implementation for busybox
|
||||
|
||||
Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this source code, with or without modification, is
|
||||
permitted provided that the following condition is met:
|
||||
|
||||
1. Redistributions of this source code must retain the above copyright
|
||||
notice, this condition, and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int dos2unix_main( int argc, char **argv ) {
|
||||
int c;
|
||||
if (argc > 1) {
|
||||
c = *argv[1];
|
||||
if (c == '-') {
|
||||
usage(dos2unix_usage);
|
||||
}
|
||||
}
|
||||
c = getchar();
|
||||
while (c != EOF) {
|
||||
/* Eat any \r's... they shouldn't be here */
|
||||
while (c == '\r') c = getchar();
|
||||
if (c == EOF) break;
|
||||
putchar(c);
|
||||
c = getchar();
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+45
-42
@@ -3,7 +3,7 @@
|
||||
* Mini du implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,7 +22,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#include "messages.c"
|
||||
@@ -31,20 +31,15 @@
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
|
||||
typedef void (Display) (long, char *);
|
||||
|
||||
static const char du_usage[] =
|
||||
"du [OPTION]... [FILE]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nSummarizes disk space used for each FILE and/or directory.\n"
|
||||
"Disk space is printed in units of 1024 bytes.\n\n"
|
||||
"Options:\n"
|
||||
"\t-l\tcount sizes many times if hard linked\n"
|
||||
"\t-s\tdisplay only a total for each argument\n"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
unsigned long du_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
;
|
||||
|
||||
typedef void (Display) (long, char *);
|
||||
|
||||
static int du_depth = 0;
|
||||
static int count_hardlinks = 0;
|
||||
@@ -53,12 +48,17 @@ static Display *print;
|
||||
|
||||
static void print_normal(long size, char *filename)
|
||||
{
|
||||
fprintf(stdout, "%ld\t%s\n", size, filename);
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
printf("%s\t%s\n", format((size * KILOBYTE), du_disp_hr), filename);
|
||||
#else
|
||||
printf("%ld\t%s\n", size, filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void print_summary(long size, char *filename)
|
||||
{
|
||||
if (du_depth == 1) {
|
||||
printf("summary\n");
|
||||
print_normal(size, filename);
|
||||
}
|
||||
}
|
||||
@@ -71,8 +71,7 @@ static long du(char *filename)
|
||||
int len;
|
||||
|
||||
if ((lstat(filename, &statbuf)) != 0) {
|
||||
printf("du: %s: %s\n", filename, strerror(errno));
|
||||
return 0;
|
||||
perror_msg_and_die("%s", filename);
|
||||
}
|
||||
|
||||
du_depth++;
|
||||
@@ -108,7 +107,7 @@ static long du(char *filename)
|
||||
}
|
||||
|
||||
if (len + strlen(name) + 1 > BUFSIZ) {
|
||||
fprintf(stderr, name_too_long, "du");
|
||||
error_msg(name_too_long);
|
||||
du_depth--;
|
||||
return 0;
|
||||
}
|
||||
@@ -136,55 +135,59 @@ static long du(char *filename)
|
||||
|
||||
int du_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int i;
|
||||
char opt;
|
||||
int c;
|
||||
|
||||
/* default behaviour */
|
||||
print = print_normal;
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
while ((c = getopt(argc, argv, "sl"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
"k")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
print = print_summary;
|
||||
break;
|
||||
print = print_summary;
|
||||
break;
|
||||
case 'l':
|
||||
count_hardlinks = 1;
|
||||
break;
|
||||
case 'h':
|
||||
case '-':
|
||||
usage(du_usage);
|
||||
break;
|
||||
count_hardlinks = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h': du_disp_hr = 0; break;
|
||||
case 'm': du_disp_hr = MEGABYTE; break;
|
||||
case 'k': du_disp_hr = KILOBYTE; break;
|
||||
#else
|
||||
case 'k': break;
|
||||
#endif
|
||||
default:
|
||||
fprintf(stderr, "du: invalid option -- %c\n", opt);
|
||||
usage(du_usage);
|
||||
usage(du_usage);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* go through remaining args (if any) */
|
||||
if (i >= argc) {
|
||||
du(".");
|
||||
if (optind >= argc) {
|
||||
if (du(".") == 0)
|
||||
status = EXIT_FAILURE;
|
||||
} else {
|
||||
long sum;
|
||||
|
||||
for (; i < argc; i++) {
|
||||
sum = du(argv[i]);
|
||||
if (sum && isDirectory(argv[i], FALSE, NULL)) {
|
||||
for (i=optind; i < argc; i++) {
|
||||
if ((sum = du(argv[i])) == 0)
|
||||
status = EXIT_FAILURE;
|
||||
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
print_normal(sum, argv[i]);
|
||||
}
|
||||
reset_ino_dev_hashtable();
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* $Id: du.c,v 1.20 2000/06/19 17:25:39 andersen Exp $ */
|
||||
/* $Id: du.c,v 1.36 2001/01/27 09:33:38 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
|
||||
+74
-62
@@ -22,81 +22,94 @@
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static const char uname_usage[] =
|
||||
"echo [-neE] [ARG ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints the specified ARGs to stdout\n\n"
|
||||
"Options:\n"
|
||||
"\t-n\tsuppress trailing newline\n"
|
||||
"\t-e\tinterpret backslash-escaped characters (i.e. \\t=tab etc)\n"
|
||||
"\t-E\tdisable interpretation of backslash-escaped characters\n"
|
||||
#endif
|
||||
;
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int
|
||||
echo_main(int argc, char** argv)
|
||||
{
|
||||
register char **ap;
|
||||
register char *p;
|
||||
register char c;
|
||||
int nflag = 0;
|
||||
int eflag = 0;
|
||||
|
||||
ap = argv;
|
||||
if (argc)
|
||||
ap++;
|
||||
while ((p = *ap) != NULL && *p == '-') {
|
||||
if (strcmp(p, "-n")==0) {
|
||||
nflag = 1;
|
||||
} else if (strcmp(p, "-e")==0) {
|
||||
eflag = 1;
|
||||
} else if (strcmp(p, "-E")==0) {
|
||||
eflag = 0;
|
||||
/* Skip argv[0]. */
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc > 0 && *argv[0] == '-')
|
||||
{
|
||||
register char *temp;
|
||||
register int index;
|
||||
|
||||
/*
|
||||
* If it appears that we are handling options, then make sure
|
||||
* that all of the options specified are actually valid.
|
||||
* Otherwise, the string should just be echoed.
|
||||
*/
|
||||
temp = argv[0] + 1;
|
||||
|
||||
for (index = 0; temp[index]; index++)
|
||||
{
|
||||
if (strrchr("neE", temp[index]) == 0)
|
||||
goto just_echo;
|
||||
}
|
||||
else if (strncmp(p, "--", 2)==0) {
|
||||
usage( uname_usage);
|
||||
}
|
||||
else break;
|
||||
ap++;
|
||||
|
||||
if (!*temp)
|
||||
goto just_echo;
|
||||
|
||||
/*
|
||||
* All of the options in temp are valid options to echo.
|
||||
* Handle them.
|
||||
*/
|
||||
while (*temp)
|
||||
{
|
||||
if (*temp == 'n')
|
||||
nflag = 1;
|
||||
else if (*temp == 'e')
|
||||
eflag = 1;
|
||||
else if (*temp == 'E')
|
||||
eflag = 0;
|
||||
else
|
||||
goto just_echo;
|
||||
|
||||
temp++;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
while ((p = *ap++) != NULL) {
|
||||
while ((c = *p++) != '\0') {
|
||||
if (c == '\\' && eflag) {
|
||||
switch (c = *p++) {
|
||||
case 'a': c = '\007'; break;
|
||||
case 'b': c = '\b'; break;
|
||||
case 'c': exit( 0); /* exit */
|
||||
case 'f': c = '\f'; break;
|
||||
case 'n': c = '\n'; break;
|
||||
case 'r': c = '\r'; break;
|
||||
case 't': c = '\t'; break;
|
||||
case 'v': c = '\v'; break;
|
||||
case '\\': break; /* c = '\\' */
|
||||
case '0': case '1': case '2': case '3':
|
||||
case '4': case '5': case '6': case '7':
|
||||
c -= '0';
|
||||
if (*p >= '0' && *p <= '7')
|
||||
c = c * 8 + (*p++ - '0');
|
||||
if (*p >= '0' && *p <= '7')
|
||||
c = c * 8 + (*p++ - '0');
|
||||
break;
|
||||
default:
|
||||
p--;
|
||||
break;
|
||||
|
||||
just_echo:
|
||||
while (argc > 0) {
|
||||
char *arg = argv[0];
|
||||
register int c;
|
||||
|
||||
while ((c = *arg++)) {
|
||||
|
||||
/* Check for escape sequence. */
|
||||
if (c == '\\' && eflag && *arg) {
|
||||
if (*arg == 'c') {
|
||||
/* '\c' means cancel newline. */
|
||||
nflag = 1;
|
||||
arg++;
|
||||
continue;
|
||||
} else {
|
||||
c = process_escape_sequence(&arg);
|
||||
}
|
||||
}
|
||||
|
||||
putchar(c);
|
||||
}
|
||||
if (*ap)
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc > 0)
|
||||
putchar(' ');
|
||||
}
|
||||
if (! nflag)
|
||||
if (!nflag)
|
||||
putchar('\n');
|
||||
fflush(stdout);
|
||||
return( 0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -114,9 +127,10 @@ echo_main(int argc, char** argv)
|
||||
* 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
@@ -136,5 +150,3 @@ echo_main(int argc, char** argv)
|
||||
*
|
||||
* @(#)echo.c 8.1 (Berkeley) 5/31/93
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,533 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini expr implementation for busybox
|
||||
*
|
||||
* based on GNU expr Mike Parker.
|
||||
* Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
*
|
||||
* Busybox modifications
|
||||
* Copyright (c) 2000 Edward Betts <edward@debian.org>.
|
||||
*
|
||||
* this program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the gnu general public license as published by
|
||||
* the free software foundation; either version 2 of the license, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* this program is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. see the gnu
|
||||
* general public license for more details.
|
||||
*
|
||||
* you should have received a copy of the gnu general public license
|
||||
* along with this program; if not, write to the free software
|
||||
* foundation, inc., 59 temple place, suite 330, boston, ma 02111-1307 usa
|
||||
*
|
||||
*/
|
||||
|
||||
/* This program evaluates expressions. Each token (operator, operand,
|
||||
* parenthesis) of the expression must be a seperate argument. The
|
||||
* parser used is a reasonably general one, though any incarnation of
|
||||
* it is language-specific. It is especially nice for expressions.
|
||||
*
|
||||
* No parse tree is needed; a new node is evaluated immediately.
|
||||
* One function can handle multiple operators all of equal precedence,
|
||||
* provided they all associate ((x op x) op x). */
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <regex.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
enum valtype {
|
||||
integer,
|
||||
string
|
||||
};
|
||||
typedef enum valtype TYPE;
|
||||
|
||||
/* A value is.... */
|
||||
struct valinfo {
|
||||
TYPE type; /* Which kind. */
|
||||
union { /* The value itself. */
|
||||
int i;
|
||||
char *s;
|
||||
} u;
|
||||
};
|
||||
typedef struct valinfo VALUE;
|
||||
|
||||
/* The arguments given to the program, minus the program name. */
|
||||
static char **args;
|
||||
|
||||
static VALUE *docolon (VALUE *sv, VALUE *pv);
|
||||
static VALUE *eval (void);
|
||||
static VALUE *int_value (int i);
|
||||
static VALUE *str_value (char *s);
|
||||
static int nextarg (char *str);
|
||||
static int null (VALUE *v);
|
||||
static int toarith (VALUE *v);
|
||||
static void freev (VALUE *v);
|
||||
static void tostring (VALUE *v);
|
||||
|
||||
int expr_main (int argc, char **argv)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (argc == 1) {
|
||||
error_msg_and_die("too few arguments\n");
|
||||
}
|
||||
|
||||
args = argv + 1;
|
||||
|
||||
v = eval ();
|
||||
if (*args)
|
||||
error_msg_and_die ("syntax error\n");
|
||||
|
||||
if (v->type == integer)
|
||||
printf ("%d\n", v->u.i);
|
||||
else
|
||||
printf ("%s\n", v->u.s);
|
||||
|
||||
exit (null (v));
|
||||
}
|
||||
|
||||
/* Return a VALUE for I. */
|
||||
|
||||
static VALUE *int_value (int i)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = integer;
|
||||
v->u.i = i;
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Return a VALUE for S. */
|
||||
|
||||
static VALUE *str_value (char *s)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = string;
|
||||
v->u.s = strdup (s);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Free VALUE V, including structure components. */
|
||||
|
||||
static void freev (VALUE *v)
|
||||
{
|
||||
if (v->type == string)
|
||||
free (v->u.s);
|
||||
free (v);
|
||||
}
|
||||
|
||||
/* Return nonzero if V is a null-string or zero-number. */
|
||||
|
||||
static int null (VALUE *v)
|
||||
{
|
||||
switch (v->type) {
|
||||
case integer:
|
||||
return v->u.i == 0;
|
||||
case string:
|
||||
return v->u.s[0] == '\0' || strcmp (v->u.s, "0") == 0;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to a string value (can't fail). */
|
||||
|
||||
static void tostring (VALUE *v)
|
||||
{
|
||||
char *temp;
|
||||
|
||||
if (v->type == integer) {
|
||||
temp = xmalloc (4 * (sizeof (int) / sizeof (char)));
|
||||
sprintf (temp, "%d", v->u.i);
|
||||
v->u.s = temp;
|
||||
v->type = string;
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
|
||||
|
||||
static int toarith (VALUE *v)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (v->type) {
|
||||
case integer:
|
||||
return 1;
|
||||
case string:
|
||||
i = 0;
|
||||
/* Don't interpret the empty string as an integer. */
|
||||
if (v->u.s == 0)
|
||||
return 0;
|
||||
i = atoi(v->u.s);
|
||||
free (v->u.s);
|
||||
v->u.i = i;
|
||||
v->type = integer;
|
||||
return 1;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Return nonzero if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
|
||||
static int
|
||||
nextarg (char *str)
|
||||
{
|
||||
if (*args == NULL)
|
||||
return 0;
|
||||
return strcmp (*args, str) == 0;
|
||||
}
|
||||
|
||||
/* The comparison operator handling functions. */
|
||||
|
||||
#define cmpf(name, rel) \
|
||||
static int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (l->type == string || r->type == string) { \
|
||||
tostring (l); \
|
||||
tostring (r); \
|
||||
return strcmp (l->u.s, r->u.s) rel 0; \
|
||||
} \
|
||||
else \
|
||||
return l->u.i rel r->u.i; \
|
||||
}
|
||||
cmpf (less_than, <)
|
||||
cmpf (less_equal, <=)
|
||||
cmpf (equal, ==)
|
||||
cmpf (not_equal, !=)
|
||||
cmpf (greater_equal, >=)
|
||||
cmpf (greater_than, >)
|
||||
|
||||
#undef cmpf
|
||||
|
||||
/* The arithmetic operator handling functions. */
|
||||
|
||||
#define arithf(name, op) \
|
||||
static \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ("non-numeric argument\n"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
#define arithdivf(name, op) \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ( "non-numeric argument\n"); \
|
||||
if (r->u.i == 0) \
|
||||
error_msg_and_die ( "division by zero\n"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
arithf (plus, +)
|
||||
arithf (minus, -)
|
||||
arithf (multiply, *)
|
||||
arithdivf (divide, /)
|
||||
arithdivf (mod, %)
|
||||
|
||||
#undef arithf
|
||||
#undef arithdivf
|
||||
|
||||
/* Do the : operator.
|
||||
SV is the VALUE for the lhs (the string),
|
||||
PV is the VALUE for the rhs (the pattern). */
|
||||
|
||||
static VALUE *docolon (VALUE *sv, VALUE *pv)
|
||||
{
|
||||
VALUE *v;
|
||||
const char *errmsg;
|
||||
struct re_pattern_buffer re_buffer;
|
||||
struct re_registers re_regs;
|
||||
int len;
|
||||
|
||||
tostring (sv);
|
||||
tostring (pv);
|
||||
|
||||
if (pv->u.s[0] == '^') {
|
||||
fprintf (stderr, "\
|
||||
warning: unportable BRE: `%s': using `^' as the first character\n\
|
||||
of a basic regular expression is not portable; it is being ignored",
|
||||
pv->u.s);
|
||||
}
|
||||
|
||||
len = strlen (pv->u.s);
|
||||
memset (&re_buffer, 0, sizeof (re_buffer));
|
||||
memset (&re_regs, 0, sizeof (re_regs));
|
||||
re_buffer.allocated = 2 * len;
|
||||
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
|
||||
re_buffer.translate = 0;
|
||||
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
|
||||
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
|
||||
if (errmsg) {
|
||||
error_msg_and_die("%s\n", errmsg);
|
||||
}
|
||||
|
||||
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
|
||||
if (len >= 0) {
|
||||
/* Were \(...\) used? */
|
||||
if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */
|
||||
sv->u.s[re_regs.end[1]] = '\0';
|
||||
v = str_value (sv->u.s + re_regs.start[1]);
|
||||
}
|
||||
else
|
||||
v = int_value (len);
|
||||
}
|
||||
else {
|
||||
/* Match failed -- return the right kind of null. */
|
||||
if (re_buffer.re_nsub > 0)
|
||||
v = str_value ("");
|
||||
else
|
||||
v = int_value (0);
|
||||
}
|
||||
free (re_buffer.buffer);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Handle bare operands and ( expr ) syntax. */
|
||||
|
||||
static VALUE *eval7 (void)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
|
||||
if (nextarg ("(")) {
|
||||
args++;
|
||||
v = eval ();
|
||||
if (!nextarg (")"))
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
args++;
|
||||
return v;
|
||||
}
|
||||
|
||||
if (nextarg (")"))
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
|
||||
return str_value (*args++);
|
||||
}
|
||||
|
||||
/* Handle match, substr, index, length, and quote keywords. */
|
||||
|
||||
static VALUE *eval6 (void)
|
||||
{
|
||||
VALUE *l, *r, *v, *i1, *i2;
|
||||
|
||||
if (nextarg ("quote")) {
|
||||
args++;
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
return str_value (*args++);
|
||||
}
|
||||
else if (nextarg ("length")) {
|
||||
args++;
|
||||
r = eval6 ();
|
||||
tostring (r);
|
||||
v = int_value (strlen (r->u.s));
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("match")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
r = eval6 ();
|
||||
v = docolon (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("index")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
r = eval6 ();
|
||||
tostring (l);
|
||||
tostring (r);
|
||||
v = int_value (strcspn (l->u.s, r->u.s) + 1);
|
||||
if (v->u.i == (int) strlen (l->u.s) + 1)
|
||||
v->u.i = 0;
|
||||
freev (l);
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("substr")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
i1 = eval6 ();
|
||||
i2 = eval6 ();
|
||||
tostring (l);
|
||||
if (!toarith (i1) || !toarith (i2)
|
||||
|| i1->u.i > (int) strlen (l->u.s)
|
||||
|| i1->u.i <= 0 || i2->u.i <= 0)
|
||||
v = str_value ("");
|
||||
else {
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = string;
|
||||
v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1),
|
||||
l->u.s + i1->u.i - 1, i2->u.i);
|
||||
v->u.s[i2->u.i] = 0;
|
||||
}
|
||||
freev (l);
|
||||
freev (i1);
|
||||
freev (i2);
|
||||
return v;
|
||||
}
|
||||
else
|
||||
return eval7 ();
|
||||
}
|
||||
|
||||
/* Handle : operator (pattern matching).
|
||||
Calls docolon to do the real work. */
|
||||
|
||||
static VALUE *eval5 (void)
|
||||
{
|
||||
VALUE *l, *r, *v;
|
||||
|
||||
l = eval6 ();
|
||||
while (nextarg (":")) {
|
||||
args++;
|
||||
r = eval6 ();
|
||||
v = docolon (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = v;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/* Handle *, /, % operators. */
|
||||
|
||||
static VALUE *eval4 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval5 ();
|
||||
while (1) {
|
||||
if (nextarg ("*"))
|
||||
fxn = multiply;
|
||||
else if (nextarg ("/"))
|
||||
fxn = divide;
|
||||
else if (nextarg ("%"))
|
||||
fxn = mod;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval5 ();
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle +, - operators. */
|
||||
|
||||
static VALUE *eval3 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval4 ();
|
||||
while (1) {
|
||||
if (nextarg ("+"))
|
||||
fxn = plus;
|
||||
else if (nextarg ("-"))
|
||||
fxn = minus;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval4 ();
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle comparisons. */
|
||||
|
||||
static VALUE *eval2 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval3 ();
|
||||
while (1) {
|
||||
if (nextarg ("<"))
|
||||
fxn = less_than;
|
||||
else if (nextarg ("<="))
|
||||
fxn = less_equal;
|
||||
else if (nextarg ("=") || nextarg ("=="))
|
||||
fxn = equal;
|
||||
else if (nextarg ("!="))
|
||||
fxn = not_equal;
|
||||
else if (nextarg (">="))
|
||||
fxn = greater_equal;
|
||||
else if (nextarg (">"))
|
||||
fxn = greater_than;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval3 ();
|
||||
toarith (l);
|
||||
toarith (r);
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle &. */
|
||||
|
||||
static VALUE *eval1 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
|
||||
l = eval2 ();
|
||||
while (nextarg ("&")) {
|
||||
args++;
|
||||
r = eval2 ();
|
||||
if (null (l) || null (r)) {
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (0);
|
||||
}
|
||||
else
|
||||
freev (r);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/* Handle |. */
|
||||
|
||||
static VALUE *eval (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
|
||||
l = eval1 ();
|
||||
while (nextarg ("|")) {
|
||||
args++;
|
||||
r = eval1 ();
|
||||
if (null (l)) {
|
||||
freev (l);
|
||||
l = r;
|
||||
}
|
||||
else
|
||||
freev (r);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
+48
-65
@@ -3,7 +3,7 @@
|
||||
* Mini head implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,32 +22,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const char head_usage[] =
|
||||
"head [OPTION] [FILE]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrint first 10 lines of each FILE to standard output.\n"
|
||||
"With more than one FILE, precede each with a header giving the\n"
|
||||
"file name. With no FILE, or when FILE is -, read standard input.\n\n"
|
||||
|
||||
"Options:\n" "\t-n NUM\t\tPrint first NUM lines instead of first 10\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int head(int len, FILE * src)
|
||||
int head(int len, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
char buffer[1024];
|
||||
char *input;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
fgets(buffer, 1024, src);
|
||||
if (feof(src)) {
|
||||
if ((input = get_line_from_file(fp)) == NULL)
|
||||
break;
|
||||
}
|
||||
fputs(buffer, stdout);
|
||||
fputs(input, stdout);
|
||||
free(input);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -55,61 +45,54 @@ int head(int len, FILE * src)
|
||||
/* BusyBoxed head(1) */
|
||||
int head_main(int argc, char **argv)
|
||||
{
|
||||
char opt;
|
||||
int len = 10, tmplen, i;
|
||||
FILE *fp;
|
||||
int need_headers, opt, len = 10, status = EXIT_SUCCESS;
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
tmplen = 0;
|
||||
if (++i < argc)
|
||||
tmplen = atoi(argv[i]);
|
||||
if (tmplen < 1)
|
||||
usage(head_usage);
|
||||
len = tmplen;
|
||||
while ((opt = getopt(argc, argv, "n:")) > 0) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
len = atoi(optarg);
|
||||
if (len >= 1)
|
||||
break;
|
||||
case '-':
|
||||
case 'h':
|
||||
usage(head_usage);
|
||||
default:
|
||||
fprintf(stderr, "head: invalid option -- %c\n", opt);
|
||||
usage(head_usage);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
/* fallthrough */
|
||||
default:
|
||||
usage(head_usage);
|
||||
}
|
||||
}
|
||||
|
||||
/* get rest of argv[] or stdin if nothing's left */
|
||||
if (i >= argc) {
|
||||
if (argv[optind] == NULL) {
|
||||
head(len, stdin);
|
||||
return status;
|
||||
}
|
||||
|
||||
} else {
|
||||
int need_headers = ((argc - i) > 1);
|
||||
|
||||
for (; i < argc; i++) {
|
||||
FILE *src;
|
||||
|
||||
src = fopen(argv[i], "r");
|
||||
if (!src) {
|
||||
fprintf(stderr, "head: %s: %s\n", argv[i],
|
||||
strerror(errno));
|
||||
} else {
|
||||
/* emulating GNU behaviour */
|
||||
if (need_headers) {
|
||||
fprintf(stdout, "==> %s <==\n", argv[i]);
|
||||
}
|
||||
head(len, src);
|
||||
if (i < argc - 1) {
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
need_headers = optind != (argc - 1);
|
||||
while (argv[optind]) {
|
||||
if (strcmp(argv[optind], "-") == 0) {
|
||||
fp = stdin;
|
||||
argv[optind] = "standard input";
|
||||
} else {
|
||||
if ((fp = wfopen(argv[optind], "r")) == NULL)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
if (fp) {
|
||||
if (need_headers) {
|
||||
printf("==> %s <==\n", argv[optind]);
|
||||
}
|
||||
head(len, fp);
|
||||
if (errno) {
|
||||
perror_msg("%s", argv[optind]);
|
||||
status = EXIT_FAILURE;
|
||||
errno = 0;
|
||||
}
|
||||
if (optind < argc - 1)
|
||||
putchar('\n');
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* $Id: head.c,v 1.11 2000/06/19 17:25:39 andersen Exp $ */
|
||||
return status;
|
||||
}
|
||||
+4
-2
@@ -20,11 +20,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern int hostid_main(int argc, char **argv)
|
||||
{
|
||||
printf("%lx\n", gethostid());
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+46
-42
@@ -2,7 +2,6 @@
|
||||
/*
|
||||
* Mini id implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,54 +20,46 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static const char id_usage[] =
|
||||
"id [OPTIONS]... [USERNAME]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrint information for USERNAME or the current user\n\n"
|
||||
"Options:\n"
|
||||
"\t-g\tprints only the group ID\n"
|
||||
"\t-u\tprints only the user ID\n"
|
||||
"\t-r\tprints the real user ID instead of the effective ID (with -ug)\n\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int id_main(int argc, char **argv)
|
||||
{
|
||||
int no_user = 0, no_group = 0, print_real = 0;
|
||||
char *cp, *user, *group;
|
||||
unsigned long gid;
|
||||
int name_not_number = 0;
|
||||
char user[9], group[9];
|
||||
long gid;
|
||||
long pwnam, grnam;
|
||||
int opt;
|
||||
|
||||
cp = user = group = NULL;
|
||||
gid = 0;
|
||||
|
||||
argc--; argv++;
|
||||
|
||||
while (argc > 0) {
|
||||
cp = *argv;
|
||||
if (*cp == '-') {
|
||||
switch (*++cp) {
|
||||
case 'u': no_group = 1; break;
|
||||
case 'g': no_user = 1; break;
|
||||
case 'r': print_real = 1; break;
|
||||
default: usage(id_usage);
|
||||
}
|
||||
} else {
|
||||
user = cp;
|
||||
while ((opt = getopt(argc, argv, "ugrn")) > 0) {
|
||||
switch (opt) {
|
||||
case 'u':
|
||||
no_group++;
|
||||
break;
|
||||
case 'g':
|
||||
no_user++;
|
||||
break;
|
||||
case 'r':
|
||||
print_real++;
|
||||
break;
|
||||
case 'n':
|
||||
name_not_number++;
|
||||
break;
|
||||
default:
|
||||
usage(id_usage);
|
||||
}
|
||||
argc--; argv++;
|
||||
}
|
||||
|
||||
if (no_user && no_group) usage(id_usage);
|
||||
|
||||
if (user == NULL) {
|
||||
user = xmalloc(9);
|
||||
group = xmalloc(9);
|
||||
if (argv[optind] == NULL) {
|
||||
if (print_real) {
|
||||
my_getpwuid(user, getuid());
|
||||
my_getgrgid(group, getgid());
|
||||
@@ -77,18 +68,31 @@ extern int id_main(int argc, char **argv)
|
||||
my_getgrgid(group, getegid());
|
||||
}
|
||||
} else {
|
||||
group = xmalloc(9);
|
||||
strncpy(user, argv[optind], 8);
|
||||
user[8] = '\0';
|
||||
gid = my_getpwnamegid(user);
|
||||
my_getgrgid(group, gid);
|
||||
}
|
||||
|
||||
if (no_group) printf("%lu\n", my_getpwnam(user));
|
||||
else if (no_user) printf("%lu\n", my_getgrnam(group));
|
||||
else
|
||||
printf("uid=%lu(%s) gid=%lu(%s)\n",
|
||||
my_getpwnam(user), user, my_getgrnam(group), group);
|
||||
|
||||
pwnam=my_getpwnam(user);
|
||||
grnam=my_getgrnam(group);
|
||||
if (gid == -1 || pwnam==-1 || grnam==-1) {
|
||||
error_msg_and_die("%s: No such user\n", user);
|
||||
}
|
||||
|
||||
if (no_group) {
|
||||
if(name_not_number && user)
|
||||
printf("%s\n",user);
|
||||
else
|
||||
printf("%ld\n", pwnam);
|
||||
} else if (no_user) {
|
||||
if(name_not_number && group)
|
||||
printf("%s\n", group);
|
||||
else
|
||||
printf("%ld\n", grnam);
|
||||
} else {
|
||||
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
+4
-9
@@ -1,18 +1,13 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int length_main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2 || **(argv + 1) == '-') {
|
||||
usage("length STRING\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints out the length of the specified STRING.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc != 2 || **(argv + 1) == '-')
|
||||
usage(length_usage);
|
||||
printf("%lu\n", (long)strlen(argv[1]));
|
||||
return (TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+74
-109
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini ln implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,130 +21,95 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#define bb_need_not_a_directory
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static const char ln_usage[] =
|
||||
"ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreate a link named LINK_NAME or DIRECTORY to the specified TARGET\n"
|
||||
"\nYou may use '--' to indicate that all following arguments are non-options.\n\n"
|
||||
"Options:\n"
|
||||
"\t-s\tmake symbolic links instead of hard links\n"
|
||||
static const int LN_SYMLINK = 1;
|
||||
static const int LN_FORCE = 2;
|
||||
static const int LN_NODEREFERENCE = 4;
|
||||
|
||||
"\t-f\tremove existing destination files\n"
|
||||
#if 0
|
||||
"\t-n\tno dereference symlinks - treat like normal file\n"
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
/*
|
||||
* linkDestName is where the link points to,
|
||||
* linkSrcName is the name of the link to be created.
|
||||
*/
|
||||
static int fs_link(const char *link_DestName, const char *link_SrcName, const int flag)
|
||||
{
|
||||
int status;
|
||||
int srcIsDir;
|
||||
char *srcName;
|
||||
|
||||
static int symlinkFlag = FALSE;
|
||||
static int removeoldFlag = FALSE;
|
||||
static int followLinks = TRUE;
|
||||
if (link_DestName==NULL)
|
||||
return(FALSE);
|
||||
|
||||
srcName = (char *) malloc(strlen(link_SrcName)+strlen(link_DestName)+1);
|
||||
|
||||
if (link_SrcName==NULL)
|
||||
strcpy(srcName, link_DestName);
|
||||
else
|
||||
strcpy(srcName, link_SrcName);
|
||||
|
||||
if (flag&LN_NODEREFERENCE)
|
||||
srcIsDir = is_directory(srcName, TRUE, NULL);
|
||||
else
|
||||
srcIsDir = is_directory(srcName, FALSE, NULL);
|
||||
|
||||
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
|
||||
strcat(srcName, "/");
|
||||
strcat(srcName, link_DestName);
|
||||
}
|
||||
|
||||
if (flag&LN_FORCE)
|
||||
unlink(srcName);
|
||||
|
||||
if (flag&LN_SYMLINK)
|
||||
status = symlink(link_DestName, srcName);
|
||||
else
|
||||
status = link(link_DestName, srcName);
|
||||
|
||||
if (status != 0) {
|
||||
perror(srcName);
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
extern int ln_main(int argc, char **argv)
|
||||
{
|
||||
char *linkName;
|
||||
int linkIntoDirFlag;
|
||||
int stopIt = FALSE;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
int status = EXIT_SUCCESS;
|
||||
int flag = 0;
|
||||
int opt;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 0 && stopIt == FALSE) {
|
||||
if (**argv == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
case 's':
|
||||
symlinkFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
removeoldFlag = TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
followLinks = FALSE;
|
||||
break;
|
||||
case '-':
|
||||
stopIt = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage(ln_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (argc < 2) {
|
||||
usage(ln_usage);
|
||||
}
|
||||
|
||||
linkName = argv[argc - 1];
|
||||
|
||||
if (strlen(linkName) > BUFSIZ) {
|
||||
fprintf(stderr, name_too_long, "ln");
|
||||
exit FALSE;
|
||||
}
|
||||
|
||||
linkIntoDirFlag = isDirectory(linkName, TRUE, NULL);
|
||||
|
||||
if ((argc >= 3) && linkIntoDirFlag == FALSE) {
|
||||
fprintf(stderr, not_a_directory, "ln", linkName);
|
||||
exit FALSE;
|
||||
}
|
||||
|
||||
while (argc-- >= 2) {
|
||||
#if 0
|
||||
char srcName[BUFSIZ + 1];
|
||||
int nChars;
|
||||
#endif
|
||||
int status;
|
||||
|
||||
if (strlen(*argv) > BUFSIZ) {
|
||||
fprintf(stderr, name_too_long, "ln");
|
||||
exit FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (followLinks == FALSE) {
|
||||
strcpy(srcName, *argv);
|
||||
} else {
|
||||
/* Warning! This can silently truncate if > BUFSIZ, but
|
||||
I don't think that there can be one > BUFSIZ anyway. */
|
||||
nChars = readlink(*argv, srcName, BUFSIZ);
|
||||
srcName[nChars] = '\0';
|
||||
}
|
||||
#endif
|
||||
|
||||
if (removeoldFlag == TRUE) {
|
||||
status = (unlink(linkName) && errno != ENOENT);
|
||||
if (status != 0) {
|
||||
perror(linkName);
|
||||
exit FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (symlinkFlag == TRUE)
|
||||
status = symlink(*argv, linkName);
|
||||
else
|
||||
status = link(*argv, linkName);
|
||||
if (status != 0) {
|
||||
perror(linkName);
|
||||
exit FALSE;
|
||||
while ((opt=getopt(argc, argv, "sfn")) != -1) {
|
||||
switch(opt) {
|
||||
case 's':
|
||||
flag |= LN_SYMLINK;
|
||||
break;
|
||||
case 'f':
|
||||
flag |= LN_FORCE;
|
||||
break;
|
||||
case 'n':
|
||||
flag |= LN_NODEREFERENCE;
|
||||
break;
|
||||
default:
|
||||
usage(ln_usage);
|
||||
}
|
||||
}
|
||||
return( TRUE);
|
||||
while(optind<(argc-1)) {
|
||||
if (fs_link(argv[optind], argv[argc-1], flag)==FALSE)
|
||||
status = EXIT_FAILURE;
|
||||
optind++;
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+7
-12
@@ -20,27 +20,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static const char logname_usage[] = "logname\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrint the name of the current user.\n"
|
||||
#endif
|
||||
;
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern int logname_main(int argc, char **argv)
|
||||
{
|
||||
char *user = xmalloc(9);
|
||||
char user[9];
|
||||
|
||||
if (argc > 1)
|
||||
usage(logname_usage);
|
||||
|
||||
my_getpwuid(user, geteuid());
|
||||
if (user) {
|
||||
if (*user) {
|
||||
puts(user);
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
fprintf(stderr, "no login name\n");
|
||||
return(FALSE);
|
||||
error_msg_and_die("no login name\n");
|
||||
}
|
||||
+792
-488
File diff suppressed because it is too large.
Load diff
+39
-98
@@ -20,10 +20,17 @@
|
||||
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
|
||||
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#define FALSE ((int) 1)
|
||||
#define TRUE ((int) 0)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//--------md5.c
|
||||
@@ -58,7 +65,7 @@
|
||||
#include <string.h>
|
||||
#include <endian.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
//----------------------------------------------------------------------------
|
||||
//--------md5.h
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -84,11 +91,11 @@
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _MD5_H
|
||||
#define _MD5_H 1
|
||||
static const int _MD5_H = 1;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined HAVE_LIMITS_H || _LIBC
|
||||
#if defined HAVE_LIMITS_H || defined _LIBC
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
@@ -99,48 +106,8 @@
|
||||
the resulting executable. Locally running cross-compiled executables
|
||||
is usually not possible. */
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <sys/types.h>
|
||||
typedef u_int32_t md5_uint32;
|
||||
#else
|
||||
# if defined __STDC__ && __STDC__
|
||||
# define UINT_MAX_32_BITS 4294967295U
|
||||
# else
|
||||
# define UINT_MAX_32_BITS 0xFFFFFFFF
|
||||
# endif
|
||||
|
||||
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
|
||||
This should be valid for all systems GNU cares about because
|
||||
that doesn't include 16-bit systems, and only modern systems
|
||||
(that certainly have <limits.h>) have 64+-bit integral types. */
|
||||
|
||||
# ifndef UINT_MAX
|
||||
# define UINT_MAX UINT_MAX_32_BITS
|
||||
# endif
|
||||
|
||||
# if UINT_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned int md5_uint32;
|
||||
# else
|
||||
# if USHRT_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned short md5_uint32;
|
||||
# else
|
||||
# if ULONG_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned long md5_uint32;
|
||||
# else
|
||||
/* The following line is intended to evoke an error.
|
||||
Using #error is not portable enough. */
|
||||
"Cannot determine unsigned 32-bit data type."
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#undef __P
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define __P(x) x
|
||||
#else
|
||||
#define __P(x) ()
|
||||
#endif
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
struct md5_ctx
|
||||
@@ -284,7 +251,7 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
|
||||
int md5_stream(FILE *stream, void *resblock)
|
||||
{
|
||||
/* Important: BLOCKSIZE must be a multiple of 64. */
|
||||
#define BLOCKSIZE 4096
|
||||
static const int BLOCKSIZE = 4096;
|
||||
struct md5_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
@@ -562,7 +529,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
/* The minimum length of a valid digest line in a file produced
|
||||
by `md5sum FILE' and read by `md5sum -c'. This length does
|
||||
not include any newline character at the end of a line. */
|
||||
#define MIN_DIGEST_LINE_LENGTH 35 /* 32 - message digest length
|
||||
static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
|
||||
2 - blank and binary indicator
|
||||
1 - minimum filename length */
|
||||
|
||||
@@ -574,23 +541,6 @@ static int status_only = 0; /* With -c, don't generate any output.
|
||||
static int warn = 0; /* With -w, print a message to standard error warning
|
||||
about each improperly formatted MD5 checksum line */
|
||||
|
||||
static const char md5sum_usage[] =
|
||||
"md5sum [OPTION] [FILE]...\n"
|
||||
"or: md5sum [OPTION] -c [FILE]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrint or check MD5 checksums.\n\n"
|
||||
"Options:\n"
|
||||
"With no FILE, or when FILE is -, read standard input.\n\n"
|
||||
"\t-b\tread files in binary mode\n"
|
||||
"\t-c\tcheck MD5 sums against given list\n"
|
||||
"\t-t\tread files in text mode (default)\n"
|
||||
"\t-g\tread a string\n"
|
||||
"\nThe following two options are useful only when verifying checksums:\n"
|
||||
"\t-s,\tdon't output anything, status code shows success\n"
|
||||
"\t-w,\twarn about improperly formated MD5 checksum lines\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
static int split_3(char *s,
|
||||
size_t s_len,
|
||||
unsigned char **u,
|
||||
@@ -700,13 +650,13 @@ static int md5_file(const char *filename,
|
||||
} else {
|
||||
fp = fopen(filename, OPENOPTS(binary));
|
||||
if (fp == NULL) {
|
||||
errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (md5_stream(fp, md5_result)) {
|
||||
errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
@@ -714,7 +664,7 @@ static int md5_file(const char *filename,
|
||||
}
|
||||
|
||||
if (fp != stdin && fclose(fp) == EOF) {
|
||||
errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -729,8 +679,7 @@ static int md5_check(const char *checkfile_name)
|
||||
int n_open_or_read_failures = 0;
|
||||
unsigned char md5buffer[16];
|
||||
size_t line_number;
|
||||
char *line;
|
||||
size_t line_chars_allocated;
|
||||
char line[BUFSIZ];
|
||||
|
||||
if (STREQ(checkfile_name, "-")) {
|
||||
have_read_stdin = 1;
|
||||
@@ -738,14 +687,12 @@ static int md5_check(const char *checkfile_name)
|
||||
} else {
|
||||
checkfile_stream = fopen(checkfile_name, "r");
|
||||
if (checkfile_stream == NULL) {
|
||||
errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
|
||||
perror_msg("%s", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
line_number = 0;
|
||||
line = 0;
|
||||
line_chars_allocated = 0;
|
||||
|
||||
do {
|
||||
char *filename;
|
||||
@@ -755,9 +702,10 @@ static int md5_check(const char *checkfile_name)
|
||||
|
||||
++line_number;
|
||||
|
||||
line_length = getline(&line, &line_chars_allocated, checkfile_stream);
|
||||
fgets(line, BUFSIZ-1, checkfile_stream);
|
||||
line_length = strlen(line);
|
||||
|
||||
if (line_length <= 0)
|
||||
if (line_length <= 0 || line==NULL)
|
||||
break;
|
||||
|
||||
/* Ignore comment lines, which begin with a '#' character. */
|
||||
@@ -771,7 +719,7 @@ static int md5_check(const char *checkfile_name)
|
||||
if (split_3(line, line_length, &md5num, &binary, &filename)
|
||||
|| !hex_digits(md5num)) {
|
||||
if (warn) {
|
||||
errorMsg("%s: %lu: improperly formatted MD5 checksum line\n",
|
||||
error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
|
||||
checkfile_name, (unsigned long) line_number);
|
||||
}
|
||||
} else {
|
||||
@@ -815,22 +763,19 @@ static int md5_check(const char *checkfile_name)
|
||||
|
||||
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
|
||||
|
||||
if (line)
|
||||
free(line);
|
||||
|
||||
if (ferror(checkfile_stream)) {
|
||||
errorMsg("%s: read error", checkfile_name); /* */
|
||||
error_msg("%s: read error\n", checkfile_name); /* */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
|
||||
errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
|
||||
perror_msg("md5sum: %s", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_properly_formated_lines == 0) {
|
||||
/* Warn if no tests are found. */
|
||||
errorMsg("%s: no properly formatted MD5 checksum lines found\n",
|
||||
error_msg("%s: no properly formatted MD5 checksum lines found\n",
|
||||
checkfile_name);
|
||||
return FALSE;
|
||||
} else {
|
||||
@@ -839,13 +784,13 @@ static int md5_check(const char *checkfile_name)
|
||||
- n_open_or_read_failures);
|
||||
|
||||
if (n_open_or_read_failures > 0) {
|
||||
errorMsg("WARNING: %d of %d listed files could not be read\n",
|
||||
error_msg("WARNING: %d of %d listed files could not be read\n",
|
||||
n_open_or_read_failures, n_properly_formated_lines);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_mismatched_checksums > 0) {
|
||||
errorMsg("WARNING: %d of %d computed checksums did NOT match\n",
|
||||
error_msg("WARNING: %d of %d computed checksums did NOT match\n",
|
||||
n_mismatched_checksums, n_computed_checkums);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -910,31 +855,26 @@ int md5sum_main(int argc,
|
||||
}
|
||||
|
||||
if (file_type_specified && do_check) {
|
||||
errorMsg("the -b and -t options are meaningless when verifying checksums\n");
|
||||
exit FALSE;
|
||||
error_msg_and_die("the -b and -t options are meaningless when verifying checksums\n");
|
||||
}
|
||||
|
||||
if (n_strings > 0 && do_check) {
|
||||
errorMsg("the -g and -c options are mutually exclusive\n");
|
||||
exit FALSE;
|
||||
error_msg_and_die("the -g and -c options are mutually exclusive\n");
|
||||
}
|
||||
|
||||
if (status_only && !do_check) {
|
||||
errorMsg("the -s option is meaningful only when verifying checksums\n");
|
||||
exit FALSE;
|
||||
error_msg_and_die("the -s option is meaningful only when verifying checksums\n");
|
||||
}
|
||||
|
||||
if (warn && !do_check) {
|
||||
errorMsg("the -w option is meaningful only when verifying checksums\n");
|
||||
exit FALSE;
|
||||
error_msg_and_die("the -w option is meaningful only when verifying checksums\n");
|
||||
}
|
||||
|
||||
if (n_strings > 0) {
|
||||
size_t i;
|
||||
|
||||
if (optind < argc) {
|
||||
errorMsg("no files may be specified when using -g\n");
|
||||
exit FALSE;
|
||||
error_msg_and_die("no files may be specified when using -g\n");
|
||||
}
|
||||
for (i = 0; i < n_strings; ++i) {
|
||||
size_t cnt;
|
||||
@@ -947,7 +887,7 @@ int md5sum_main(int argc,
|
||||
}
|
||||
} else if (do_check) {
|
||||
if (optind + 1 < argc) {
|
||||
errorMsg("only one argument may be specified when using -c\n");
|
||||
error_msg("only one argument may be specified when using -c\n");
|
||||
}
|
||||
|
||||
err = md5_check ((optind == argc) ? "-" : argv[optind]);
|
||||
@@ -1000,14 +940,15 @@ int md5sum_main(int argc,
|
||||
}
|
||||
|
||||
if (fclose (stdout) == EOF) {
|
||||
errorMsg("write error");
|
||||
exit FALSE;
|
||||
error_msg_and_die("write error\n");
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF) {
|
||||
errorMsg("standard input");
|
||||
exit FALSE;
|
||||
error_msg_and_die("standard input\n");
|
||||
}
|
||||
|
||||
exit (err == 0 ? TRUE : FALSE);
|
||||
if (err == 0)
|
||||
return EXIT_SUCCESS;
|
||||
else
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
+13
-23
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini mkdir implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,25 +21,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#define bb_need_name_too_long
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
static const char mkdir_usage[] =
|
||||
"mkdir [OPTION] DIRECTORY...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreate the DIRECTORY(ies), if they do not already exist\n\n"
|
||||
"Options:\n"
|
||||
|
||||
"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
|
||||
"\t-p\tno error if existing, make parent directories as needed\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int parentFlag = FALSE;
|
||||
static mode_t mode = 0777;
|
||||
@@ -62,8 +52,8 @@ extern int mkdir_main(int argc, char **argv)
|
||||
/* Find the specified modes */
|
||||
mode = 0;
|
||||
if (parse_mode(*(++argv), &mode) == FALSE) {
|
||||
fprintf(stderr, "Unknown mode: %s\n", *argv);
|
||||
exit FALSE;
|
||||
error_msg("Unknown mode: %s\n", *argv);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up whatever the user just entered. */
|
||||
@@ -91,26 +81,26 @@ extern int mkdir_main(int argc, char **argv)
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if (strlen(*argv) > BUFSIZ - 1) {
|
||||
fprintf(stderr, name_too_long, "mkdir");
|
||||
exit FALSE;
|
||||
error_msg(name_too_long);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
strcpy(buf, *argv);
|
||||
status = stat(buf, &statBuf);
|
||||
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
|
||||
fprintf(stderr, "%s: File exists\n", buf);
|
||||
exit FALSE;
|
||||
error_msg("%s: File exists\n", buf);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (parentFlag == TRUE) {
|
||||
strcat(buf, "/");
|
||||
createPath(buf, mode);
|
||||
create_path(buf, mode);
|
||||
} else {
|
||||
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
|
||||
perror(buf);
|
||||
exit FALSE;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+5
-15
@@ -20,19 +20,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
static const char mkfifo_usage[] = "mkfifo [OPTIONS] name\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreates a named pipe (identical to 'mknod name p')\n\n"
|
||||
"Options:\n"
|
||||
"\t-m\tcreate the pipe using the specified mode (default a=rw)\n"
|
||||
#endif
|
||||
;
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int mkfifo_main(int argc, char **argv)
|
||||
{
|
||||
@@ -62,9 +54,7 @@ extern int mkfifo_main(int argc, char **argv)
|
||||
}
|
||||
if (argc < 1 || *argv[0] == '-')
|
||||
usage(mkfifo_usage);
|
||||
if (mkfifo(*argv, mode) < 0) {
|
||||
perror("mkfifo");
|
||||
exit(255);
|
||||
}
|
||||
return(TRUE);
|
||||
if (mkfifo(*argv, mode) < 0)
|
||||
perror_msg_and_die("mkfifo");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+5
-16
@@ -20,25 +20,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static const char mknod_usage[] = "mknod [OPTIONS] NAME TYPE MAJOR MINOR\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreate a special file (block, character, or pipe).\n\n"
|
||||
"Options:\n"
|
||||
"\t-m\tcreate the special file using the specified mode (default a=rw)\n\n"
|
||||
"TYPEs include:\n"
|
||||
"\tb:\tMake a block (buffered) device.\n"
|
||||
"\tc or u:\tMake a character (un-buffered) device.\n"
|
||||
"\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n"
|
||||
#endif
|
||||
;
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int mknod_main(int argc, char **argv)
|
||||
{
|
||||
@@ -97,7 +86,7 @@ int mknod_main(int argc, char **argv)
|
||||
mode |= perm;
|
||||
|
||||
if (mknod(argv[0], mode, dev) != 0)
|
||||
fatalError("%s: %s\n", argv[0], strerror(errno));
|
||||
return (TRUE);
|
||||
perror_msg_and_die("%s", argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+2
-10
@@ -47,11 +47,10 @@
|
||||
|
||||
// 19990508 Busy Boxed! Dave Cinege
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
@@ -60,7 +59,7 @@
|
||||
|
||||
|
||||
#ifndef S_IFMT
|
||||
# define S_IFMT 0170000
|
||||
static const int S_IFMT = 0170000;
|
||||
#endif
|
||||
#if !defined(S_ISBLK) && defined(S_IFBLK)
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
@@ -137,13 +136,6 @@ static void verify __P((char *s, char *end));
|
||||
/* The value to return to the calling program. */
|
||||
static int exit_status;
|
||||
|
||||
static const char printf_usage[] = "printf FORMAT [ARGUMENT...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nFormats and prints ARGUMENT(s) according to FORMAT,\n"
|
||||
"Where FORMAT controls the output exactly as in C printf.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int printf_main(int argc, char **argv)
|
||||
{
|
||||
char *format;
|
||||
|
||||
+6
-4
@@ -21,18 +21,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int pwd_main(int argc, char **argv)
|
||||
{
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if (getcwd(buf, sizeof(buf)) == NULL)
|
||||
fatalError("pwd: %s\n", strerror(errno));
|
||||
perror_msg_and_die("getcwd");
|
||||
|
||||
printf("%s\n", buf);
|
||||
return(TRUE);
|
||||
puts(buf);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+15
-18
@@ -3,7 +3,7 @@
|
||||
* Mini rm implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,23 +22,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
static const char *rm_usage = "rm [OPTION]... FILE...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRemove (unlink) the FILE(s). You may use '--' to\n"
|
||||
"indicate that all following arguments are non-options.\n\n"
|
||||
"Options:\n"
|
||||
"\t-f\t\tremove existing destinations, never prompt\n"
|
||||
"\t-r or -R\tremove the contents of directories recursively\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int recursiveFlag = FALSE;
|
||||
static int forceFlag = FALSE;
|
||||
@@ -48,7 +39,7 @@ static const char *srcName;
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (unlink(fileName) < 0) {
|
||||
perror(fileName);
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
@@ -56,8 +47,13 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (recursiveFlag == FALSE) {
|
||||
errno = EISDIR;
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
if (rmdir(fileName) < 0) {
|
||||
perror(fileName);
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
@@ -65,6 +61,7 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
extern int rm_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int stopIt=FALSE;
|
||||
struct stat statbuf;
|
||||
|
||||
@@ -106,11 +103,11 @@ extern int rm_main(int argc, char **argv)
|
||||
&& errno == ENOENT) {
|
||||
/* do not reports errors for non-existent files if -f, just skip them */
|
||||
} else {
|
||||
if (recursiveAction(srcName, recursiveFlag, FALSE,
|
||||
if (recursive_action(srcName, recursiveFlag, FALSE,
|
||||
TRUE, fileAction, dirAction, NULL) == FALSE) {
|
||||
exit(FALSE);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
+11
-14
@@ -3,7 +3,7 @@
|
||||
* Mini rmdir implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,27 +22,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 1 || **(argv + 1) == '-') {
|
||||
usage
|
||||
("rmdir [OPTION]... DIRECTORY...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRemove the DIRECTORY(ies), if they are empty.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
usage(rmdir_usage);
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
fprintf(stderr, "%s: %s\n", *argv, strerror(errno));
|
||||
exit(FALSE);
|
||||
perror_msg("%s", *argv);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
+6
-12
@@ -21,14 +21,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char sleep_usage[] = "sleep N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPause for N seconds.\n"
|
||||
#endif
|
||||
;
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int sleep_main(int argc, char **argv)
|
||||
{
|
||||
@@ -36,9 +32,7 @@ extern int sleep_main(int argc, char **argv)
|
||||
usage(sleep_usage);
|
||||
}
|
||||
|
||||
if (sleep(atoi(*(++argv))) != 0) {
|
||||
perror("sleep");
|
||||
exit(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
if (sleep(atoi(*(++argv))) != 0)
|
||||
perror_msg_and_die("sleep");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+40
-258
@@ -3,8 +3,7 @@
|
||||
* Mini sort implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,286 +21,69 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char sort_usage[] = "sort [-n]"
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
" [-r]"
|
||||
#endif
|
||||
" [FILE]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nSorts lines of text in the specified files\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
|
||||
static int reverse = 0;
|
||||
#else
|
||||
#define APPLY_REVERSE(x) (x)
|
||||
#endif
|
||||
|
||||
/* typedefs _______________________________________________________________ */
|
||||
|
||||
/* line node */
|
||||
typedef struct Line {
|
||||
char *data; /* line data */
|
||||
struct Line *next; /* pointer to next line node */
|
||||
} Line;
|
||||
|
||||
/* singly-linked list of lines */
|
||||
typedef struct {
|
||||
int len; /* number of Lines */
|
||||
Line **sorted; /* array fed to qsort */
|
||||
Line *head; /* head of List */
|
||||
Line *current; /* current Line */
|
||||
} List;
|
||||
|
||||
/* comparison function */
|
||||
typedef int (Compare) (const void *, const void *);
|
||||
|
||||
|
||||
/* methods ________________________________________________________________ */
|
||||
|
||||
static const int max = 1024;
|
||||
|
||||
/* mallocate Line */
|
||||
static Line *line_alloc()
|
||||
int compare_ascii(const void *x, const void *y)
|
||||
{
|
||||
Line *self;
|
||||
self = malloc(1 * sizeof(Line));
|
||||
return self;
|
||||
return strcmp(*(char **)x, *(char **)y);
|
||||
}
|
||||
|
||||
/* Construct Line from FILE* */
|
||||
static Line *line_newFromFile(FILE * src)
|
||||
int compare_numeric(const void *x, const void *y)
|
||||
{
|
||||
Line *self;
|
||||
char *cstring = NULL;
|
||||
|
||||
if ((cstring = cstring_lineFromFile(src))) {
|
||||
self = line_alloc();
|
||||
if (self == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
self->data = cstring;
|
||||
self->next = NULL;
|
||||
return self;
|
||||
}
|
||||
return NULL;
|
||||
return atoi(*(char **)x) - atoi(*(char **)y);
|
||||
}
|
||||
|
||||
/* Line destructor */
|
||||
static Line *line_release(Line * self)
|
||||
{
|
||||
if (self->data) {
|
||||
free(self->data);
|
||||
free(self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/* Comparison */
|
||||
|
||||
/* ascii order */
|
||||
static int compare_ascii(const void *a, const void *b)
|
||||
{
|
||||
Line **doh;
|
||||
Line *x, *y;
|
||||
|
||||
doh = (Line **) a;
|
||||
x = *doh;
|
||||
doh = (Line **) b;
|
||||
y = *doh;
|
||||
|
||||
// fprintf(stdout, "> %p: %s< %p: %s", x, x->data, y, y->data);
|
||||
return APPLY_REVERSE(strcmp(x->data, y->data));
|
||||
}
|
||||
|
||||
/* numeric order */
|
||||
static int compare_numeric(const void *a, const void *b)
|
||||
{
|
||||
Line **doh;
|
||||
Line *x, *y;
|
||||
int xint, yint;
|
||||
|
||||
doh = (Line **) a;
|
||||
x = *doh;
|
||||
doh = (Line **) b;
|
||||
y = *doh;
|
||||
|
||||
xint = strtoul(x->data, NULL, 10);
|
||||
yint = strtoul(y->data, NULL, 10);
|
||||
|
||||
return APPLY_REVERSE(xint - yint);
|
||||
}
|
||||
|
||||
|
||||
/* List */
|
||||
|
||||
/* */
|
||||
static List *list_init(List * self)
|
||||
{
|
||||
self->len = 0;
|
||||
self->sorted = NULL;
|
||||
self->head = NULL;
|
||||
self->current = NULL;
|
||||
return self;
|
||||
}
|
||||
|
||||
/* for simplicity, the List gains ownership of the line */
|
||||
static List *list_insert(List * self, Line * line)
|
||||
{
|
||||
if (line == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* first insertion */
|
||||
if (self->head == NULL) {
|
||||
self->head = line;
|
||||
self->current = line;
|
||||
|
||||
/* all subsequent insertions */
|
||||
} else {
|
||||
self->current->next = line;
|
||||
self->current = line;
|
||||
}
|
||||
self->len++;
|
||||
return self;
|
||||
}
|
||||
|
||||
/* order the list according to compare() */
|
||||
static List *list_sort(List * self, Compare * compare)
|
||||
{
|
||||
int i;
|
||||
Line *line;
|
||||
|
||||
/* mallocate array of Line*s */
|
||||
self->sorted = (Line **) malloc(self->len * sizeof(Line *));
|
||||
if (self->sorted == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* fill array w/ List's contents */
|
||||
i = 0;
|
||||
line = self->head;
|
||||
while (line) {
|
||||
self->sorted[i++] = line;
|
||||
line = line->next;
|
||||
}
|
||||
|
||||
/* apply qsort */
|
||||
qsort(self->sorted, self->len, sizeof(Line *), compare);
|
||||
return self;
|
||||
}
|
||||
|
||||
/* precondition: list must be sorted */
|
||||
static List *list_writeToFile(List * self, FILE * dst)
|
||||
{
|
||||
int i;
|
||||
Line **line = self->sorted;
|
||||
|
||||
if (self->sorted == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < self->len; i++) {
|
||||
fprintf(dst, "%s", line[i]->data);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/* deallocate */
|
||||
static void list_release(List * self)
|
||||
{
|
||||
Line *i;
|
||||
Line *die;
|
||||
|
||||
i = self->head;
|
||||
while (i) {
|
||||
die = i;
|
||||
i = die->next;
|
||||
line_release(die);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int sort_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char opt;
|
||||
List list;
|
||||
Line *l;
|
||||
Compare *compare;
|
||||
FILE *fp;
|
||||
char *line, **lines = NULL;
|
||||
int i, opt, nlines = 0;
|
||||
int (*compare)(const void *, const void *) = compare_ascii;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
int reverse = FALSE;
|
||||
#endif
|
||||
|
||||
/* init */
|
||||
compare = compare_ascii;
|
||||
list_init(&list);
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
usage(sort_usage);
|
||||
break;
|
||||
while ((opt = getopt(argc, argv, "nr")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
/* numeric comparison */
|
||||
compare = compare_numeric;
|
||||
break;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
case 'r':
|
||||
/* reverse */
|
||||
reverse = 1;
|
||||
reverse = TRUE;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
fprintf(stderr, "sort: invalid option -- %c\n", opt);
|
||||
usage(sort_usage);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* this could be factored better */
|
||||
/* read the input */
|
||||
for (i = optind; i == optind || i < argc; i++) {
|
||||
if (argv[i] == NULL)
|
||||
fp = stdin;
|
||||
else
|
||||
fp = xfopen(argv[i], "r");
|
||||
|
||||
/* work w/ stdin */
|
||||
if (i >= argc) {
|
||||
while ((l = line_newFromFile(stdin))) {
|
||||
list_insert(&list, l);
|
||||
while ((line = get_line_from_file(fp)) != NULL) {
|
||||
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
|
||||
lines[nlines++] = line;
|
||||
}
|
||||
list_sort(&list, compare);
|
||||
list_writeToFile(&list, stdout);
|
||||
list_release(&list);
|
||||
|
||||
/* work w/ what's left in argv[] */
|
||||
} else {
|
||||
FILE *src;
|
||||
|
||||
for (; i < argc; i++) {
|
||||
src = fopen(argv[i], "r");
|
||||
if (src == NULL) {
|
||||
break;
|
||||
}
|
||||
while ((l = line_newFromFile(src))) {
|
||||
list_insert(&list, l);
|
||||
}
|
||||
fclose(src);
|
||||
}
|
||||
list_sort(&list, compare);
|
||||
list_writeToFile(&list, stdout);
|
||||
list_release(&list);
|
||||
}
|
||||
|
||||
return(0);
|
||||
/* sort it */
|
||||
qsort(lines, nlines, sizeof(char *), compare);
|
||||
|
||||
/* print it */
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
if (reverse)
|
||||
for (i = nlines - 1; 0 <= i; i--)
|
||||
fputs(lines[i], stdout);
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < nlines; i++)
|
||||
fputs(lines[i], stdout);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* $Id: sort.c,v 1.17 2000/06/19 17:25:40 andersen Exp $ */
|
||||
+4
-8
@@ -21,17 +21,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern int sync_main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1 && **(argv + 1) == '-') {
|
||||
usage("sync\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nWrite all buffered filesystem blocks to disk.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage(sync_usage);
|
||||
return(sync());
|
||||
}
|
||||
+220
-1196
File diff suppressed because it is too large.
Load diff
+33
-101
@@ -2,9 +2,8 @@
|
||||
/*
|
||||
* Mini tee implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,115 +21,48 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static const char tee_usage[] =
|
||||
"tee [OPTION]... [FILE]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCopy standard input to each FILE, and also to standard output.\n\n"
|
||||
"Options:\n" "\t-a\tappend to the given FILEs, do not overwrite\n"
|
||||
#if 0
|
||||
"\t-i\tignore interrupt signals\n"
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
/* FileList _______________________________________________________________ */
|
||||
|
||||
#define FL_MAX 1024
|
||||
static FILE **FileList;
|
||||
static int FL_end;
|
||||
|
||||
typedef void (FL_Function) (FILE * file, char c);
|
||||
|
||||
|
||||
/* apply a function to everything in FileList */
|
||||
static void FL_apply(FL_Function * f, char c)
|
||||
int
|
||||
tee_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char *mode = "w";
|
||||
int c, i, status = 0, nfiles = 0;
|
||||
FILE **files;
|
||||
|
||||
for (i = 0; i <= FL_end; i++) {
|
||||
f(FileList[i], c);
|
||||
}
|
||||
}
|
||||
|
||||
/* FL_Function for writing to files*/
|
||||
static void tee_fwrite(FILE * file, char c)
|
||||
{
|
||||
fputc(c, file);
|
||||
}
|
||||
|
||||
/* FL_Function for closing files */
|
||||
static void tee_fclose(FILE * file, char c)
|
||||
{
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
/* ________________________________________________________________________ */
|
||||
|
||||
/* BusyBoxed tee(1) */
|
||||
int tee_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
char opt;
|
||||
char opt_fopen[2] = "w";
|
||||
FILE *file;
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
opt_fopen[0] = 'a';
|
||||
break;
|
||||
#if 0
|
||||
case 'i':
|
||||
fprintf(stderr, "ignore interrupt not implemented\n");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
usage(tee_usage);
|
||||
}
|
||||
} else {
|
||||
while ((c = getopt(argc, argv, "a")) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
mode = "a";
|
||||
break;
|
||||
default:
|
||||
usage(tee_usage);
|
||||
}
|
||||
}
|
||||
|
||||
/* init FILE pointers */
|
||||
FileList = calloc(FL_MAX, sizeof(FILE*));
|
||||
if (!FileList) {
|
||||
fprintf(stderr, "tee: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
FL_end = 0;
|
||||
FileList[0] = stdout;
|
||||
for (; i < argc; i++) {
|
||||
/* add a file to FileList */
|
||||
file = fopen(argv[i], opt_fopen);
|
||||
if (!file) {
|
||||
continue;
|
||||
}
|
||||
if (FL_end < FL_MAX) {
|
||||
FileList[++FL_end] = file;
|
||||
files = (FILE **)xmalloc(sizeof(FILE *) * (argc - optind + 1));
|
||||
files[nfiles++] = stdout;
|
||||
while (optind < argc) {
|
||||
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
|
||||
nfiles--;
|
||||
perror_msg("%s", argv[optind-1]);
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* read and redirect */
|
||||
while ((c = (char) getchar()) && (!feof(stdin))) {
|
||||
FL_apply(tee_fwrite, c);
|
||||
}
|
||||
while ((c = getchar()) != EOF)
|
||||
for (i = 0; i < nfiles; i++)
|
||||
putc(c, files[i]);
|
||||
|
||||
/* clean up */
|
||||
FL_apply(tee_fclose, 0);
|
||||
/* Don't bother to close files Exit does that
|
||||
* automagically, so we can save a few bytes */
|
||||
/* free(FileList); */
|
||||
return(0);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* $Id: tee.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+12
-25
@@ -31,9 +31,8 @@
|
||||
* "This program is in the Public Domain."
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@@ -157,8 +156,8 @@ struct t_op {
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
char **t_wp;
|
||||
struct t_op const *t_wp_op;
|
||||
static char **t_wp;
|
||||
static struct t_op const *t_wp_op;
|
||||
static gid_t *group_array = NULL;
|
||||
static int ngroups;
|
||||
|
||||
@@ -183,21 +182,11 @@ test_main(int argc, char** argv)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (strcmp(argv[0], "[") == 0) {
|
||||
if (strcmp(applet_name, "[") == 0) {
|
||||
if (strcmp(argv[--argc], "]"))
|
||||
fatalError("missing ]\n");
|
||||
error_msg_and_die("missing ]\n");
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
if (strcmp(argv[1], dash_dash_help) == 0) {
|
||||
usage("test EXPRESSION\n"
|
||||
"or [ EXPRESSION ]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nChecks file types and compares values returning an exit\n"
|
||||
"code determined by the value of EXPRESSION.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
/* Implement special cases from POSIX.2, section 4.62.4 */
|
||||
switch (argc) {
|
||||
case 1:
|
||||
@@ -244,9 +233,9 @@ syntax(op, msg)
|
||||
char *msg;
|
||||
{
|
||||
if (op && *op)
|
||||
fatalError("%s: %s\n", op, msg);
|
||||
error_msg_and_die("%s: %s\n", op, msg);
|
||||
else
|
||||
fatalError("%s\n", msg);
|
||||
error_msg_and_die("%s\n", msg);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -372,7 +361,7 @@ filstat(nm, mode)
|
||||
enum token mode;
|
||||
{
|
||||
struct stat s;
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
if (mode == FILSYM) {
|
||||
#ifdef S_IFLNK
|
||||
@@ -481,13 +470,13 @@ getn(s)
|
||||
r = strtol(s, &p, 10);
|
||||
|
||||
if (errno != 0)
|
||||
fatalError("%s: out of range\n", s);
|
||||
error_msg_and_die("%s: out of range\n", s);
|
||||
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
|
||||
if (*p)
|
||||
fatalError("%s: bad number\n", s);
|
||||
error_msg_and_die("%s: bad number\n", s);
|
||||
|
||||
return (int) r;
|
||||
}
|
||||
@@ -535,7 +524,7 @@ char *path;
|
||||
int mode;
|
||||
{
|
||||
struct stat st;
|
||||
int euid = geteuid();
|
||||
unsigned int euid = geteuid();
|
||||
|
||||
if (stat (path, &st) < 0)
|
||||
return (-1);
|
||||
@@ -566,9 +555,7 @@ static void
|
||||
initialize_group_array ()
|
||||
{
|
||||
ngroups = getgroups(0, NULL);
|
||||
if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL)
|
||||
fatalError("Out of space\n");
|
||||
|
||||
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
|
||||
getgroups(ngroups, group_array);
|
||||
}
|
||||
|
||||
|
||||
+8
-18
@@ -3,7 +3,7 @@
|
||||
* Mini touch implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,23 +22,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <utime.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
static const char touch_usage[] = "touch [-c] file [file ...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nUpdate the last-modified date on the given file[s].\n\n"
|
||||
"Options:\n"
|
||||
"\t-c\tDo not create any files\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int touch_main(int argc, char **argv)
|
||||
{
|
||||
@@ -54,7 +45,6 @@ extern int touch_main(int argc, char **argv)
|
||||
break;
|
||||
default:
|
||||
usage(touch_usage);
|
||||
exit(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,18 +58,18 @@ extern int touch_main(int argc, char **argv)
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (fd < 0) {
|
||||
if (create == FALSE && errno == ENOENT)
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
else {
|
||||
fatalError("touch: %s", strerror(errno));
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
if (utime(*argv, NULL)) {
|
||||
fatalError("touch: %s", strerror(errno));
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+61
-70
@@ -24,7 +24,7 @@
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
@@ -34,34 +34,15 @@
|
||||
#define bb_need_write_error
|
||||
#include "messages.c"
|
||||
|
||||
const char *tr_usage="tr [-cds] STRING1 [STRING2]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nTranslate, squeeze, and/or delete characters from\n"
|
||||
"standard input, writing to standard output.\n\n"
|
||||
"Options:\n"
|
||||
"\t-c\ttake complement of STRING1\n"
|
||||
"\t-d\tdelete input characters coded STRING1\n"
|
||||
"\t-s\tsqueeze multiple output characters of STRING2 into one character\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
|
||||
#ifdef TRUE
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define ASCII 0377
|
||||
static const int ASCII = 0377;
|
||||
|
||||
/* some glabals shared across this file */
|
||||
static char com_fl, del_fl, sq_fl;
|
||||
static unsigned char output[BUFSIZ], input[BUFSIZ];
|
||||
static unsigned char vector[ASCII + 1];
|
||||
static char invec[ASCII + 1], outvec[ASCII + 1];
|
||||
static short in_index, out_index;
|
||||
/* these last are pointers to static buffers declared in tr_main */
|
||||
static unsigned char *poutput, *pinput;
|
||||
static unsigned char *pvector;
|
||||
static char *pinvec, *poutvec;
|
||||
|
||||
|
||||
static void convert()
|
||||
@@ -72,22 +53,22 @@ static void convert()
|
||||
|
||||
for (;;) {
|
||||
if (in_index == read_chars) {
|
||||
if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) {
|
||||
if (write(1, (char *) output, out_index) != out_index)
|
||||
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
|
||||
if (write(1, (char *) poutput, out_index) != out_index)
|
||||
write(2, write_error, strlen(write_error));
|
||||
exit(0);
|
||||
}
|
||||
in_index = 0;
|
||||
}
|
||||
c = input[in_index++];
|
||||
coded = vector[c];
|
||||
if (del_fl && invec[c])
|
||||
c = pinput[in_index++];
|
||||
coded = pvector[c];
|
||||
if (del_fl && pinvec[c])
|
||||
continue;
|
||||
if (sq_fl && last == coded && outvec[coded])
|
||||
if (sq_fl && last == coded && (pinvec[c] || poutvec[coded]))
|
||||
continue;
|
||||
output[out_index++] = last = coded;
|
||||
poutput[out_index++] = last = coded;
|
||||
if (out_index == BUFSIZ) {
|
||||
if (write(1, (char *) output, out_index) != out_index) {
|
||||
if (write(1, (char *) poutput, out_index) != out_index) {
|
||||
write(2, write_error, strlen(write_error));
|
||||
exit(1);
|
||||
}
|
||||
@@ -98,35 +79,29 @@ static void convert()
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static void map(register unsigned char *string1, register unsigned char *string2)
|
||||
static void map(register unsigned char *string1, unsigned int string1_len,
|
||||
register unsigned char *string2, unsigned int string2_len)
|
||||
{
|
||||
unsigned char last = '0';
|
||||
unsigned int i, j;
|
||||
|
||||
while (*string1) {
|
||||
if (*string2 == '\0')
|
||||
vector[*string1] = last;
|
||||
for (j = 0, i = 0; i < string1_len; i++) {
|
||||
if (string2_len <= j)
|
||||
pvector[string1[i]] = last;
|
||||
else
|
||||
vector[*string1] = last = *string2++;
|
||||
string1++;
|
||||
pvector[string1[i]] = last = string2[j++];
|
||||
}
|
||||
}
|
||||
|
||||
static void expand(register char *arg, register unsigned char *buffer)
|
||||
static unsigned int expand(char *arg, register unsigned char *buffer)
|
||||
{
|
||||
unsigned char *buffer_start = buffer;
|
||||
int i, ac;
|
||||
|
||||
while (*arg) {
|
||||
if (*arg == '\\') {
|
||||
arg++;
|
||||
i = ac = 0;
|
||||
if (*arg >= '0' && *arg <= '7') {
|
||||
do {
|
||||
ac = (ac << 3) + *arg++ - '0';
|
||||
i++;
|
||||
} while (i < 4 && *arg >= '0' && *arg <= '7');
|
||||
*buffer++ = ac;
|
||||
} else if (*arg != '\0')
|
||||
*buffer++ = *arg++;
|
||||
*buffer++ = process_escape_sequence(&arg);
|
||||
} else if (*arg == '[') {
|
||||
arg++;
|
||||
i = *arg++;
|
||||
@@ -142,31 +117,45 @@ static void expand(register char *arg, register unsigned char *buffer)
|
||||
} else
|
||||
*buffer++ = *arg++;
|
||||
}
|
||||
|
||||
return (buffer - buffer_start);
|
||||
}
|
||||
|
||||
static void complement(unsigned char *buffer)
|
||||
static int complement(unsigned char *buffer, int buffer_len)
|
||||
{
|
||||
register unsigned char *ptr;
|
||||
register short i, index;
|
||||
unsigned char conv[ASCII + 2];
|
||||
register short i, j, index;
|
||||
char conv[ASCII + 2];
|
||||
|
||||
index = 0;
|
||||
for (i = 1; i <= ASCII; i++) {
|
||||
for (ptr = buffer; *ptr; ptr++)
|
||||
if (*ptr == i)
|
||||
for (i = 0; i <= ASCII; i++) {
|
||||
for (j = 0; j < buffer_len; j++)
|
||||
if (buffer[j] == i)
|
||||
break;
|
||||
if (*ptr == '\0')
|
||||
if (j == buffer_len)
|
||||
conv[index++] = i & ASCII;
|
||||
}
|
||||
conv[index] = '\0';
|
||||
strcpy((char *) buffer, (char *) conv);
|
||||
memcpy(buffer, conv, index);
|
||||
return index;
|
||||
}
|
||||
|
||||
extern int tr_main(int argc, char **argv)
|
||||
{
|
||||
register unsigned char *ptr;
|
||||
int output_length=0, input_length;
|
||||
int index = 1;
|
||||
short i;
|
||||
int i;
|
||||
RESERVE_BB_BUFFER(output, BUFSIZ);
|
||||
RESERVE_BB_BUFFER(input, BUFSIZ);
|
||||
RESERVE_BB_UBUFFER(vector, ASCII+1);
|
||||
RESERVE_BB_BUFFER(invec, ASCII+1);
|
||||
RESERVE_BB_BUFFER(outvec, ASCII+1);
|
||||
|
||||
/* ... but make them available globally */
|
||||
poutput = output;
|
||||
pinput = input;
|
||||
pvector = vector;
|
||||
pinvec = invec;
|
||||
poutvec = outvec;
|
||||
|
||||
if (argc > 1 && argv[index][0] == '-') {
|
||||
for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
|
||||
@@ -192,17 +181,19 @@ extern int tr_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (argv[index] != NULL) {
|
||||
expand(argv[index++], input);
|
||||
input_length = expand(argv[index++], input);
|
||||
if (com_fl)
|
||||
complement(input);
|
||||
if (argv[index] != NULL)
|
||||
expand(argv[index], output);
|
||||
if (argv[index] != NULL)
|
||||
map(input, output);
|
||||
for (ptr = input; *ptr; ptr++)
|
||||
invec[*ptr] = TRUE;
|
||||
for (ptr = output; *ptr; ptr++)
|
||||
outvec[*ptr] = TRUE;
|
||||
input_length = complement(input, input_length);
|
||||
if (argv[index] != NULL) {
|
||||
if (*argv[index] == '\0')
|
||||
error_msg_and_die("STRING2 cannot be empty\n");
|
||||
output_length = expand(argv[index], output);
|
||||
map(input, input_length, output, output_length);
|
||||
}
|
||||
for (i = 0; i < input_length; i++)
|
||||
invec[(int)input[i]] = TRUE;
|
||||
for (i = 0; i < output_length; i++)
|
||||
outvec[(int)output[i]] = TRUE;
|
||||
}
|
||||
convert();
|
||||
return (0);
|
||||
|
||||
+4
-10
@@ -20,18 +20,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static const char tty_usage[] = "tty\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrint the file name of the terminal connected to standard input.\n\n"
|
||||
"Options:\n"
|
||||
"\t-s\tprint nothing, only return an exit status\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int tty_main(int argc, char **argv)
|
||||
{
|
||||
char *tty;
|
||||
@@ -46,5 +40,5 @@ extern int tty_main(int argc, char **argv)
|
||||
else
|
||||
puts("not a tty");
|
||||
}
|
||||
return(isatty(0) ? TRUE : FALSE);
|
||||
return(isatty(0) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
+11
-28
@@ -31,8 +31,9 @@
|
||||
|
||||
/* Busyboxed by Erik Andersen */
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
@@ -40,44 +41,26 @@
|
||||
# include <sys/systeminfo.h>
|
||||
#endif
|
||||
|
||||
|
||||
static const char uname_usage[] =
|
||||
"uname [OPTION]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrint certain system information. With no OPTION, same as -s.\n\n"
|
||||
"Options:\n"
|
||||
"\t-a\tprint all information\n"
|
||||
"\t-m\tthe machine (hardware) type\n"
|
||||
"\t-n\tprint the machine's network node hostname\n"
|
||||
"\t-r\tprint the operating system release\n"
|
||||
"\t-s\tprint the operating system name\n"
|
||||
|
||||
"\t-p\tprint the host processor type\n"
|
||||
"\t-v\tprint the operating system version\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
static void print_element(unsigned int mask, char *element);
|
||||
|
||||
/* Values that are bitwise or'd into `toprint'. */
|
||||
/* Operating system name. */
|
||||
#define PRINT_SYSNAME 1
|
||||
static const int PRINT_SYSNAME = 1;
|
||||
|
||||
/* Node name on a communications network. */
|
||||
#define PRINT_NODENAME 2
|
||||
static const int PRINT_NODENAME = 2;
|
||||
|
||||
/* Operating system release. */
|
||||
#define PRINT_RELEASE 4
|
||||
static const int PRINT_RELEASE = 4;
|
||||
|
||||
/* Operating system version. */
|
||||
#define PRINT_VERSION 8
|
||||
static const int PRINT_VERSION = 8;
|
||||
|
||||
/* Machine hardware name. */
|
||||
#define PRINT_MACHINE 16
|
||||
static const int PRINT_MACHINE = 16;
|
||||
|
||||
/* Host processor type. */
|
||||
#define PRINT_PROCESSOR 32
|
||||
static const int PRINT_PROCESSOR = 32;
|
||||
|
||||
/* Mask indicating which elements of the name to print. */
|
||||
static unsigned char toprint;
|
||||
@@ -132,11 +115,11 @@ int uname_main(int argc, char **argv)
|
||||
toprint = PRINT_SYSNAME;
|
||||
|
||||
if (uname(&name) == -1)
|
||||
perror("cannot get system name");
|
||||
perror_msg("cannot get system name");
|
||||
|
||||
#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE)
|
||||
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
|
||||
perror("cannot get processor type");
|
||||
perror_msg("cannot get processor type");
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -156,7 +139,7 @@ int uname_main(int argc, char **argv)
|
||||
print_element(PRINT_MACHINE, name.machine);
|
||||
print_element(PRINT_PROCESSOR, processor);
|
||||
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* If the name element set in MASK is selected for printing in `toprint',
|
||||
|
||||
+46
-147
@@ -3,8 +3,9 @@
|
||||
* Mini uniq implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Rewritten by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,169 +23,67 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char uniq_usage[] =
|
||||
"uniq [OPTION]... [INPUT [OUTPUT]]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDiscard all but one of successive identical lines from INPUT\n"
|
||||
"(or standard input), writing to OUTPUT (or standard output).\n"
|
||||
#endif
|
||||
;
|
||||
static int print_count;
|
||||
static int print_uniq = 1;
|
||||
static int print_duplicates = 1;
|
||||
|
||||
/* max chars in line */
|
||||
#define UNIQ_MAX 4096
|
||||
|
||||
typedef void (Print) (FILE *, const char *);
|
||||
|
||||
typedef int (Decide) (const char *, const char *);
|
||||
|
||||
/* container for two lines to be compared */
|
||||
typedef struct {
|
||||
char *a;
|
||||
char *b;
|
||||
int recurrence;
|
||||
FILE *in;
|
||||
FILE *out;
|
||||
void *func;
|
||||
} Subject;
|
||||
|
||||
/* set up all the variables of a uniq operation */
|
||||
static Subject *subject_init(Subject * self, FILE * in, FILE * out,
|
||||
void *func)
|
||||
static void print_line(char *line, int count, FILE *fp)
|
||||
{
|
||||
self->a = NULL;
|
||||
self->b = NULL;
|
||||
self->in = in;
|
||||
self->out = out;
|
||||
self->func = func;
|
||||
self->recurrence = 0;
|
||||
return self;
|
||||
if ((print_duplicates && count > 1) || (print_uniq && count == 1)) {
|
||||
if (print_count)
|
||||
fprintf(fp, "%7d\t%s", count, line);
|
||||
else
|
||||
fputs(line, fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* point a and b to the appropriate lines;
|
||||
* count the recurrences (if any) of a string;
|
||||
*/
|
||||
static Subject *subject_next(Subject * self)
|
||||
{
|
||||
/* tmp line holders */
|
||||
static char line[2][UNIQ_MAX];
|
||||
static int alternator = 0;
|
||||
|
||||
if (fgets(line[alternator], UNIQ_MAX, self->in)) {
|
||||
self->a = self->b;
|
||||
self->b = line[alternator];
|
||||
alternator ^= 1;
|
||||
return self;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Subject *subject_last(Subject * self)
|
||||
{
|
||||
self->a = self->b;
|
||||
self->b = NULL;
|
||||
return self;
|
||||
}
|
||||
|
||||
static Subject *subject_study(Subject * self)
|
||||
{
|
||||
if (self->a == NULL) {
|
||||
return self;
|
||||
}
|
||||
if (self->b == NULL) {
|
||||
fprintf(self->out, "%s", self->a);
|
||||
return self;
|
||||
}
|
||||
if (strcmp(self->a, self->b) == 0) {
|
||||
self->recurrence++;
|
||||
} else {
|
||||
fprintf(self->out, "%s", self->a);
|
||||
self->recurrence = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static int
|
||||
set_file_pointers(int schema, FILE ** in, FILE ** out, char **argv)
|
||||
{
|
||||
switch (schema) {
|
||||
case 0:
|
||||
*in = stdin;
|
||||
*out = stdout;
|
||||
break;
|
||||
case 1:
|
||||
*in = fopen(argv[0], "r");
|
||||
*out = stdout;
|
||||
break;
|
||||
case 2:
|
||||
*in = fopen(argv[0], "r");
|
||||
*out = fopen(argv[1], "w");
|
||||
break;
|
||||
}
|
||||
if (*in == NULL) {
|
||||
fprintf(stderr, "uniq: %s: %s\n", argv[0], strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
if (*out == NULL) {
|
||||
fprintf(stderr, "uniq: %s: %s\n", argv[1], strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* one variable is the decision algo */
|
||||
/* another variable is the printing algo */
|
||||
|
||||
/* I don't think I have to have more than a 1 line memory
|
||||
this is the one constant */
|
||||
|
||||
/* it seems like GNU/uniq only takes one or two files as an option */
|
||||
|
||||
/* ________________________________________________________________________ */
|
||||
int uniq_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char opt;
|
||||
FILE *in, *out;
|
||||
Subject s;
|
||||
FILE *in = stdin, *out = stdout;
|
||||
char *lastline = NULL, *input;
|
||||
int opt, count = 0;
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
case '-':
|
||||
case 'h':
|
||||
usage(uniq_usage);
|
||||
default:
|
||||
usage(uniq_usage);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
while ((opt = getopt(argc, argv, "cdu")) > 0) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
print_count = 1;
|
||||
break;
|
||||
case 'd':
|
||||
print_duplicates = 1;
|
||||
print_uniq = 0;
|
||||
break;
|
||||
case 'u':
|
||||
print_duplicates = 0;
|
||||
print_uniq = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 0 src: stdin; dst: stdout */
|
||||
/* 1 src: file; dst: stdout */
|
||||
/* 2 src: file; dst: file */
|
||||
if (set_file_pointers((argc - 1), &in, &out, &argv[i])) {
|
||||
exit(1);
|
||||
if (argv[optind] != NULL) {
|
||||
in = xfopen(argv[optind], "r");
|
||||
if (argv[optind+1] != NULL)
|
||||
out = xfopen(argv[optind+1], "w");
|
||||
}
|
||||
|
||||
subject_init(&s, in, out, NULL);
|
||||
while (subject_next(&s)) {
|
||||
subject_study(&s);
|
||||
while ((input = get_line_from_file(in)) != NULL) {
|
||||
if (lastline == NULL || strcmp(input, lastline) != 0) {
|
||||
print_line(lastline, count, out);
|
||||
free(lastline);
|
||||
lastline = input;
|
||||
count = 0;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
subject_last(&s);
|
||||
subject_study(&s);
|
||||
print_line(lastline, count, out);
|
||||
free(lastline);
|
||||
|
||||
return(0);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* $Id: uniq.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */
|
||||
+2
-8
@@ -21,16 +21,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
const char usleep_usage[] = "usleep N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPause for N microseconds.\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
extern int usleep_main(int argc, char **argv)
|
||||
{
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
@@ -38,5 +32,5 @@ extern int usleep_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
usleep(atoi(*(++argv))); /* return void */
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+59
-59
@@ -15,47 +15,22 @@
|
||||
* along with this product; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93.
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "pwd_grp/pwd.h"
|
||||
#include "pwd_grp/grp.h"
|
||||
|
||||
/*struct passwd *getpwnam();*/
|
||||
|
||||
@@ -71,7 +46,7 @@ static int read_stduu (const char *inname)
|
||||
char *p;
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL) {
|
||||
errorMsg("%s: Short file\n", inname);
|
||||
error_msg("%s: Short file\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
p = buf;
|
||||
@@ -106,7 +81,7 @@ static int read_stduu (const char *inname)
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL
|
||||
|| strcmp (buf, "end\n")) {
|
||||
errorMsg("%s: No `end' line\n", inname);
|
||||
error_msg("%s: No `end' line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -156,7 +131,7 @@ static int read_base64 (const char *inname)
|
||||
unsigned char *p;
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL) {
|
||||
errorMsg("%s: Short file\n", inname);
|
||||
error_msg("%s: Short file\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
p = buf;
|
||||
@@ -164,7 +139,7 @@ static int read_base64 (const char *inname)
|
||||
if (memcmp (buf, "====", 4) == 0)
|
||||
break;
|
||||
if (last_data != 0) {
|
||||
errorMsg("%s: data following `=' padding character\n", inname);
|
||||
error_msg("%s: data following `=' padding character\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -186,14 +161,14 @@ static int read_base64 (const char *inname)
|
||||
|
||||
while ((b64_tab[*p] & '\100') != 0)
|
||||
if (*p == '\n' || *p++ == '=') {
|
||||
errorMsg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
c2 = b64_tab[*p++];
|
||||
|
||||
while (b64_tab[*p] == '\177')
|
||||
if (*p++ == '\n') {
|
||||
errorMsg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
if (*p == '=') {
|
||||
@@ -205,7 +180,7 @@ static int read_base64 (const char *inname)
|
||||
|
||||
while (b64_tab[*p] == '\177')
|
||||
if (*p++ == '\n') {
|
||||
errorMsg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
putchar (c1 << 2 | c2 >> 4);
|
||||
@@ -237,7 +212,7 @@ static int decode (const char *inname,
|
||||
|
||||
while (1) {
|
||||
if (fgets (buf, sizeof (buf), stdin) == NULL) {
|
||||
errorMsg("%s: No `begin' line\n", inname);
|
||||
error_msg("%s: No `begin' line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -262,13 +237,13 @@ static int decode (const char *inname,
|
||||
while (*p != '/')
|
||||
++p;
|
||||
if (*p == '\0') {
|
||||
errorMsg("%s: Illegal ~user\n", inname);
|
||||
error_msg("%s: Illegal ~user\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
*p++ = '\0';
|
||||
pw = getpwnam (buf + 1);
|
||||
if (pw == NULL) {
|
||||
errorMsg("%s: No user `%s'\n", inname, buf + 1);
|
||||
error_msg("%s: No user `%s'\n", inname, buf + 1);
|
||||
return FALSE;
|
||||
}
|
||||
n = strlen (pw->pw_dir);
|
||||
@@ -285,7 +260,7 @@ static int decode (const char *inname,
|
||||
&& (freopen (outname, "w", stdout) == NULL
|
||||
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
|
||||
)) {
|
||||
errorMsg("uudeoce %s: %s %s\n", outname, inname, strerror(errno)); /* */
|
||||
perror_msg("%s", outname); /* */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -299,15 +274,6 @@ static int decode (const char *inname,
|
||||
return read_stduu (inname);
|
||||
}
|
||||
|
||||
static const char uudecode_usage[] =
|
||||
"uudecode [FILE]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nUudecode a file that is uuencoded.\n\n"
|
||||
"Options:\n"
|
||||
"\t-o FILE\tdirect output to FILE\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int uudecode_main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
@@ -331,16 +297,16 @@ int uudecode_main (int argc,
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
exit_status = decode ("stdin", outname) == 0 ? TRUE : FALSE;
|
||||
exit_status = decode ("stdin", outname) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
else {
|
||||
exit_status = TRUE;
|
||||
exit_status = EXIT_SUCCESS;
|
||||
do {
|
||||
if (freopen (argv[optind], "r", stdin) != NULL) {
|
||||
if (decode (argv[optind], outname) != 0)
|
||||
exit_status = FALSE;
|
||||
} else {
|
||||
errorMsg("uudecode: %s: %s\n", argv[optind], strerror(errno));
|
||||
exit_status = FALSE;
|
||||
perror_msg("%s", argv[optind]);
|
||||
exit_status = EXIT_FAILURE;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
@@ -348,3 +314,37 @@ int uudecode_main (int argc,
|
||||
}
|
||||
return(exit_status);
|
||||
}
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+46
-53
@@ -15,48 +15,19 @@
|
||||
* along with this product; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt */
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
|
||||
|
||||
@@ -171,7 +142,7 @@ static void encode()
|
||||
}
|
||||
|
||||
if (ferror (stdin))
|
||||
errorMsg("Read error\n");
|
||||
error_msg("Read error\n");
|
||||
|
||||
if (trans_ptr == uu_std) {
|
||||
putchar (ENC ('\0'));
|
||||
@@ -179,15 +150,6 @@ static void encode()
|
||||
}
|
||||
}
|
||||
|
||||
static const char uuencode_usage[] =
|
||||
"uuencode [OPTION] [INFILE] REMOTEFILE\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nUuencode a file.\n\n"
|
||||
"Options:\n"
|
||||
"\t-m\tuse base64 encoding as of RFC1521\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
int uuencode_main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
@@ -198,15 +160,12 @@ int uuencode_main (int argc,
|
||||
trans_ptr = uu_std; /* Standard encoding is old uu format */
|
||||
|
||||
/* Parse any options */
|
||||
while ((opt = getopt (argc, argv, "m")) != EOF) {
|
||||
while ((opt = getopt (argc, argv, "m")) > 0) {
|
||||
switch (opt) {
|
||||
case 'm':
|
||||
trans_ptr = uu_base64;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(uuencode_usage);
|
||||
}
|
||||
@@ -216,8 +175,8 @@ int uuencode_main (int argc,
|
||||
case 2:
|
||||
/* Optional first argument is input file. */
|
||||
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
|
||||
errorMsg("uuencode: %s: %s\n", argv[optind], strerror(errno));
|
||||
exit FALSE;
|
||||
perror_msg("%s", argv[optind]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
optind++;
|
||||
@@ -237,8 +196,42 @@ int uuencode_main (int argc,
|
||||
encode();
|
||||
printf(trans_ptr == uu_std ? "end\n" : "====\n");
|
||||
if (ferror (stdout)) {
|
||||
errorMsg("Write error\n");
|
||||
exit FALSE;
|
||||
error_msg("Write error\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+22
-37
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini wc implementation for busybox
|
||||
*
|
||||
* by Edward Betts <edward@debian.org>
|
||||
* Copyright (C) 2000 Edward Betts <edward@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,21 +20,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static const char wc_usage[] = "wc [OPTION]... [FILE]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrint line, word, and byte counts for each FILE, and a total line if\n"
|
||||
"more than one FILE is specified. With no FILE, read standard input.\n\n"
|
||||
"Options:\n"
|
||||
"\t-c\tprint the byte counts\n"
|
||||
"\t-l\tprint the newline counts\n"
|
||||
|
||||
"\t-L\tprint the length of the longest line\n"
|
||||
"\t-w\tprint the word counts\n"
|
||||
#endif
|
||||
;
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int total_lines, total_words, total_chars, max_length;
|
||||
static int print_lines, print_words, print_chars, print_length;
|
||||
@@ -116,13 +105,14 @@ static void wc_file(FILE * file, const char *name)
|
||||
int wc_main(int argc, char **argv)
|
||||
{
|
||||
FILE *file;
|
||||
unsigned int num_files_counted = 0;
|
||||
int opt, status = EXIT_SUCCESS;
|
||||
|
||||
total_lines = total_words = total_chars = max_length = 0;
|
||||
print_lines = print_words = print_chars = print_length = 0;
|
||||
|
||||
while (--argc && **(++argv) == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
while ((opt = getopt(argc, argv, "clLw")) > 0) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
print_chars = 1;
|
||||
break;
|
||||
@@ -143,28 +133,23 @@ int wc_main(int argc, char **argv)
|
||||
if (!print_lines && !print_words && !print_chars && !print_length)
|
||||
print_lines = print_words = print_chars = 1;
|
||||
|
||||
if (argc == 0) {
|
||||
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
|
||||
wc_file(stdin, "");
|
||||
exit(TRUE);
|
||||
} else if (argc == 1) {
|
||||
file = fopen(*argv, "r");
|
||||
if (file == NULL) {
|
||||
perror(*argv);
|
||||
exit(FALSE);
|
||||
}
|
||||
wc_file(file, *argv);
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
while (argc-- > 0 && *argv != '\0' && strlen(*argv)) {
|
||||
file = fopen(*argv, "r");
|
||||
if (file == NULL) {
|
||||
perror(*argv);
|
||||
exit(FALSE);
|
||||
}
|
||||
wc_file(file, *argv);
|
||||
argv++;
|
||||
while (optind < argc) {
|
||||
if ((file = wfopen(argv[optind], "r")) != NULL)
|
||||
wc_file(file, argv[optind]);
|
||||
else
|
||||
status = EXIT_FAILURE;
|
||||
num_files_counted++;
|
||||
optind++;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_files_counted > 1)
|
||||
print_counts(total_lines, total_words, total_chars,
|
||||
max_length, "total");
|
||||
}
|
||||
return(TRUE);
|
||||
|
||||
return status;
|
||||
}
|
||||
+7
-14
@@ -20,30 +20,23 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
|
||||
static const char whoami_usage[] = "whoami\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints the user name associated with the current effective user id.\n"
|
||||
#endif
|
||||
;
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern int whoami_main(int argc, char **argv)
|
||||
{
|
||||
char *user = xmalloc(9);
|
||||
char user[9];
|
||||
uid_t uid = geteuid();
|
||||
|
||||
if (argc > 1)
|
||||
usage(whoami_usage);
|
||||
|
||||
my_getpwuid(user, uid);
|
||||
if (user) {
|
||||
if (*user) {
|
||||
puts(user);
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
fprintf(stderr, "%s: cannot find username for UID %u\n", argv[0],
|
||||
(unsigned) uid);
|
||||
return(FALSE);
|
||||
error_msg_and_die("cannot find username for UID %u\n", (unsigned) uid);
|
||||
}
|
||||
+8
-11
@@ -20,26 +20,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern int yes_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc >= 2 && *argv[1] == '-') {
|
||||
usage("yes [OPTION]... [STRING]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRepeatedly outputs a line with all specified STRING(s), or `y'.\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
if (argc >= 2 && *argv[1] == '-')
|
||||
usage(yes_usage);
|
||||
|
||||
if (argc == 1) {
|
||||
while (1)
|
||||
if (puts("y") == EOF) {
|
||||
perror("yes");
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +44,8 @@ extern int yes_main(int argc, char **argv)
|
||||
if (fputs(argv[i], stdout) == EOF
|
||||
|| putchar(i == argc - 1 ? '\n' : ' ') == EOF) {
|
||||
perror("yes");
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
exit(TRUE);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini `cp' and `mv' implementation for BusyBox.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Copyright (C) 2000 by BitterSweet Enterprises, LLC. (GPL)
|
||||
@@ -25,7 +25,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#define bb_need_omitting_directory
|
||||
@@ -41,30 +41,17 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define is_cp 0
|
||||
#define is_mv 1
|
||||
static const int is_cp = 0;
|
||||
static const int is_mv = 1;
|
||||
static int dz_i; /* index into cp_mv_usage */
|
||||
static const char *dz; /* dollar zero, .bss */
|
||||
|
||||
static const char *cp_mv_usage[] = /* .rodata */
|
||||
{
|
||||
"cp [OPTION]... SOURCE DEST\n"
|
||||
" or: cp [OPTION]... SOURCE... DIRECTORY\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCopies SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n"
|
||||
"\n"
|
||||
"\t-a\tSame as -dpR\n"
|
||||
"\t-d\tPreserves links\n"
|
||||
"\t-p\tPreserves file attributes if possible\n"
|
||||
"\t-f\tforce (implied; ignored) - always set\n"
|
||||
"\t-R\tCopies directories recursively\n"
|
||||
#endif
|
||||
,
|
||||
"mv SOURCE DEST\n"
|
||||
" or: mv SOURCE... DIRECTORY\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.\n"
|
||||
#endif
|
||||
cp_usage,
|
||||
mv_usage
|
||||
};
|
||||
|
||||
static int recursiveFlag;
|
||||
@@ -76,7 +63,7 @@ static const char *baseSrcName;
|
||||
static int srcDirFlag;
|
||||
static struct stat srcStatBuf;
|
||||
|
||||
static char baseDestName[BUFSIZ + 1];
|
||||
static char *pBaseDestName;
|
||||
static size_t baseDestLen;
|
||||
static int destDirFlag;
|
||||
static struct stat destStatBuf;
|
||||
@@ -89,8 +76,7 @@ static void name_too_long__exit (void) __attribute__((noreturn));
|
||||
static
|
||||
void name_too_long__exit (void)
|
||||
{
|
||||
fprintf(stderr, name_too_long, dz);
|
||||
exit(FALSE);
|
||||
error_msg_and_die(name_too_long);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -119,19 +105,19 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
const char *srcBasename;
|
||||
char *name;
|
||||
|
||||
strcpy(destName, baseDestName);
|
||||
strcpy(destName, pBaseDestName);
|
||||
destLen = strlen(destName);
|
||||
|
||||
if (srcDirFlag == TRUE) {
|
||||
if (recursiveFlag == FALSE) {
|
||||
fprintf(stderr, omitting_directory, dz, baseSrcName);
|
||||
error_msg(omitting_directory, baseSrcName);
|
||||
return TRUE;
|
||||
}
|
||||
srcBasename = (strstr(fileName, baseSrcName)
|
||||
+ strlen(baseSrcName));
|
||||
|
||||
if (destLen + strlen(srcBasename) > BUFSIZ) {
|
||||
fprintf(stderr, name_too_long, dz);
|
||||
error_msg(name_too_long);
|
||||
return FALSE;
|
||||
}
|
||||
strcat(destName, srcBasename);
|
||||
@@ -145,8 +131,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
if (mv_Action_first_time && (dz_i == is_mv)) {
|
||||
mv_Action_first_time = errno = 0;
|
||||
if (rename(fileName, destName) < 0 && errno != EXDEV) {
|
||||
fprintf(stderr, "%s: rename(%s, %s): %s\n",
|
||||
dz, fileName, destName, strerror(errno));
|
||||
perror_msg("rename(%s, %s)", fileName, destName);
|
||||
goto do_copyFile; /* Try anyway... */
|
||||
}
|
||||
else if (errno == EXDEV)
|
||||
@@ -158,8 +143,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
|
||||
if (is_in_ino_dev_hashtable(statbuf, &name)) {
|
||||
if (link(name, destName) < 0) {
|
||||
fprintf(stderr, "%s: link(%s, %s): %s\n",
|
||||
dz, name, destName, strerror(errno));
|
||||
perror_msg("link(%s, %s)", name, destName);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -168,7 +152,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
add_to_ino_dev_hashtable(statbuf, destName);
|
||||
}
|
||||
}
|
||||
return copyFile(fileName, destName, preserveFlag, followLinks, forceFlag);
|
||||
return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -178,11 +162,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
if (S_ISDIR(statbuf->st_mode)) {
|
||||
if (rmdir(fileName) < 0) {
|
||||
fprintf(stderr, "%s: rmdir(%s): %s\n", dz, fileName, strerror(errno));
|
||||
perror_msg("rmdir(%s)", fileName);
|
||||
status = FALSE;
|
||||
}
|
||||
} else if (unlink(fileName) < 0) {
|
||||
fprintf(stderr, "%s: unlink(%s): %s\n", dz, fileName, strerror(errno));
|
||||
perror_msg("unlink(%s)", fileName);
|
||||
status = FALSE;
|
||||
}
|
||||
return status;
|
||||
@@ -190,22 +174,23 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
extern int cp_mv_main(int argc, char **argv)
|
||||
{
|
||||
dz = *argv; /* already basename'd by busybox.c:main */
|
||||
if (*dz == 'c' && *(dz + 1) == 'p')
|
||||
volatile int i;
|
||||
int c;
|
||||
RESERVE_BB_BUFFER(baseDestName,BUFSIZ + 1);
|
||||
pBaseDestName = baseDestName; /* available globally */
|
||||
|
||||
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
|
||||
dz_i = is_cp;
|
||||
else
|
||||
dz_i = is_mv;
|
||||
if (argc < 3)
|
||||
usage(cp_mv_usage[dz_i]);
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (dz_i == is_cp) {
|
||||
recursiveFlag = preserveFlag = forceFlag = FALSE;
|
||||
followLinks = TRUE;
|
||||
while (*argv && **argv == '-') {
|
||||
while (*++(*argv)) {
|
||||
switch (**argv) {
|
||||
while ((c = getopt(argc, argv, "adpRf")) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
followLinks = FALSE;
|
||||
preserveFlag = TRUE;
|
||||
@@ -226,21 +211,22 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
default:
|
||||
usage(cp_mv_usage[is_cp]);
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc < 2) {
|
||||
if ((argc - optind) < 2) {
|
||||
usage(cp_mv_usage[dz_i]);
|
||||
}
|
||||
} else { /* (dz_i == is_mv) */
|
||||
/* Initialize optind to 1, since in libc5 optind
|
||||
* is not initialized until getopt() is called
|
||||
* (or until sneaky programmers force it...). */
|
||||
optind = 1;
|
||||
recursiveFlag = preserveFlag = TRUE;
|
||||
followLinks = FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (strlen(argv[argc - 1]) > BUFSIZ) {
|
||||
fprintf(stderr, name_too_long, "cp");
|
||||
error_msg(name_too_long);
|
||||
goto exit_false;
|
||||
}
|
||||
strcpy(baseDestName, argv[argc - 1]);
|
||||
@@ -248,25 +234,25 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
if (baseDestLen == 0)
|
||||
goto exit_false;
|
||||
|
||||
destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf);
|
||||
if ((argc > 3) && destDirFlag == FALSE) {
|
||||
fprintf(stderr, not_a_directory, "cp", baseDestName);
|
||||
destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf);
|
||||
if (argc - optind > 2 && destDirFlag == FALSE) {
|
||||
error_msg(not_a_directory, baseDestName);
|
||||
goto exit_false;
|
||||
}
|
||||
|
||||
while (argc-- > 1) {
|
||||
for (i = optind; i < (argc-1); i++) {
|
||||
size_t srcLen;
|
||||
volatile int flags_memo;
|
||||
int status;
|
||||
|
||||
baseSrcName = *(argv++);
|
||||
baseSrcName=argv[i];
|
||||
|
||||
if ((srcLen = strlen(baseSrcName)) > BUFSIZ)
|
||||
name_too_long__exit();
|
||||
|
||||
if (srcLen == 0) continue; /* "" */
|
||||
|
||||
srcDirFlag = isDirectory(baseSrcName, followLinks, &srcStatBuf);
|
||||
srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf);
|
||||
|
||||
if ((flags_memo = (recursiveFlag == TRUE &&
|
||||
srcDirFlag == TRUE && destDirFlag == TRUE))) {
|
||||
@@ -276,29 +262,28 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
char *pushd, *d, *p;
|
||||
|
||||
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
|
||||
fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno));
|
||||
perror_msg("getcwd()");
|
||||
continue;
|
||||
}
|
||||
if (chdir(baseDestName) < 0) {
|
||||
fprintf(stderr, "%s: chdir(%s): %s\n", dz, baseSrcName, strerror(errno));
|
||||
perror_msg("chdir(%s)", baseSrcName);
|
||||
continue;
|
||||
}
|
||||
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
|
||||
fprintf(stderr, "%s: getcwd(): %s\n", dz, strerror(errno));
|
||||
perror_msg("getcwd()");
|
||||
continue;
|
||||
}
|
||||
while (!state && *d != '\0') {
|
||||
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
|
||||
fprintf(stderr, "%s: stat(%s) :%s\n", dz, d, strerror(errno));
|
||||
perror_msg("stat(%s)", d);
|
||||
state = -1;
|
||||
continue;
|
||||
}
|
||||
if ((sb.st_ino == srcStatBuf.st_ino) &&
|
||||
(sb.st_dev == srcStatBuf.st_dev)) {
|
||||
fprintf(stderr,
|
||||
"%s: Cannot %s `%s' "
|
||||
"into a subdirectory of itself, `%s/%s'\n",
|
||||
dz, dz, baseSrcName, baseDestName, baseSrcName);
|
||||
error_msg("Cannot %s `%s' into a subdirectory of itself, "
|
||||
"`%s/%s'\n", applet_name, baseSrcName,
|
||||
baseDestName, baseSrcName);
|
||||
state = -1;
|
||||
continue;
|
||||
}
|
||||
@@ -307,7 +292,7 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
if (chdir(pushd) < 0) {
|
||||
fprintf(stderr, "%s: chdir(%s): %s\n", dz, pushd, strerror(errno));
|
||||
perror_msg("chdir(%s)", pushd);
|
||||
free(pushd);
|
||||
free(d);
|
||||
continue;
|
||||
@@ -322,20 +307,20 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
status = setjmp(catch);
|
||||
if (status == 0) {
|
||||
mv_Action_first_time = 1;
|
||||
if (recursiveAction(baseSrcName,
|
||||
if (recursive_action(baseSrcName,
|
||||
recursiveFlag, followLinks, FALSE,
|
||||
cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false;
|
||||
if (dz_i == is_mv &&
|
||||
recursiveAction(baseSrcName,
|
||||
recursive_action(baseSrcName,
|
||||
recursiveFlag, followLinks, TRUE,
|
||||
rm_Action, rm_Action, NULL) == FALSE) goto exit_false;
|
||||
}
|
||||
if (flags_memo)
|
||||
*(baseDestName + baseDestLen) = '\0';
|
||||
}
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
exit_false:
|
||||
return( FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* cut implementation for busybox
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* Copyright (c) Michael J. Holme
|
||||
*
|
||||
* This version of cut is adapted from Minix cut and was modified
|
||||
* by Erik Andersen <andersee@debian.org> to be used in busybox.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,353 +17,230 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_help
|
||||
#include "messages.c"
|
||||
|
||||
#define MAX_FIELD 80 /* Pointers to the beginning of each field
|
||||
* are stored in columns[], if a line holds
|
||||
* more than MAX_FIELD columns the array
|
||||
* boundary is exceed. But unlikely at 80 */
|
||||
|
||||
#define MAX_ARGS 32 /* Maximum number of fields following -f or
|
||||
* -c switches */
|
||||
int args[MAX_ARGS * 2];
|
||||
int num_args;
|
||||
|
||||
/* Lots of new defines, should easen maintainance... */
|
||||
#define DUMP_STDIN 0 /* define for mode: no options */
|
||||
#define OPTIONF 1 /* define for mode: option -f */
|
||||
#define OPTIONC 2 /* define for mode: option -c */
|
||||
#define OPTIONB 3 /* define for mode: option -b */
|
||||
#define NOTSET 0 /* option not selected */
|
||||
#define SET 1 /* option selected */
|
||||
|
||||
/* Defines for the warnings */
|
||||
#define DELIMITER_NOT_APPLICABLE 0
|
||||
#define OVERRIDING_PREVIOUS_MODE 1
|
||||
#define OPTION_NOT_APPLICABLE 2
|
||||
#define UNKNOWN_OPTION 3
|
||||
#define FILE_NOT_READABLE 4
|
||||
|
||||
/* Defines for the fatal errors */
|
||||
#define SYNTAX_ERROR 101
|
||||
#define POSITION_ERROR 102
|
||||
#define LINE_TO_LONG_ERROR 103
|
||||
#define RANGE_ERROR 104
|
||||
#define MAX_FIELDS_EXEEDED_ERROR 105
|
||||
#define MAX_ARGS_EXEEDED_ERROR 106
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> /* getopt */
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
int mode; /* 0 = dump stdin to stdout, 1=-f, 2=-c */
|
||||
char delim = '\t'; /* default delimiting character */
|
||||
FILE *fd;
|
||||
char *name;
|
||||
char line[BUFSIZ];
|
||||
int exit_status;
|
||||
|
||||
int cut_main(int argc, char **argv);
|
||||
void warn(int warn_number, char *option);
|
||||
void cuterror(int err);
|
||||
void get_args(void);
|
||||
void cut(void);
|
||||
|
||||
void warn(int warn_number, char *option)
|
||||
{
|
||||
static char *warn_msg[] = {
|
||||
"%s: Option -d allowed only with -f\n",
|
||||
"%s: -%s overrides earlier option\n",
|
||||
"%s: -%s not allowed in current mode\n",
|
||||
"%s: Cannot open %s\n"
|
||||
};
|
||||
|
||||
fprintf(stderr, warn_msg[warn_number], name, option);
|
||||
exit_status = warn_number + 1;
|
||||
|
||||
}
|
||||
|
||||
void cuterror(int err)
|
||||
{
|
||||
static char *err_mes[] = {
|
||||
"%s: syntax error\n",
|
||||
"%s: position must be >0\n",
|
||||
"%s: line longer than BUFSIZ\n",
|
||||
"%s: range must not decrease from left to right\n",
|
||||
"%s: MAX_FIELD exceeded\n",
|
||||
"%s: MAX_ARGS exceeded\n"
|
||||
};
|
||||
|
||||
fprintf(stderr, err_mes[err - 101], name);
|
||||
exit(err);
|
||||
}
|
||||
/* globals from other files */
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
|
||||
void get_args()
|
||||
{
|
||||
int i = 0;
|
||||
int arg_ptr = 0;
|
||||
int flag;
|
||||
/* globals in this file only */
|
||||
static char part = 0; /* (b)yte, (c)har, (f)ields */
|
||||
static int startpos = 1;
|
||||
static int endpos = -1;
|
||||
static char delim = '\t'; /* delimiter, default is tab */
|
||||
static unsigned int supress_non_delimited_lines = 0;
|
||||
|
||||
num_args = 0;
|
||||
do {
|
||||
if (num_args == MAX_ARGS)
|
||||
cuterror(MAX_ARGS_EXEEDED_ERROR);
|
||||
if (!isdigit(line[i]) && line[i] != '-')
|
||||
cuterror(SYNTAX_ERROR);
|
||||
|
||||
args[arg_ptr] = 1;
|
||||
args[arg_ptr + 1] = BUFSIZ;
|
||||
flag = 1;
|
||||
|
||||
while (line[i] != ',' && line[i] != 0) {
|
||||
if (isdigit(line[i])) {
|
||||
args[arg_ptr] = 0;
|
||||
while (isdigit(line[i]))
|
||||
args[arg_ptr] = 10 * args[arg_ptr] + line[i++] - '0';
|
||||
if (!args[arg_ptr])
|
||||
cuterror(POSITION_ERROR);
|
||||
arg_ptr++;
|
||||
}
|
||||
if (line[i] == '-') {
|
||||
arg_ptr |= 1;
|
||||
i++;
|
||||
flag = 0;
|
||||
}
|
||||
}
|
||||
if (flag && arg_ptr & 1)
|
||||
args[arg_ptr] = args[arg_ptr - 1];
|
||||
if (args[num_args * 2] > args[num_args * 2 + 1])
|
||||
cuterror(RANGE_ERROR);
|
||||
num_args++;
|
||||
arg_ptr = num_args * 2;
|
||||
}
|
||||
while (line[i++]);
|
||||
}
|
||||
|
||||
|
||||
void cut()
|
||||
{
|
||||
int i, j, length, maxcol=0;
|
||||
char *columns[MAX_FIELD];
|
||||
|
||||
while (fgets(line, BUFSIZ, fd)) {
|
||||
length = strlen(line) - 1;
|
||||
*(line + length) = 0;
|
||||
switch (mode) {
|
||||
case DUMP_STDIN:
|
||||
printf("%s", line);
|
||||
break;
|
||||
case OPTIONF:
|
||||
columns[maxcol++] = line;
|
||||
for (i = 0; i < length; i++) {
|
||||
if (*(line + i) == delim) {
|
||||
*(line + i) = 0;
|
||||
if (maxcol == MAX_FIELD)
|
||||
cuterror(MAX_FIELDS_EXEEDED_ERROR);
|
||||
columns[maxcol] = line + i + 1;
|
||||
maxcol++;
|
||||
}
|
||||
}
|
||||
if (maxcol != 1) {
|
||||
for (i = 0; i < num_args; i++) {
|
||||
for (j = args[i * 2]; j <= args[i * 2 + 1]; j++)
|
||||
if (j <= maxcol) {
|
||||
printf("%s", columns[j - 1]);
|
||||
if (i != num_args - 1 || j != args[i * 2 + 1])
|
||||
putchar(delim);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OPTIONC:
|
||||
for (i = 0; i < num_args; i++) {
|
||||
for (j = args[i * 2];
|
||||
j <= (args[i * 2 + 1] >
|
||||
length ? length : args[i * 2 + 1]); j++)
|
||||
putchar(*(line + j - 1));
|
||||
}
|
||||
}
|
||||
if (maxcol != 1)
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int cut_main(int argc, char **argv)
|
||||
{
|
||||
int i = 1;
|
||||
int numberFilenames = 0;
|
||||
|
||||
name = argv[0];
|
||||
|
||||
if (argc == 1 || strcmp(argv[1], dash_dash_help)==0)
|
||||
usage( "cut [OPTION]... [FILE]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nPrints selected fields from each input FILE to standard output.\n\n"
|
||||
"Options:\n"
|
||||
"\t-b LIST\tOutput only bytes from LIST\n"
|
||||
"\t-c LIST\tOutput only characters from LIST\n"
|
||||
"\t-d DELIM\tUse DELIM instead of tab as the field delimiter\n"
|
||||
"\t-f N\tPrint only these fields\n"
|
||||
"\t-n\tIgnored\n"
|
||||
#endif
|
||||
);
|
||||
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '-') {
|
||||
switch (argv[i++][1]) {
|
||||
case 'd':
|
||||
if (mode == OPTIONC || mode == OPTIONB)
|
||||
warn(DELIMITER_NOT_APPLICABLE, "d");
|
||||
delim = argv[i++][0];
|
||||
break;
|
||||
case 'f':
|
||||
sprintf(line, "%s", argv[i++]);
|
||||
if (mode == OPTIONC || mode == OPTIONB)
|
||||
warn(OVERRIDING_PREVIOUS_MODE, "f");
|
||||
mode = OPTIONF;
|
||||
break;
|
||||
case 'b':
|
||||
sprintf(line, "%s", argv[i++]);
|
||||
if (mode == OPTIONF || mode == OPTIONC)
|
||||
warn(OVERRIDING_PREVIOUS_MODE, "b");
|
||||
mode = OPTIONB;
|
||||
break;
|
||||
case 'c':
|
||||
sprintf(line, "%s", argv[i++]);
|
||||
if (mode == OPTIONF || mode == OPTIONB)
|
||||
warn(OVERRIDING_PREVIOUS_MODE, "c");
|
||||
mode = OPTIONC;
|
||||
break;
|
||||
case '\0': /* - means: read from stdin */
|
||||
numberFilenames++;
|
||||
break;
|
||||
case 'n': /* needed for Posix, but no effect here */
|
||||
if (mode != OPTIONB)
|
||||
warn(OPTION_NOT_APPLICABLE, "n");
|
||||
break;
|
||||
default:
|
||||
warn(UNKNOWN_OPTION, &(argv[i - 1][1]));
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
numberFilenames++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Here follow the checks, if the selected options are reasonable. */
|
||||
if (mode == OPTIONB) /* since in Minix char := byte */
|
||||
mode = OPTIONC;
|
||||
get_args();
|
||||
if (numberFilenames != 0) {
|
||||
i = 1;
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '-') {
|
||||
switch (argv[i][1]) {
|
||||
case 'f':
|
||||
case 'c':
|
||||
case 'b':
|
||||
case 'd':
|
||||
i += 2;
|
||||
break;
|
||||
case 'n':
|
||||
case 'i':
|
||||
case 's':
|
||||
i++;
|
||||
break;
|
||||
case '\0':
|
||||
fd = stdin;
|
||||
i++;
|
||||
cut();
|
||||
break;
|
||||
default:
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
if ((fd = fopen(argv[i++], "r")) == NULL) {
|
||||
warn(FILE_NOT_READABLE, argv[i - 1]);
|
||||
} else {
|
||||
cut();
|
||||
fclose(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fd = stdin;
|
||||
cut();
|
||||
}
|
||||
|
||||
return(exit_status);
|
||||
}
|
||||
|
||||
/* cut - extract columns from a file or stdin. Author: Michael J. Holme
|
||||
*
|
||||
* Copyright 1989, Michael John Holme, All rights reserved.
|
||||
* This code may be freely distributed, provided that this notice
|
||||
* remains intact.
|
||||
*
|
||||
* V1.1: 6th September 1989
|
||||
*
|
||||
* Bugs, criticisms, etc,
|
||||
* c/o Mark Powell
|
||||
* JANET sq79@uk.ac.liv
|
||||
* ARPA sq79%liv.ac.uk@nsfnet-relay.ac.uk
|
||||
* UUCP ...!mcvax!ukc!liv.ac.uk!sq79
|
||||
*-------------------------------------------------------------------------
|
||||
* Changed for POSIX1003.2/Draft10 conformance
|
||||
* Thomas Brupbacher (tobr@mw.lpc.ethz.ch), September 1990.
|
||||
* Changes:
|
||||
* - separation of error messages ( stderr) and output (stdout).
|
||||
* - support for -b and -n (no effect, -b acts as -c)
|
||||
* - support for -s
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987,1997, Prentice Hall
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use of the MINIX operating system in source and
|
||||
* binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Neither the name of Prentice Hall nor the names of the software
|
||||
* authors or contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, 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 PRENTICE HALL OR ANY AUTHORS 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.
|
||||
*
|
||||
* decompose_list() - parses a list and puts values into startpos and endpos.
|
||||
* valid list formats: N, N-, N-M, -M
|
||||
*/
|
||||
static void decompose_list(const char *list)
|
||||
{
|
||||
unsigned int nminus = 0;
|
||||
char *ptr;
|
||||
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* handle single value 'N' case */
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
error_msg_and_die("missing list of fields\n");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
/* handle multi-value cases */
|
||||
else if (nminus == 1) {
|
||||
/* handle 'N-' case */
|
||||
if (list[strlen(list) - 1] == '-') {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
}
|
||||
/* handle '-M' case */
|
||||
else if (list[0] == '-') {
|
||||
endpos = strtol(&list[1], NULL, 10);
|
||||
}
|
||||
/* handle 'N-M' case */
|
||||
else {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
endpos = strtol(ptr+1, &ptr, 10);
|
||||
}
|
||||
|
||||
/* a sanity check */
|
||||
if (startpos == 0) {
|
||||
startpos = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* snippy-snip
|
||||
*/
|
||||
static void cut_file(FILE *file)
|
||||
{
|
||||
char *line;
|
||||
unsigned int cr_hits = 0;
|
||||
|
||||
/* go through every line in the file */
|
||||
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
|
||||
/* cut based on chars/bytes */
|
||||
if (part == 'c' || part == 'b') {
|
||||
int i;
|
||||
/* a valid end position has been specified */
|
||||
if (endpos > 0) {
|
||||
for (i = startpos-1; i < endpos; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* otherwise, just go to the end of the line */
|
||||
else {
|
||||
for (i = startpos-1; line[i]; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* cut based on fields */
|
||||
else if (part == 'f') {
|
||||
char *ptr;
|
||||
char *start = line;
|
||||
unsigned int delims_hit = 0;
|
||||
|
||||
if (delim == '\n') {
|
||||
cr_hits++;
|
||||
if (cr_hits >= startpos && cr_hits <= endpos) {
|
||||
while (*start && *start != '\n') {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern int cut_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'f':
|
||||
/* make sure they didn't ask for two types of lists */
|
||||
if (part != 0) {
|
||||
error_msg_and_die("only one type of list may be specified\n");
|
||||
}
|
||||
part = (char)opt;
|
||||
decompose_list(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character\n");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
case 'n':
|
||||
/* no-op */
|
||||
break;
|
||||
case 's':
|
||||
supress_non_delimited_lines++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense"
|
||||
" only when operating on fields\n");
|
||||
|
||||
}
|
||||
|
||||
if (delim != '\t' && part != 'f') {
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields\n");
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
* files were specified or '-' was specified, take input from stdin.
|
||||
* Otherwise, we process all the files specified. */
|
||||
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
|
||||
cut_file(stdin);
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
FILE *file;
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_date
|
||||
#define bb_need_memory_exhausted
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
|
||||
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
@@ -39,17 +41,6 @@
|
||||
an RFC 822 complient date output for shell scripting
|
||||
mail commands */
|
||||
|
||||
static const char date_usage[] = "date [OPTION]... [+FORMAT]\n"
|
||||
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDisplays the current time in the given FORMAT, or sets the system date.\n"
|
||||
"\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n"
|
||||
"\t-s\tSets time described by STRING\n"
|
||||
"\t-u\tPrints or sets Coordinated Universal Time\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
/* Input parsing code is always bulky - used heavy duty libc stuff as
|
||||
much as possible, missed out a lot of bounds checking */
|
||||
|
||||
@@ -66,7 +57,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
&(tm_time->tm_min), &(tm_time->tm_year));
|
||||
|
||||
if (nr < 4 || nr > 5) {
|
||||
fatalError(invalid_date, "date", t_string);
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
@@ -84,73 +75,57 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
|
||||
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
struct tm itm_time, jtm_time, ktm_time, ltm_time, mtm_time, ntm_time;
|
||||
|
||||
itm_time = *tm_time;
|
||||
jtm_time = *tm_time;
|
||||
ktm_time = *tm_time;
|
||||
ltm_time = *tm_time;
|
||||
mtm_time = *tm_time;
|
||||
ntm_time = *tm_time;
|
||||
struct tm t;
|
||||
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if (sscanf(t_string, "%d:%d:%d",
|
||||
&itm_time.tm_hour, &itm_time.tm_min, &itm_time.tm_sec) == 3) {
|
||||
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
|
||||
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
|
||||
*tm_time = itm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
|
||||
&t.tm_hour, &t.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
|
||||
} else if (sscanf(t_string, "%d:%d",
|
||||
&jtm_time.tm_hour, &jtm_time.tm_min) == 2) {
|
||||
|
||||
*tm_time = jtm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 5) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&ktm_time.tm_mon,
|
||||
&ktm_time.tm_mday,
|
||||
&ktm_time.tm_hour,
|
||||
&ktm_time.tm_min, &ktm_time.tm_sec) == 5) {
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
ktm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ktm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 4) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d",
|
||||
<m_time.tm_mon,
|
||||
<m_time.tm_mday,
|
||||
<m_time.tm_hour, <m_time.tm_min) == 4) {
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
ltm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ltm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 6) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&mtm_time.tm_year,
|
||||
&mtm_time.tm_mon,
|
||||
&mtm_time.tm_mday,
|
||||
&mtm_time.tm_hour,
|
||||
&mtm_time.tm_min, &mtm_time.tm_sec) == 6) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
mtm_time.tm_year -= 1900; /* Adjust years */
|
||||
mtm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = mtm_time;
|
||||
return (tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&ntm_time.tm_year,
|
||||
&ntm_time.tm_mon,
|
||||
&ntm_time.tm_mday,
|
||||
&ntm_time.tm_hour, &ntm_time.tm_min) == 5) {
|
||||
ntm_time.tm_year -= 1900; /* Adjust years */
|
||||
ntm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ntm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 5) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else {
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
fatalError(invalid_date, "date", t_string);
|
||||
*tm_time = t;
|
||||
return (tm_time);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +134,7 @@ int date_main(int argc, char **argv)
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *t_buff;
|
||||
int i;
|
||||
int c;
|
||||
int set_time = 0;
|
||||
int rfc822 = 0;
|
||||
int utc = 0;
|
||||
@@ -168,49 +143,44 @@ int date_main(int argc, char **argv)
|
||||
struct tm tm_time;
|
||||
|
||||
/* Interpret command line args */
|
||||
i = --argc;
|
||||
argv++;
|
||||
while (i > 0 && **argv) {
|
||||
if (**argv == '-') {
|
||||
while (i > 0 && *++(*argv))
|
||||
switch (**argv) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if (date_str != NULL)
|
||||
usage(date_usage);
|
||||
date_str = *argv;
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
fatalError(memory_exhausted, "date");
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if (date_str != NULL)
|
||||
usage(date_usage);
|
||||
date_str = *argv;
|
||||
break;
|
||||
case '-':
|
||||
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
usage(date_usage);
|
||||
}
|
||||
} else {
|
||||
if ((date_fmt == NULL) && (**argv == '+'))
|
||||
date_fmt = *argv + 1; /* Skip over the '+' */
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = *argv;
|
||||
} else {
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
}
|
||||
}
|
||||
i--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
|
||||
date_fmt = &argv[optind][1]; /* Skip over the '+' */
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = argv[optind];
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
usage(date_usage);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
@@ -236,12 +206,16 @@ int date_main(int argc, char **argv)
|
||||
/* Correct any day of week and day of year etc fields */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0)
|
||||
fatalError(invalid_date, "date", date_str);
|
||||
error_msg_and_die(invalid_date, date_str);
|
||||
if ( utc ) {
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if (set_time) {
|
||||
if (stime(&tm) < 0) {
|
||||
fatalError("date: can't set date.\n");
|
||||
perror_msg("cannot set date");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -259,7 +233,7 @@ int date_main(int argc, char **argv)
|
||||
} else if (*date_fmt == '\0') {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf("\n");
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Handle special conversions */
|
||||
@@ -273,5 +247,5 @@ int date_main(int argc, char **argv)
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
printf("%s\n", t_buff);
|
||||
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -8,32 +8,20 @@
|
||||
|
||||
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
|
||||
|
||||
static const char dc_usage[] = "dc expression ...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nThis is a Tiny RPN calculator that understands the\n"
|
||||
"following operations: +, -, /, *, and, or, not, eor.\n"
|
||||
"i.e. 'dc 2 2 add' -> 4, and 'dc 8 8 \\* 2 2 + /' -> 16\n"
|
||||
#endif
|
||||
;
|
||||
|
||||
static double stack[100];
|
||||
static unsigned int pointer;
|
||||
|
||||
static void push(double a)
|
||||
{
|
||||
if (pointer >= (sizeof(stack) / sizeof(*stack))) {
|
||||
fprintf(stderr, "dc: stack overflow\n");
|
||||
exit(-1);
|
||||
} else
|
||||
stack[pointer++] = a;
|
||||
if (pointer >= (sizeof(stack) / sizeof(*stack)))
|
||||
error_msg_and_die("stack overflow\n");
|
||||
stack[pointer++] = a;
|
||||
}
|
||||
|
||||
static double pop()
|
||||
{
|
||||
if (pointer == 0) {
|
||||
fprintf(stderr, "dc: stack underflow\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (pointer == 0)
|
||||
error_msg_and_die("stack underflow\n");
|
||||
return stack[--pointer];
|
||||
}
|
||||
|
||||
@@ -132,8 +120,7 @@ static void stack_machine(const char *argument)
|
||||
}
|
||||
o++;
|
||||
}
|
||||
fprintf(stderr, "dc: %s: syntax error.\n", argument);
|
||||
exit(-1);
|
||||
error_msg_and_die("%s: syntax error.\n", argument);
|
||||
}
|
||||
|
||||
/* return pointer to next token in buffer and set *buffer to one char
|
||||
@@ -170,7 +157,7 @@ int dc_main(int argc, char **argv)
|
||||
char *line = NULL;
|
||||
char *cursor = NULL;
|
||||
char *token = NULL;
|
||||
while ((line = cstring_lineFromFile(stdin))) {
|
||||
while ((line = get_line_from_file(stdin))) {
|
||||
cursor = line;
|
||||
len = number_of_tokens(line);
|
||||
for (i = 0; i < len; i++) {
|
||||
@@ -190,5 +177,5 @@ int dc_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
stack_machine(0);
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -2,15 +2,8 @@
|
||||
/*
|
||||
* Mini dd implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999, 2000 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Based in part on code taken from sash.
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Permission to distribute this code under the GPL has been granted.
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,180 +21,138 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#include "internal.h"
|
||||
#include <features.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
typedef unsigned long long int uintmax_t;
|
||||
#endif
|
||||
|
||||
static const char dd_usage[] =
|
||||
"dd [if=FILE] [of=FILE] [bs=N] [count=N] [skip=N] [seek=N]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCopy a file, converting and formatting according to options\n\n"
|
||||
"\tif=FILE\tread from FILE instead of stdin\n"
|
||||
"\tof=FILE\twrite to FILE instead of stdout\n"
|
||||
"\tbs=N\tread and write N bytes at a time\n"
|
||||
"\tcount=N\tcopy only N input blocks\n"
|
||||
"\tskip=N\tskip N input blocks\n"
|
||||
"\tseek=N\tskip N output blocks\n"
|
||||
"\n"
|
||||
"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n"
|
||||
#endif
|
||||
;
|
||||
static struct suffix_mult dd_suffixes[] = {
|
||||
{ "c", 1 },
|
||||
{ "w", 2 },
|
||||
{ "b", 512 },
|
||||
{ "kD", 1000 },
|
||||
{ "k", 1024 },
|
||||
{ "MD", 1000000 },
|
||||
{ "M", 1048576 },
|
||||
{ "GD", 1000000000 },
|
||||
{ "G", 1073741824 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern int dd_main(int argc, char **argv)
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
char *inFile = NULL;
|
||||
char *outFile = NULL;
|
||||
char *cp;
|
||||
int inFd;
|
||||
int outFd;
|
||||
int inCc = 0;
|
||||
int outCc;
|
||||
long blockSize = 512;
|
||||
uintmax_t skipBlocks = 0;
|
||||
uintmax_t seekBlocks = 0;
|
||||
uintmax_t count = (uintmax_t) - 1;
|
||||
uintmax_t intotal;
|
||||
uintmax_t outTotal;
|
||||
unsigned char *buf;
|
||||
int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
|
||||
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
|
||||
size_t bs = 512, count = -1;
|
||||
ssize_t n;
|
||||
off_t seek = 0, skip = 0;
|
||||
FILE *statusfp;
|
||||
char *infile = NULL, *outfile = NULL, *buf;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strncmp("bs=", argv[i], 3) == 0)
|
||||
bs = parse_number(argv[i]+3, dd_suffixes);
|
||||
else if (strncmp("count=", argv[i], 6) == 0)
|
||||
count = parse_number(argv[i]+6, dd_suffixes);
|
||||
else if (strncmp("seek=", argv[i], 5) == 0)
|
||||
seek = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("skip=", argv[i], 5) == 0)
|
||||
skip = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("if=", argv[i], 3) == 0)
|
||||
infile = argv[i]+3;
|
||||
else if (strncmp("of=", argv[i], 3) == 0)
|
||||
outfile = argv[i]+3;
|
||||
else if (strncmp("conv=", argv[i], 5) == 0) {
|
||||
buf = argv[i]+5;
|
||||
while (1) {
|
||||
if (strncmp("notrunc", buf, 7) == 0) {
|
||||
trunc = FALSE;
|
||||
buf += 7;
|
||||
} else if (strncmp("sync", buf, 4) == 0) {
|
||||
sync = TRUE;
|
||||
buf += 4;
|
||||
} else {
|
||||
error_msg_and_die("invalid conversion `%s'\n", argv[i]+5);
|
||||
}
|
||||
if (buf[0] == '\0')
|
||||
break;
|
||||
if (buf[0] == ',')
|
||||
buf++;
|
||||
}
|
||||
} else
|
||||
usage(dd_usage);
|
||||
}
|
||||
|
||||
/* Parse any options */
|
||||
while (argc) {
|
||||
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
|
||||
inFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
|
||||
outFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (strncmp("count", *argv, 5) == 0) {
|
||||
count = getNum((strchr(*argv, '=')) + 1);
|
||||
if (count <= 0) {
|
||||
fprintf(stderr, "Bad count value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "bs", 2) == 0) {
|
||||
blockSize = getNum((strchr(*argv, '=')) + 1);
|
||||
if (blockSize <= 0) {
|
||||
fprintf(stderr, "Bad block size value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "skip", 4) == 0) {
|
||||
skipBlocks = getNum((strchr(*argv, '=')) + 1);
|
||||
if (skipBlocks <= 0) {
|
||||
fprintf(stderr, "Bad skip value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
buf = xmalloc(bs);
|
||||
|
||||
} else if (strncmp(*argv, "seek", 4) == 0) {
|
||||
seekBlocks = getNum((strchr(*argv, '=')) + 1);
|
||||
if (seekBlocks <= 0) {
|
||||
fprintf(stderr, "Bad seek value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
if (infile != NULL) {
|
||||
if ((ifd = open(infile, O_RDONLY)) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
} else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = "standard input";
|
||||
}
|
||||
|
||||
} else {
|
||||
goto usage;
|
||||
if (outfile != NULL) {
|
||||
oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
if (!seek && trunc)
|
||||
oflag |= O_TRUNC;
|
||||
|
||||
if ((ofd = open(outfile, oflag, 0666)) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
|
||||
if (seek && trunc) {
|
||||
if (ftruncate(ofd, seek * bs) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
statusfp = stdout;
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
statusfp = stderr;
|
||||
}
|
||||
|
||||
buf = xmalloc(blockSize);
|
||||
|
||||
intotal = 0;
|
||||
outTotal = 0;
|
||||
|
||||
if (inFile == NULL)
|
||||
inFd = fileno(stdin);
|
||||
else
|
||||
inFd = open(inFile, 0);
|
||||
|
||||
if (inFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* free(buf); */
|
||||
fatalError( inFile);
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
outFd = fileno(stdout);
|
||||
else
|
||||
outFd = open(outFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
if (outFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* close(inFd);
|
||||
free(buf); */
|
||||
fatalError( outFile);
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
lseek(inFd, skipBlocks * blockSize, SEEK_SET);
|
||||
lseek(outFd, seekBlocks * blockSize, SEEK_SET);
|
||||
//
|
||||
//TODO: Convert to using fullRead & fullWrite
|
||||
// from utility.c
|
||||
// -Erik
|
||||
while (outTotal < count * blockSize) {
|
||||
inCc = read(inFd, buf, blockSize);
|
||||
if (inCc < 0) {
|
||||
perror(inFile);
|
||||
goto cleanup;
|
||||
} else if (inCc == 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
intotal += inCc;
|
||||
cp = buf;
|
||||
|
||||
while (intotal > outTotal) {
|
||||
if (outTotal + inCc > count * blockSize)
|
||||
inCc = count * blockSize - outTotal;
|
||||
outCc = write(outFd, cp, inCc);
|
||||
if (outCc < 0) {
|
||||
perror(outFile);
|
||||
goto cleanup;
|
||||
} else if (outCc == 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
inCc -= outCc;
|
||||
cp += outCc;
|
||||
outTotal += outCc;
|
||||
while (in_full + in_part != count) {
|
||||
n = safe_read(ifd, buf, bs);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (n == bs)
|
||||
in_full++;
|
||||
else
|
||||
in_part++;
|
||||
if (sync) {
|
||||
memset(buf + n, '\0', bs - n);
|
||||
n = bs;
|
||||
}
|
||||
n = full_write(ofd, buf, n);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (n == bs)
|
||||
out_full++;
|
||||
else
|
||||
out_part++;
|
||||
}
|
||||
|
||||
if (inCc < 0)
|
||||
perror(inFile);
|
||||
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
|
||||
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
|
||||
|
||||
cleanup:
|
||||
/* Note that we are not freeing memory or closing
|
||||
* files here, to save a few bytes. */
|
||||
#if 0
|
||||
close(inFd);
|
||||
close(outFd);
|
||||
free(buf);
|
||||
#endif
|
||||
|
||||
printf("%ld+%d records in\n", (long) (intotal / blockSize),
|
||||
(intotal % blockSize) != 0);
|
||||
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
|
||||
(outTotal % blockSize) != 0);
|
||||
exit(TRUE);
|
||||
usage:
|
||||
|
||||
usage(dd_usage);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+17
-29
@@ -3,53 +3,41 @@
|
||||
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
|
||||
* Renamed deallocvt.
|
||||
*/
|
||||
#include "internal.h"
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/vt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *progname;
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
int fd, num, i;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-')) {
|
||||
usage
|
||||
("deallocvt N\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDeallocate unused virtual terminal /dev/ttyN\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
progname = argv[0];
|
||||
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
|
||||
if (argc > 2)
|
||||
usage(deallocvt_usage);
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
if (argc == 1) {
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
exit( FALSE);
|
||||
}
|
||||
} else
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
fprintf(stderr, "%s: 0: illegal VT number\n", progname);
|
||||
error_msg("0: illegal VT number\n");
|
||||
else if (num == 1)
|
||||
fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
|
||||
progname);
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
fprintf(stderr, "%s: could not deallocate console %d\n",
|
||||
progname, num);
|
||||
exit( FALSE);
|
||||
}
|
||||
error_msg("VT 1 cannot be deallocated\n");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Vendored
+110
-34
@@ -14,6 +14,7 @@
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
@@ -23,15 +24,20 @@
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
#define BB_DOS2UNIX
|
||||
#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
|
||||
@@ -41,10 +47,9 @@
|
||||
#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
#define BB_INIT
|
||||
#define BB_INSMOD
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_KLOGD
|
||||
#define BB_LENGTH
|
||||
#define BB_LN
|
||||
#define BB_LOADACM
|
||||
@@ -55,7 +60,7 @@
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
#define BB_MAKEDEVS
|
||||
//#define BB_MD5SUM
|
||||
#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
@@ -72,13 +77,17 @@
|
||||
#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_RPMUNPACK
|
||||
#define BB_SED
|
||||
#define BB_SETKEYCODES
|
||||
#define BB_SFDISK
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
@@ -97,6 +106,7 @@
|
||||
#define BB_UPTIME
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
@@ -104,7 +114,9 @@
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
#define BB_UNIX2DOS
|
||||
#define BB_UPDATE
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
@@ -116,12 +128,17 @@
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, devmtab,
|
||||
// etc kernel drivers, thereby eliminating the need for
|
||||
// the /proc filesystem and thereby saving lots and lots
|
||||
// memory for more important things.
|
||||
// You can't use this and USE_PROCFS at the same time...
|
||||
// (BTW, I emailed Linus and this patch will not be going into the stock kernel)
|
||||
//
|
||||
// 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
|
||||
@@ -130,12 +147,6 @@
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// Enable full regular expressions. This adds about
|
||||
// 4k. When this is off, things that would normally
|
||||
// use regualr expressions (like grep) will just use
|
||||
// normal strings.
|
||||
#define BB_FEATURE_FULL_REGULAR_EXPRESSIONS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
@@ -155,17 +166,23 @@
|
||||
// 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_SIMPLE_PING
|
||||
//#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
|
||||
#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
@@ -178,8 +195,14 @@
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Simple tail implementation (2k vs 6k for the full one). Still
|
||||
//provides 'tail -f' support -- but for only one file at a time.
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
@@ -188,30 +211,42 @@
|
||||
// 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
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes
|
||||
// (This does not yet work with Linux 2.[34].x kernels)
|
||||
//#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" for excluding files
|
||||
// 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
|
||||
#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
|
||||
//amoung other thing.
|
||||
#define BB_FEATURE_STANDALONE_SHELL
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//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.
|
||||
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
@@ -220,15 +255,40 @@
|
||||
//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
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support modules status from pre 2.1 kernels
|
||||
//#define BB_FEATURE_LSMOD_OLD_KERNEL
|
||||
// Support modules status from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_LSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support 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
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
#define BB_FEATURE_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
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
@@ -245,10 +305,6 @@
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_FULL_REGULAR_EXPRESSIONS && (defined BB_SED || defined BB_GREP )
|
||||
#define BB_REGEXP
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#endif
|
||||
@@ -262,8 +318,8 @@
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#define BB_LINUXRC
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
@@ -272,6 +328,26 @@
|
||||
#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
|
||||
Vendored
+371
@@ -0,0 +1,371 @@
|
||||
/* 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_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_INIT
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
//#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_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_RPMUNPACK
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES
|
||||
//#define BB_SH
|
||||
#define BB_SLEEP
|
||||
//#define BB_SORT
|
||||
#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_TOUCH
|
||||
//#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
//#define BB_TTY
|
||||
#define BB_UPTIME
|
||||
//#define BB_USLEEP
|
||||
//#define BB_WC
|
||||
//#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
//#define BB_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
//#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
//#define BB_UNIX2DOS
|
||||
//#define BB_UPDATE
|
||||
#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).
|
||||
//
|
||||
//
|
||||
//
|
||||
// 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
|
||||
#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
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
//#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// You may need to mount with "-o nolock" if you are
|
||||
// not running a local portmapper daemon...
|
||||
#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
//#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" and "-X" for excluding files
|
||||
//#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
// Enable support for tar -z option (currently only works for inflating)
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things.
|
||||
//#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//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.
|
||||
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
//
|
||||
//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
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support modules status from pre 2.1 kernels
|
||||
//#define BB_FEATURE_LSMOD_OLD_KERNEL
|
||||
// Support modules status from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_LSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support 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
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
#define BB_FEATURE_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
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#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_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#endif
|
||||
#endif
|
||||
Vendored
+28
-2
@@ -1,4 +1,30 @@
|
||||
busybox (0.45-1) frozen; urgency=low
|
||||
busybox (0.49-1) unstable; urgency=low
|
||||
|
||||
* Lots more source updates and bug fixes. See changelog for details.
|
||||
|
||||
-- Erik Andersen <andersee@debian.org> Sat, 27 Jan 2001 01:45:53 -0700
|
||||
|
||||
busybox (0.48-1) unstable; urgency=low
|
||||
|
||||
* Lots more source updates and bug fixes. See changelog for details.
|
||||
* Now includes .udeb support for the debian-installer. The .udeb
|
||||
probably needs some more work, but this should be a good start.
|
||||
|
||||
-- Erik Andersen <andersee@debian.org> Wed, 13 Dec 2000 08:36:07 -0700
|
||||
|
||||
busybox (0.47-1) unstable; urgency=low
|
||||
|
||||
* New version released. See changelog for details.
|
||||
|
||||
-- Erik Andersen <andersee@debian.org> Mon, 25 Sep 2000 23:00:56 -0600
|
||||
|
||||
busybox (0.46-1) unstable; urgency=low
|
||||
|
||||
* New version released. See changelog for details.
|
||||
|
||||
-- Erik Andersen <andersee@debian.org> Tue, 11 Jul 2000 12:15:44 -0600
|
||||
|
||||
busybox (0.45-1) unstable; urgency=low
|
||||
|
||||
* First attempt at packaging BusyBox as a .deb. This has been in
|
||||
in the Debian boot-floppies CVS tree forever. Hopefully, having it as a
|
||||
@@ -10,7 +36,7 @@ busybox (0.45-1) frozen; urgency=low
|
||||
times in the past that I would have loved to have this sitting on my system
|
||||
(i.e. when libc gets screwed up.)
|
||||
|
||||
-- Erik Andersen <andersee@debian.org> Sun, 18 Jun 2000 21:45:47 -0600
|
||||
-- Erik Andersen <andersee@debian.org> Tue, 27 Jun 2000 12:26:41 -0600
|
||||
|
||||
Local variables:
|
||||
mode: debian-changelog
|
||||
|
||||
Vendored
+26
-9
@@ -1,16 +1,16 @@
|
||||
Source: busybox
|
||||
Priority: optional
|
||||
Maintainer: Erik Andersen <andersee@debian.org>
|
||||
Build-Depends: debhelper (>= 2.0.80)
|
||||
Standards-Version: 3.1.1
|
||||
Build-Depends: debhelper (>= 2.1.18), dpkg-dev (1.7.0)
|
||||
Standards-Version: 3.2.1.0
|
||||
|
||||
Package: busybox
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}
|
||||
Conflicts: binutils, bsdutils, console-tools, cpio, debianutils, dnsutils, dpkg, fbset, fdflush, fileutils, grep, gzip, hostname, modutils, mount, netbase, procps, psmisc, sed, sharutils, shellutils, sysklogd, sysvinit, tar, textutils, update, util-linux
|
||||
Replaces: dpkg, netbase
|
||||
Conflicts:
|
||||
Replaces:
|
||||
Section: utils
|
||||
Description: Tiny utilities for the debian-installer and for embedded systems.
|
||||
Description: Tiny utilities for small and embedded systems.
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for the most common
|
||||
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
|
||||
@@ -19,10 +19,10 @@ Description: Tiny utilities for the debian-installer and for embedded systems.
|
||||
provide the expected functionality and behave very much like their GNU
|
||||
counterparts.
|
||||
.
|
||||
BusyBox is used by the debian-installer. Installing BusyBox onto your Debian
|
||||
system is not recommended, unless you are intended to make a very small embedded
|
||||
system. Chances are good that for embedded systems, you will want to recompile
|
||||
to only include the tools and utilities you wish to include.
|
||||
This package installs the BusyBox binary but does not install symlinks
|
||||
for any of the supported utilities. You can use /bin/busybox --install
|
||||
to install BusyBox to the current directory (you do not want to do this
|
||||
in / on your Debian system!).
|
||||
|
||||
Package: busybox-static
|
||||
Architecture: any
|
||||
@@ -44,3 +44,20 @@ Description: Provides a stand alone rescue shell with tons of builtin utilities.
|
||||
your system from certain destruction. Invoke "busybox", and it will list the
|
||||
available builtin commands.
|
||||
|
||||
Package: busybox-udeb
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}
|
||||
Section: debian-installer
|
||||
Description: Tiny utilities for the debian-installer
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for the most common
|
||||
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
|
||||
mount, tar, etc). 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-udeb is used by the debian-installer, so unless you are working
|
||||
on the debian-installer, this package is not for you. Installing this
|
||||
on your Debian system is a very, very bad idea. You have been warned.
|
||||
|
||||
Loaded 100 of 291 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user