Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a6a77362b | ||
|
|
25f95dee2d | ||
|
|
040f440262 | ||
|
|
08804ceaf1 | ||
|
|
76097edc0e | ||
|
|
3124a9ecee | ||
|
|
b99aec0ba5 | ||
|
|
d8ceba959a | ||
|
|
eef2317b9f | ||
|
|
eac20451d2 | ||
|
|
c663ab0c6b | ||
|
|
ca16204c31 | ||
|
|
2a186890ee | ||
|
|
81fe123040 | ||
|
|
9cdef5d928 | ||
|
|
930c59675a | ||
|
|
cad4c5b0f3 | ||
|
|
4052051864 | ||
|
|
c470f4477a | ||
|
|
9b47661165 | ||
|
|
68d4a85f12 | ||
|
|
f3a02bbf41 | ||
|
|
05df91a3ac | ||
|
|
35e643b39f | ||
|
|
4f4631732c | ||
|
|
f96675bc50 | ||
|
|
727f529211 | ||
|
|
342aea967f | ||
|
|
a1ed06b047 | ||
|
|
aa820dbc00 | ||
|
|
480f1533f3 | ||
|
|
05e662ab4d | ||
|
|
ac00aa7599 | ||
|
|
ef73d3b5d9 | ||
|
|
7d72e796d6 | ||
|
|
d5868c1692 | ||
|
|
f231c72630 | ||
|
|
b511f9cea9 | ||
|
|
e5272074c9 | ||
|
|
20c9f1e5e7 | ||
|
|
4c6c236781 | ||
|
|
340aa1cb3f | ||
|
|
fe55b260e2 | ||
|
|
b24da33a06 | ||
|
|
3857a184c7 | ||
|
|
795c4bac91 | ||
|
|
a501d0f01f | ||
|
|
9c3c38da55 | ||
|
|
6fd0e31e87 | ||
|
|
0246222351 | ||
|
|
85e5e72bc1 | ||
|
|
0a14c9f924 | ||
|
|
d14d2a1f61 | ||
|
|
e199220d48 | ||
|
|
725db196c3 | ||
|
|
d9fe958921 | ||
|
|
680ec6eeae | ||
|
|
cde8f53c60 | ||
|
|
592ebd507a | ||
|
|
3443bd7286 | ||
|
|
1ebcff191a | ||
|
|
8212aa5a37 | ||
|
|
85c3c3f091 | ||
|
|
1b0075d243 | ||
|
|
c989724316 | ||
|
|
db210ae02c | ||
|
|
bb9dc93477 | ||
|
|
d4fcb80609 | ||
|
|
335816bc4c | ||
|
|
43da9d19ef | ||
|
|
cb81e6484d | ||
|
|
74f270a317 | ||
|
|
e5642119ee | ||
|
|
1eceb127bd | ||
|
|
b7ebc61b54 | ||
|
|
fb0c6af286 | ||
|
|
9edcabdc34 | ||
|
|
96916b7f41 | ||
|
|
341170b012 | ||
|
|
feb283a437 | ||
|
|
9059e3a37b | ||
|
|
f890f9dd16 | ||
|
|
e3393513c5 | ||
|
|
9f894f4062 | ||
|
|
3c5a83c567 | ||
|
|
d5a2780aa2 | ||
|
|
3c8064ff69 | ||
|
|
40ea66cd9d | ||
|
|
7207b88d06 | ||
|
|
65e20a33c2 | ||
|
|
01c3d40f3c | ||
|
|
a21f4e018a | ||
|
|
e968ee3f70 | ||
|
|
8a93179c14 | ||
|
|
bccb31533e | ||
|
|
9e48045e45 | ||
|
|
c48d49ad98 | ||
|
|
e5920a2dc0 | ||
|
|
a5c488449e | ||
|
|
61f6db130e | ||
|
|
a63d09a517 | ||
|
|
b01ed65ad2 | ||
|
|
0b0d393347 | ||
|
|
4a2dcd904c | ||
|
|
7c512439b2 | ||
|
|
f60d4b491a | ||
|
|
27cb6846d7 | ||
|
|
a3bb3e6e0b | ||
|
|
fd10c70521 | ||
|
|
1c25ba9de1 | ||
|
|
b6071ea5cb | ||
|
|
655d814d75 | ||
|
|
a0b3705fa1 | ||
|
|
f0f754aeaf | ||
|
|
9d9cecfd63 | ||
|
|
3c8bca364d | ||
|
|
25ea42de9b | ||
|
|
908e362133 | ||
|
|
9d7f0f0fe8 | ||
|
|
dd92c77bb0 | ||
|
|
0cc7e6236a | ||
|
|
2a41ec6c63 | ||
|
|
1b2e7c3b2a | ||
|
|
c9e7024924 | ||
|
|
0f08e53535 | ||
|
|
8876fb2f59 | ||
|
|
dfce3536ac | ||
|
|
a8da17acef | ||
|
|
fa7532b91a | ||
|
|
b838420fd5 | ||
|
|
24833430bc | ||
|
|
6c43f743a3 | ||
|
|
a721204ec5 | ||
|
|
a9e4617494 | ||
|
|
138d71bc35 | ||
|
|
7aa62cf173 | ||
|
|
233b170a85 | ||
|
|
d130973f34 | ||
|
|
82ab3d7c3e | ||
|
|
b0cfca7544 | ||
|
|
a2d1982841 | ||
|
|
fab3e12cec | ||
|
|
64191c3896 | ||
|
|
2faee7b1ed | ||
|
|
393183dccc | ||
|
|
ddfe18df75 | ||
|
|
46ba568fc0 | ||
|
|
d4f90ed37e | ||
|
|
787ff55a69 | ||
|
|
4fe3ff8cff | ||
|
|
0861e828d0 | ||
|
|
900c8f3362 | ||
|
|
d3af409eae | ||
|
|
874e3381db | ||
|
|
0a3b0106ab | ||
|
|
c9163fee91 | ||
|
|
49e74effbc | ||
|
|
74fcbb0f7d | ||
|
|
1e11c34be4 | ||
|
|
8c6887c855 | ||
|
|
7b3edeb14d | ||
|
|
a860bec167 | ||
|
|
7a54360cd4 | ||
|
|
f01b805d91 | ||
|
|
c91ce57099 | ||
|
|
c5408fe7f7 | ||
|
|
26df70a823 | ||
|
|
e2aed7ffd7 | ||
|
|
91e1978ff0 | ||
|
|
69f28e7c0c | ||
|
|
fbf0b8af41 | ||
|
|
86f2cce6bf | ||
|
|
2c1de61023 | ||
|
|
afc01cd485 | ||
|
|
923dd79af7 | ||
|
|
35a5b08eee | ||
|
|
6f9a0d4bbb | ||
|
|
4a11e0fb45 | ||
|
|
2894266f12 | ||
|
|
343658582b | ||
|
|
7cb6ef7982 | ||
|
|
fc4cb4dbb5 | ||
|
|
d4185b0e15 | ||
|
|
d7fe39b587 | ||
|
|
d87a7ac269 | ||
|
|
2410386611 | ||
|
|
bd9b32bc0d | ||
|
|
8d6395d41a | ||
|
|
c1d95076f0 | ||
|
|
7ce9e247f0 | ||
|
|
c6adada158 | ||
|
|
4957fc7a93 | ||
|
|
8353fe9298 | ||
|
|
982da3e6b4 | ||
|
|
4762a48166 | ||
|
|
0c236a09ed | ||
|
|
8320b425a3 | ||
|
|
a71c7047cf | ||
|
|
f3def2792b | ||
|
|
1b6dfa7066 | ||
|
|
9a52bb6878 | ||
|
|
30b47df86b | ||
|
|
f01b46d7dd | ||
|
|
0c51832b60 | ||
|
|
b5b5ac3237 | ||
|
|
a0f0f0cf76 | ||
|
|
595a6a4199 | ||
|
|
ccd43a8301 | ||
|
|
b08e3e8c2e | ||
|
|
961c6c19da | ||
|
|
56c633c139 | ||
|
|
c949bfa555 | ||
|
|
3a9b0bf0ba | ||
|
|
4baef0c77f | ||
|
|
ea4c43445c | ||
|
|
1cb1b64c35 | ||
|
|
4eff18189a | ||
|
|
cad5364599 | ||
|
|
e01f9662a5 | ||
|
|
2971ef1730 | ||
|
|
737f5fb890 | ||
|
|
d2b8118650 | ||
|
|
c3b2dbec8c | ||
|
|
92b7e7baa1 | ||
|
|
3f1cf455a0 | ||
|
|
e68afefe56 | ||
|
|
4157a8a71e | ||
|
|
ff724fb076 | ||
|
|
bed4033e96 | ||
|
|
f3bd7c4631 | ||
|
|
f50ce3135f | ||
|
|
4c6523a90b | ||
|
|
e7a8bc949b | ||
|
|
1fb446795d | ||
|
|
2f8a401772 | ||
|
|
d5eadea970 | ||
|
|
505bd0f15a | ||
|
|
77831c11d1 | ||
|
|
3719e9e790 | ||
|
|
1bc5fa8c0c | ||
|
|
6067c08145 | ||
|
|
2afcbe436f | ||
|
|
a9c6bc41e9 | ||
|
|
bae7c1ac24 | ||
|
|
08f4a4c508 | ||
|
|
5ef448285b | ||
|
|
a0ac4523b1 | ||
|
|
ee6da5527c | ||
|
|
008c01915b | ||
|
|
ae0f1e7052 | ||
|
|
4a4c677fcc | ||
|
|
3238ea1673 | ||
|
|
858fad722f | ||
|
|
496411b489 | ||
|
|
c2843563f3 | ||
|
|
ae494a9086 | ||
|
|
b1207b3320 | ||
|
|
3d2405cfb3 | ||
|
|
18d8a3b7e3 | ||
|
|
883d4842d2 | ||
|
|
826b48b624 | ||
|
|
a837e2d9b3 | ||
|
|
06e9565b6c | ||
|
|
877d418b39 | ||
|
|
def85e8752 | ||
|
|
1d21fb3c23 | ||
|
|
cc616928d5 | ||
|
|
a88cb5025c | ||
|
|
3aeaee33b6 | ||
|
|
b4f3d7f594 | ||
|
|
cb665093b8 | ||
|
|
a486f469cb | ||
|
|
46c203a6ce | ||
|
|
21110a0aa2 | ||
|
|
a99534354a | ||
|
|
66a3af9d7c | ||
|
|
22237017a7 | ||
|
|
ee9441f848 | ||
|
|
bf77f61d69 | ||
|
|
853c494efd | ||
|
|
97d86f2bb5 | ||
|
|
be65c350ae | ||
|
|
889dd20c69 | ||
|
|
8eb214edbd | ||
|
|
d8fdf0c57d | ||
|
|
6393d69f76 | ||
|
|
6af21c2afa | ||
|
|
9e5d6c002c | ||
|
|
4c51202b9d | ||
|
|
5cc9ada0e4 | ||
|
|
2e51a14d57 | ||
|
|
aad465efb7 | ||
|
|
a9adef0394 | ||
|
|
e6ae6e3d39 | ||
|
|
f2ba45e339 | ||
|
|
77c60e5c66 | ||
|
|
8573704097 | ||
|
|
147a3ca1a4 | ||
|
|
fc4a0fd82e | ||
|
|
85d9d80db8 | ||
|
|
ab4e19afc6 | ||
|
|
92a06d0943 | ||
|
|
8004bb7661 | ||
|
|
e0716ba23b | ||
|
|
4b525addb8 | ||
|
|
65ddf77fbd | ||
|
|
b4a1baa312 | ||
|
|
d66370cd73 | ||
|
|
4e486a5d00 | ||
|
|
1dcf218e60 | ||
|
|
575c78274a | ||
|
|
b1c9469f65 | ||
|
|
aaab46baba | ||
|
|
f05fd444e8 | ||
|
|
e931909d2d | ||
|
|
9e59841375 | ||
|
|
dd3461af2f | ||
|
|
a69fd2ecf6 | ||
|
|
e40500f9cb | ||
|
|
7040ecc993 | ||
|
|
4d00129d0f | ||
|
|
58c708af23 | ||
|
|
c2e74ca934 | ||
|
|
ea2a1064b3 | ||
|
|
39dd4011e4 | ||
|
|
4dcc2ddfcc | ||
|
|
2c24bb80f9 | ||
|
|
7ce75f44ae | ||
|
|
a6685585d8 | ||
|
|
87444efbab | ||
|
|
d4c8d1a97f | ||
|
|
76ff0da4d2 | ||
|
|
c00c56e7c8 | ||
|
|
0a65e190f4 | ||
|
|
4d7f965c8e | ||
|
|
e86e4a2282 | ||
|
|
0f18271a8a | ||
|
|
1643f41986 | ||
|
|
688cf014af | ||
|
|
cf1fee06a5 | ||
|
|
be2ae246fb | ||
|
|
53f133ac33 | ||
|
|
275be87be7 | ||
|
|
1e132dd4dd | ||
|
|
cf93274663 | ||
|
|
6fe1960ff5 | ||
|
|
068b6b07ff | ||
|
|
c118f99f73 | ||
|
|
8b08bda66b | ||
|
|
25fe94fd32 | ||
|
|
a67dffe186 | ||
|
|
3b33dd9b1e | ||
|
|
02d7cbfe92 | ||
|
|
f03c933e47 | ||
|
|
9130c85847 | ||
|
|
6ed77595f1 | ||
|
|
6d07432b2f | ||
|
|
b8dff0c2a2 | ||
|
|
b2bfd34a7b | ||
|
|
1f1c3f9485 | ||
|
|
54fde9ea5c | ||
|
|
f4b273cbb4 | ||
|
|
9f4395c54e | ||
|
|
920c1e8d6c | ||
|
|
9701411d21 | ||
|
|
49b0f86043 | ||
|
|
4501dbe509 | ||
|
|
1eb7a17b12 | ||
|
|
d7e1a6c6eb | ||
|
|
392947c860 | ||
|
|
ece8fc2b9b | ||
|
|
29f9b2fbdb | ||
|
|
80ff9449bf | ||
|
|
0552b9a7ff | ||
|
|
84cc4e7e3e | ||
|
|
acd244af1c | ||
|
|
8882ea53d5 | ||
|
|
39438c7c17 | ||
|
|
b323162aab | ||
|
|
11adab0535 | ||
|
|
7b4e89b9e3 | ||
|
|
38386d7fed | ||
|
|
b72a735a32 | ||
|
|
62fae308a3 | ||
|
|
9bf9f1edbe | ||
|
|
919798d5a8 | ||
|
|
a94c3108b1 | ||
|
|
584baeb47d | ||
|
|
fad90db887 | ||
|
|
fdbbb04893 | ||
|
|
6b5bd0e5ab | ||
|
|
c4698b3668 | ||
|
|
a6bbf7929c | ||
|
|
35631a6e00 | ||
|
|
e167d69309 | ||
|
|
8e49caa54f | ||
|
|
66125c8065 | ||
|
|
346cdb1dde | ||
|
|
4a6b4e393c | ||
|
|
4e05b9b043 | ||
|
|
0325a1c9e3 | ||
|
|
1d658263e8 | ||
|
|
80a60419f7 | ||
|
|
75360f951f | ||
|
|
f795b027c6 | ||
|
|
0337c467a0 | ||
|
|
a6b9051e16 | ||
|
|
110ee23515 | ||
|
|
27e99c8f09 | ||
|
|
cc2bc454d1 | ||
|
|
b077c9f47d | ||
|
|
da15a496e2 | ||
|
|
398ff9d981 | ||
|
|
cdbe5e5d4c | ||
|
|
9227371b71 | ||
|
|
83fdb317a7 | ||
|
|
23b5146247 | ||
|
|
536018278a | ||
|
|
f0a360ea19 | ||
|
|
08c358b604 | ||
|
|
c9f20d9fb9 | ||
|
|
deca106b6d | ||
|
|
6f9b45b9ef | ||
|
|
350d26bbbb | ||
|
|
3ba7ceebfc | ||
|
|
7127b58baa | ||
|
|
bf91f2eb1b | ||
|
|
69b5756594 | ||
|
|
09adaca37d | ||
|
|
06b1aeaf0a | ||
|
|
2626ef613e | ||
|
|
18eae0031a | ||
|
|
c82f2324bd | ||
|
|
b963875a3e | ||
|
|
f112daa232 | ||
|
|
f3faf41334 | ||
|
|
b9e57f45f3 | ||
|
|
941eb80795 | ||
|
|
e1ad672216 | ||
|
|
6fc6d7fe4f | ||
|
|
4d4ef19c76 | ||
|
|
82d2cd4ead | ||
|
|
1b0813ab61 | ||
|
|
d4de975cd2 | ||
|
|
8b6024449f | ||
|
|
e3e2a7b41c | ||
|
|
a170e1c858 | ||
|
|
1652855fbc | ||
|
|
eaed78a91f | ||
|
|
cdf142af90 | ||
|
|
9048ae5923 | ||
|
|
df72536f8e | ||
|
|
68d949956a | ||
|
|
b2e28a0e35 | ||
|
|
b122217d90 | ||
|
|
642f28903a | ||
|
|
30db423e11 | ||
|
|
efdd0aed23 | ||
|
|
d7d5f42934 | ||
|
|
d4036f86e5 | ||
|
|
d211214d42 | ||
|
|
fedbfe4059 | ||
|
|
8e027f6474 | ||
|
|
6ead3abd55 | ||
|
|
9c802416ab | ||
|
|
73ceca275e | ||
|
|
2601559fb6 | ||
|
|
10d905ce27 | ||
|
|
062c74f710 | ||
|
|
ec87d37305 | ||
|
|
441e7efc72 | ||
|
|
0ff941e1c3 | ||
|
|
8ae4cab4a8 | ||
|
|
c5dced17c5 | ||
|
|
2f79f5b60d | ||
|
|
efc6fbd452 | ||
|
|
a2e24825a2 | ||
|
|
d7fb1b372c | ||
|
|
2801eb925d | ||
|
|
12371f916b | ||
|
|
f66de64a11 | ||
|
|
393ad1a834 | ||
|
|
bb2e9d47f3 | ||
|
|
5b110874df | ||
|
|
822e7fd587 | ||
|
|
eda4f53f2e | ||
|
|
7b1eca265a | ||
|
|
b7a76df4d1 | ||
|
|
1b16bf6b1b | ||
|
|
77dbaa48df | ||
|
|
2997fca414 | ||
|
|
30a35d20d9 | ||
|
|
f23fdf1717 | ||
|
|
2f1f898228 | ||
|
|
157fea5960 | ||
|
|
82701e4d67 | ||
|
|
83bf47c02f | ||
|
|
0126fda5bb | ||
|
|
efe7889086 | ||
|
|
d1431073d1 | ||
|
|
83bcba26c0 | ||
|
|
a0d395eac9 | ||
|
|
ae01fa99e1 | ||
|
|
50c00f4b45 | ||
|
|
29d801b834 | ||
|
|
fd73b8c2ce | ||
|
|
36233bdd71 | ||
|
|
39289b54a7 | ||
|
|
02fcd2d2df | ||
|
|
5780adb586 | ||
|
|
2666679692 | ||
|
|
09eb000d7a | ||
|
|
f870148a04 | ||
|
|
e356883ffb | ||
|
|
034c371bb2 | ||
|
|
9af8a72f10 | ||
|
|
545106f8db | ||
|
|
8f0722a53b | ||
|
|
c11986d89e | ||
|
|
912d8f4cbc | ||
|
|
f234e7c755 | ||
|
|
e16860df08 | ||
|
|
3ff3f4ac35 | ||
|
|
59870e89ae | ||
|
|
f57674e9a9 | ||
|
|
907a240b1c | ||
|
|
5a7ec22c49 | ||
|
|
eebe31d997 | ||
|
|
49a28b3b5e | ||
|
|
8ae75013c8 | ||
|
|
9a2d27249c | ||
|
|
021fa7db91 | ||
|
|
7ab93d9980 | ||
|
|
5703341123 | ||
|
|
f6bf7a03fe | ||
|
|
b26674b2f8 | ||
|
|
1713a11a26 | ||
|
|
ef5e8f8de0 | ||
|
|
f9496d4e44 | ||
|
|
62d28828d6 | ||
|
|
747381c602 | ||
|
|
ea12202288 | ||
|
|
0288c8e543 | ||
|
|
da970859da | ||
|
|
d8d1191505 | ||
|
|
7f2a95319b | ||
|
|
18bbca18ac | ||
|
|
8e94098423 | ||
|
|
f92caa7619 | ||
|
|
237ae42fc9 | ||
|
|
2fc54a9258 | ||
|
|
6ab32eb34c | ||
|
|
b8e556e5f5 | ||
|
|
9c60b29071 | ||
|
|
60bce4905c | ||
|
|
97b141ac69 | ||
|
|
bf1cc8b1b7 | ||
|
|
d6aec8619d | ||
|
|
9ef0944456 | ||
|
|
b2f67b4068 | ||
|
|
563ac6e789 | ||
|
|
f5ecd43473 | ||
|
|
1b6eb9b6eb | ||
|
|
df5b8679a2 | ||
|
|
69051e817c | ||
|
|
db1df5ebeb | ||
|
|
fda2b7ff47 | ||
|
|
12f834ccfc | ||
|
|
18921bd00d | ||
|
|
5ad22c933c | ||
|
|
09da627a23 | ||
|
|
080ddc1c19 | ||
|
|
5e02c67331 | ||
|
|
fe5b1a9f3c | ||
|
|
72e1212ad8 | ||
|
|
f02c26f1ef | ||
|
|
f6f7bfb8e0 | ||
|
|
44608e9693 | ||
|
|
1887b0478f | ||
|
|
5956028f6f | ||
|
|
9ffd5776eb | ||
|
|
0d53ebdc52 | ||
|
|
4298e87fa5 | ||
|
|
61b7904afd | ||
|
|
c5c1a8a112 | ||
|
|
05fa661123 | ||
|
|
25bca9566d | ||
|
|
98f824aa22 | ||
|
|
934805aec1 | ||
|
|
2a2ab1479c | ||
|
|
431a18497d | ||
|
|
31f9747a23 | ||
|
|
d69e31fb93 | ||
|
|
1977a60de4 | ||
|
|
61fb48930f | ||
|
|
9060a73159 | ||
|
|
e8a90fb2bc | ||
|
|
71ae64bdc6 | ||
|
|
fdfe298a96 | ||
|
|
d274b53c1d | ||
|
|
1bb1e83454 | ||
|
|
adb058b0de | ||
|
|
a39342b131 | ||
|
|
528649463f | ||
|
|
2983330512 | ||
|
|
e0f5500bb5 | ||
|
|
506177df7f | ||
|
|
08a72209c9 | ||
|
|
02e6ba91e8 | ||
|
|
a6f6e06107 | ||
|
|
ad082987d0 | ||
|
|
d9d47c3078 | ||
|
|
aa1d6ccbfb | ||
|
|
6a9799020b | ||
|
|
e4d2a43951 | ||
|
|
5c99581880 | ||
|
|
924f93e848 | ||
|
|
891ee641cb | ||
|
|
8132e933e6 | ||
|
|
92052e3945 | ||
|
|
2e41d0cb77 | ||
|
|
a47a3eada6 | ||
|
|
6f2ebcaa01 | ||
|
|
a920871c3a | ||
|
|
5a66b640f9 | ||
|
|
69eab26401 | ||
|
|
7ca04f328e | ||
|
|
ecfa290cfd | ||
|
|
b3f7261ffe | ||
|
|
3a1d8377ab | ||
|
|
19feada06f | ||
|
|
7695b7b5f4 | ||
|
|
d499330e9e | ||
|
|
06c35da6af | ||
|
|
420b208a45 | ||
|
|
793c3b4a7d | ||
|
|
dc180d1442 | ||
|
|
6c32a8add4 | ||
|
|
60943c5d5c | ||
|
|
39ad2833c0 | ||
|
|
871d93c462 | ||
|
|
927c3bdc18 | ||
|
|
a9a220b92a | ||
|
|
bf8bf105fb | ||
|
|
34fd00af5f | ||
|
|
7365c58783 | ||
|
|
bdff6a4c59 | ||
|
|
d4ee98940b | ||
|
|
02b8dfc524 | ||
|
|
403a73a351 | ||
|
|
18b76e6f80 | ||
|
|
8fede28c74 | ||
|
|
a9cc8961ed | ||
|
|
e18cb71e0c | ||
|
|
c38678d14b | ||
|
|
166fa4684f | ||
|
|
061c900176 | ||
|
|
ebdc8b48a5 | ||
|
|
ec0c48cb29 | ||
|
|
6714862bdd | ||
|
|
7a32aaacd0 | ||
|
|
b3c4e9add5 | ||
|
|
186685d46f | ||
|
|
4d0884a1ea | ||
|
|
7829b8d067 | ||
|
|
2a1eb31f18 | ||
|
|
2bec97c076 | ||
|
|
1130976f8e | ||
|
|
c3b7f7d6e7 | ||
|
|
193697db4e | ||
|
|
210aa14916 | ||
|
|
abac53b33c | ||
|
|
1ee52e8b14 | ||
|
|
933d10d308 | ||
|
|
fbef225c4b | ||
|
|
192ff35d9c | ||
|
|
0be933b505 | ||
|
|
50812fff21 | ||
|
|
de9e803149 | ||
|
|
e599b6d96e | ||
|
|
7dd2cec2fd | ||
|
|
84878fe20e | ||
|
|
0df910af49 | ||
|
|
5d3cb7cc1f | ||
|
|
8042f65398 | ||
|
|
acfc0d872e | ||
|
|
03195fc16f | ||
|
|
a199b17253 | ||
|
|
14dad7028b | ||
|
|
1ed9dd9d06 | ||
|
|
4534af2763 | ||
|
|
0775a07d87 | ||
|
|
4cc2e5e944 | ||
|
|
9fef17dec3 | ||
|
|
7c58e9be69 | ||
|
|
baf55a85fc | ||
|
|
e3906fcd94 | ||
|
|
99b12543cf | ||
|
|
242e3b6bde | ||
|
|
60a22addea | ||
|
|
a0ee881ba4 | ||
|
|
4176972db5 | ||
|
|
d827e8b665 | ||
|
|
b37367aa77 | ||
|
|
f853db54f9 | ||
|
|
75762705a3 | ||
|
|
419eed7501 | ||
|
|
5f8f32a41c | ||
|
|
8fc5d6d2da | ||
|
|
6fdacc74f0 | ||
|
|
a95e99e6f3 | ||
|
|
d9768d7cb9 | ||
|
|
1ff58b6570 | ||
|
|
8eb0dc1d10 | ||
|
|
3d184586a7 | ||
|
|
938e982c4d | ||
|
|
1d23f3a492 | ||
|
|
6069441bd2 | ||
|
|
91a0aac110 | ||
|
|
2ab6ff95e0 | ||
|
|
65d415d847 | ||
|
|
00f5ecb141 | ||
|
|
7940147e25 | ||
|
|
edcac5572f | ||
|
|
f8277ca992 | ||
|
|
74b007f7cc | ||
|
|
c59716ff4c | ||
|
|
6859d761d3 | ||
|
|
0d833ca7fd | ||
|
|
49c024addd | ||
|
|
e85dbfdd80 | ||
|
|
a71389bfe8 | ||
|
|
7373e485d3 | ||
|
|
87715170cc | ||
|
|
b230159958 | ||
|
|
df03932b7e | ||
|
|
70112da81a | ||
|
|
e707806894 | ||
|
|
3bc2b206b0 | ||
|
|
aead70b4d1 | ||
|
|
d0dd3d31e2 | ||
|
|
2a4a8d8ffb | ||
|
|
31a2e20bd3 | ||
|
|
41369af3f2 | ||
|
|
80cd3cfdbc | ||
|
|
f2f26e7fdd | ||
|
|
967c3d4406 | ||
|
|
1cd0445495 | ||
|
|
fc78b79575 | ||
|
|
efd4983eb1 | ||
|
|
d378c3149c | ||
|
|
88947dd05e | ||
|
|
2c0d0f0051 | ||
|
|
e4f9f3a960 | ||
|
|
0fe3e62e2c | ||
|
|
d2fd0d5869 | ||
|
|
acc257e994 | ||
|
|
e8fcf4bd69 | ||
|
|
2276d83639 | ||
|
|
cafc103230 | ||
|
|
1785ddcae2 | ||
|
|
8e139871fe | ||
|
|
0826b6b0b3 | ||
|
|
887ca79f04 | ||
|
|
360e254954 | ||
|
|
0b31586c71 | ||
|
|
51b8bd68bb | ||
|
|
599e3ce163 | ||
|
|
935daf2d0d | ||
|
|
7f90ed4460 | ||
|
|
796446718d | ||
|
|
8c4025e708 | ||
|
|
5222d31a15 | ||
|
|
549df2ebc3 | ||
|
|
7234c3a0b6 | ||
|
|
009ae1f17d | ||
|
|
abc9568690 | ||
|
|
b493dec91e | ||
|
|
69d4178708 | ||
|
|
9031481ac3 | ||
|
|
ed11993900 | ||
|
|
8c26fbe537 | ||
|
|
5b0f9e417e | ||
|
|
27f64e1f4e | ||
|
|
0fbff134f4 | ||
|
|
b0c39a8a8d | ||
|
|
3ece93ba0f | ||
|
|
8b1aa4d749 | ||
|
|
61f83059c1 | ||
|
|
9f92d5f2a2 | ||
|
|
2d34215456 | ||
|
|
b0fd2b06a3 | ||
|
|
a7d0b41c08 | ||
|
|
47abc49c4a | ||
|
|
3ad88ccf2d | ||
|
|
9ef2ea27d4 | ||
|
|
360060252a | ||
|
|
0c789a4255 | ||
|
|
fe1ef2bc62 | ||
|
|
6fb4e4877a | ||
|
|
0d2d1eb599 | ||
|
|
8610f91ebf | ||
|
|
27d3766e0d | ||
|
|
ad79c0b629 | ||
|
|
77d22c4abd | ||
|
|
1a92376f00 | ||
|
|
e90e741b1e | ||
|
|
fc059090b6 | ||
|
|
ff7661d9de | ||
|
|
1fca558799 | ||
|
|
ea1a63a201 | ||
|
|
c9aca4561d | ||
|
|
bc28f7a1e1 | ||
|
|
c06391be0d | ||
|
|
3b79370a7d | ||
|
|
b99cb64b80 | ||
|
|
a94a06a38e | ||
|
|
1d4ef2a9e9 | ||
|
|
53146cc9ec | ||
|
|
8302c43265 | ||
|
|
cffd5022c5 | ||
|
|
d11edf9809 | ||
|
|
236abbfd71 | ||
|
|
94a6a956f0 | ||
|
|
c6def44cfc | ||
|
|
13c26fc1a5 | ||
|
|
c30c5e89cf | ||
|
|
d8636cad4d | ||
|
|
f6495eb767 | ||
|
|
7ac868460a | ||
|
|
081df62b92 | ||
|
|
52e8d060a9 | ||
|
|
d77601178d | ||
|
|
64f70cc755 | ||
|
|
8187bb4394 | ||
|
|
820098fd61 | ||
|
|
aa385d4015 | ||
|
|
f63a20ad7b | ||
|
|
864b79791a | ||
|
|
26920c6c94 | ||
|
|
c088c582bf | ||
|
|
95bf6da637 | ||
|
|
a4a65e7f99 | ||
|
|
051e4c15db | ||
|
|
d598d41110 | ||
|
|
1372780662 | ||
|
|
3a01f8cae2 | ||
|
|
ef38b39262 | ||
|
|
aba75460e4 | ||
|
|
1323c940fd | ||
|
|
00a6a75035 | ||
|
|
1c31501b1b | ||
|
|
416340642d | ||
|
|
8db361b3e5 | ||
|
|
ed8e036360 | ||
|
|
86c76a9c2a | ||
|
|
0e28e1fa05 | ||
|
|
60e56f5292 | ||
|
|
54c14d7850 | ||
|
|
ae1036185e | ||
|
|
5f6873621d | ||
|
|
272a95524f | ||
|
|
a0782684fd | ||
|
|
744ec1d549 | ||
|
|
9fe5f98de4 | ||
|
|
c8459a5a8f | ||
|
|
19732c6226 | ||
|
|
4e116823f4 | ||
|
|
fb24eb4f47 | ||
|
|
defd998c42 | ||
|
|
1f30a41abe | ||
|
|
5d8d4a674b | ||
|
|
65a0730c9f | ||
|
|
3e6908b586 | ||
|
|
db7d5fca5f | ||
|
|
4c9b68f0e0 | ||
|
|
a66a43e8ef | ||
|
|
d75ac02a4f | ||
|
|
114de55668 | ||
|
|
1d1d2f9b18 | ||
|
|
497a88506e | ||
|
|
85208e2ab9 | ||
|
|
b1591d1f8b | ||
|
|
a3603e845e | ||
|
|
265d229427 | ||
|
|
fcffa2cc1a | ||
|
|
50e4d660ac | ||
|
|
45673d2cc0 | ||
|
|
5c69cd84ff | ||
|
|
75ce8d7c88 | ||
|
|
130bec5ad8 | ||
|
|
ae28b04ff2 | ||
|
|
c57e42b8f0 | ||
|
|
8a8308f129 | ||
|
|
66388f89a5 | ||
|
|
50aec98e1c | ||
|
|
6feaeace86 | ||
|
|
cf32ac543c | ||
|
|
35d60421b4 | ||
|
|
9cdb0601eb | ||
|
|
fa15f702d2 | ||
|
|
ef8b112d77 | ||
|
|
b88868276c | ||
|
|
83788da250 | ||
|
|
27eff033d2 | ||
|
|
c7a3fb96d0 | ||
|
|
b0cc0a6ca8 | ||
|
|
889a301a0c | ||
|
|
900c24dc4e | ||
|
|
5a40651046 | ||
|
|
89de1e7930 | ||
|
|
b5474c48b1 | ||
|
|
b159146fa6 | ||
|
|
3ad0bd9563 | ||
|
|
3ec5c692ec | ||
|
|
aee53f4604 | ||
|
|
b3de66869b | ||
|
|
0efab3319d | ||
|
|
3b1cbd7bec | ||
|
|
38ddbed4c1 | ||
|
|
08ed1a73f1 | ||
|
|
806c74fe19 | ||
|
|
f64c1cd26d | ||
|
|
a1bbde71bf | ||
|
|
3bd31ebc9a | ||
|
|
372f91f07c | ||
|
|
bc12fb79fd | ||
|
|
1b17b01584 | ||
|
|
0298be88ae | ||
|
|
684d745bf3 | ||
|
|
02a4ed9264 | ||
|
|
49da8a83ad | ||
|
|
a99b194336 | ||
|
|
eed9451cf6 | ||
|
|
fa144713b8 | ||
|
|
6b140ea5a9 | ||
|
|
7c71822809 | ||
|
|
b5b757eb8d | ||
|
|
6be2319873 | ||
|
|
ad6faf6497 | ||
|
|
4271d438e2 | ||
|
|
d4574f1b61 | ||
|
|
c00e4ff8e5 | ||
|
|
3b7767abe6 | ||
|
|
796245b554 | ||
|
|
8fd6e1fb0f | ||
|
|
d7f7bd0445 | ||
|
|
02a415606c | ||
|
|
8833a51781 | ||
|
|
9bd49d6a22 | ||
|
|
592a3e63ee | ||
|
|
273af73317 | ||
|
|
eb83478528 | ||
|
|
369da77d5e | ||
|
|
20d739adf7 | ||
|
|
53a2299230 | ||
|
|
467a18b1d9 | ||
|
|
a3181dd833 | ||
|
|
ba552523fa | ||
|
|
d35c5df08c | ||
|
|
b75b6e2c35 | ||
|
|
038cbc7442 | ||
|
|
c94e89d81f | ||
|
|
db2b9f37d4 | ||
|
|
8ec99dfa05 | ||
|
|
d402f971a5 | ||
|
|
eeba178d3a | ||
|
|
7d957c6573 | ||
|
|
665b4e69ed | ||
|
|
7875f5b72a | ||
|
|
55ed17747f | ||
|
|
4fa2bb5e95 | ||
|
|
9eaf059d28 | ||
|
|
5ed78adca5 | ||
|
|
d299563257 | ||
|
|
9758e7d58d | ||
|
|
f3fbe20c35 | ||
|
|
01d2ea908b | ||
|
|
39fcb5a750 | ||
|
|
0733e840bd | ||
|
|
d21735de2d | ||
|
|
87ac7028e0 | ||
|
|
438803311b | ||
|
|
9a218bf979 | ||
|
|
1a6986699f | ||
|
|
eec2bbb9bf | ||
|
|
2aef3a6bb9 | ||
|
|
95877b6756 | ||
|
|
79a466f128 | ||
|
|
6d13964714 | ||
|
|
e7dd383f67 | ||
|
|
b9c0b99e51 | ||
|
|
70624846fd | ||
|
|
1fcc66e685 | ||
|
|
ceef50b280 | ||
|
|
f1f2bd0b0a | ||
|
|
9910cd2869 | ||
|
|
1f0c43668a | ||
|
|
31c73af656 | ||
|
|
2b1effdbbc | ||
|
|
c5b5cab37d | ||
|
|
38c15becf6 | ||
|
|
5a841adf5d | ||
|
|
fb74a45088 | ||
|
|
f3f9062ecf | ||
|
|
730f826f25 | ||
|
|
ace02dc9cd | ||
|
|
46ea0e4696 | ||
|
|
6925d50176 | ||
|
|
de2a342289 | ||
|
|
e62dc86bc7 | ||
|
|
04ae328851 | ||
|
|
14b7c5d12b | ||
|
|
741f40b58e | ||
|
|
72812d3143 | ||
|
|
a2e6908165 | ||
|
|
90c2abd212 | ||
|
|
dec43433e5 | ||
|
|
2423b12dae | ||
|
|
05b5addcaa | ||
|
|
07a37aebf5 | ||
|
|
dba11452cb | ||
|
|
1a781a499f | ||
|
|
603557b466 | ||
|
|
089db51fbe | ||
|
|
3eeab3b23f | ||
|
|
6834ee941a | ||
|
|
54805af092 | ||
|
|
c98c06233e | ||
|
|
b24d65659f | ||
|
|
06656f363d | ||
|
|
db930948a9 | ||
|
|
463304edfd | ||
|
|
356b6dbf86 | ||
|
|
0ee0a8d539 | ||
|
|
b6ecbdc07d | ||
|
|
ebd8065f38 | ||
|
|
2dd2d7a37d | ||
|
|
b9df470c4d | ||
|
|
249f39a265 | ||
|
|
ef03dbcd4d | ||
|
|
aad44fb37a | ||
|
|
3280f9a3fc | ||
|
|
6509f92a3b | ||
|
|
1dbbd2fe34 | ||
|
|
ed8a9be287 | ||
|
|
c3657428d3 | ||
|
|
38288bbf4c | ||
|
|
8a35c9a557 | ||
|
|
9e6c9f7311 | ||
|
|
74afa9aed1 | ||
|
|
c29ab97094 | ||
|
|
1477ad8e83 | ||
|
|
02d090d3d2 | ||
|
|
2480e3a30a | ||
|
|
1dbd6ff80f | ||
|
|
585f657e2d | ||
|
|
0c390a76fe | ||
|
|
fd3f1be57f | ||
|
|
355a61b56f | ||
|
|
66c22051f9 | ||
|
|
dbdc0d5da9 | ||
|
|
4d7f9c3d99 |
No files matched your search
@@ -3,3 +3,5 @@ busybox.links
|
||||
_install
|
||||
.config
|
||||
.menuconfig.log
|
||||
.config.cmd
|
||||
.config.old
|
||||
@@ -8,14 +8,23 @@ incorect, _please_ let me know.
|
||||
|
||||
-----------
|
||||
|
||||
Erik Andersen <andersen@codepoet.org>, <andersee@debian.org>
|
||||
Emanuele Aina <emanuele.aina@tiscali.it>
|
||||
run-parts
|
||||
|
||||
Erik Andersen <andersen@codepoet.org>, <andersen@codepoet.org>
|
||||
Tons of new stuff, major rewrite of most of the
|
||||
core apps, tons of new apps as noted in header files.
|
||||
|
||||
Laurence Anderson <l.d.anderson@warwick.ac.uk>
|
||||
rpm2cpio, unzip, get_header_cpio, read_gz interface, rpm
|
||||
|
||||
Jeff Angielski <jeff@theptrgroup.com>
|
||||
ftpput, ftpget
|
||||
|
||||
Edward Betts <edward@debian.org>
|
||||
expr, hostid, logname, tty, wc, whoami, yes
|
||||
|
||||
John Beppu <beppu@lineo.com>
|
||||
John Beppu <beppu@codepoet.org>
|
||||
du, head, nslookup, sort, tee, uniq
|
||||
|
||||
Brian Candler <B.Candler@pobox.com>
|
||||
@@ -28,6 +37,9 @@ Dave Cinege <dcinege@psychosis.com>
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
|
||||
Jordan Crouse <jordan@cosmicpenguin.net>
|
||||
ipcalc
|
||||
|
||||
Magnus Damm <damm@opensource.se>
|
||||
tftp client
|
||||
insmod powerpc support
|
||||
@@ -35,7 +47,10 @@ Magnus Damm <damm@opensource.se>
|
||||
Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
pristine source directory compilation, lots of patches and fixes.
|
||||
|
||||
Gennady Feldman <gfeldman@cachier.com>
|
||||
Glenn Engel <glenne@engel.org>
|
||||
httpd
|
||||
|
||||
Gennady Feldman <gfeldman@gena01.com>
|
||||
Sysklogd (single threaded syslogd, IPC Circular buffer support,
|
||||
logread), various fixes.
|
||||
|
||||
@@ -45,9 +60,12 @@ Karl M. Hegbloom <karlheg@debian.org>
|
||||
Daniel Jacobowitz <dan@debian.org>
|
||||
mktemp.c
|
||||
|
||||
Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
Matt Kraai <kraai@alumni.cmu.edu>
|
||||
documentation, bugfixes, test suite
|
||||
|
||||
Stephan Linz <linz@li-pro.net>
|
||||
ipcalc, Red Hat equivalence
|
||||
|
||||
John Lombardo <john@deltanet.com>
|
||||
dirname, tr
|
||||
|
||||
@@ -55,17 +73,20 @@ Glenn McGrath <bug1@optushome.com.au>
|
||||
ar, dpkg, dpkg-deb
|
||||
|
||||
Vladimir Oleynik <dzo@simtreas.ru>
|
||||
cmdedit; ports: ash, stty, traceroute; locale, various fixes
|
||||
cmdedit; xargs(current), httpd(current);
|
||||
ports: ash, crond, fdisk, inetd, stty, traceroute, top;
|
||||
locale, various fixes
|
||||
and irreconcilable critic of everything not perfect.
|
||||
|
||||
Bruce Perens <bruce@pixar.com>
|
||||
Original author of BusyBox. His code is still in many apps.
|
||||
Original author of BusyBox in 1995, 1996. Some of his code can
|
||||
still be found hiding here and there...
|
||||
|
||||
Tim Riker <Tim@Rikers.org>
|
||||
bug fixes, member of fan club
|
||||
|
||||
Kent Robotti <robotti@metconnect.com>
|
||||
reset, tons and tons of bug reports and patchs.
|
||||
reset, tons and tons of bug reports and patches.
|
||||
|
||||
Chip Rosenthal <chip@unicom.com>, <crosenth@covad.com>
|
||||
wget - Contributed by permission of Covad Communications
|
||||
@@ -79,15 +100,12 @@ Gyepi Sam <gyepi@praxis-sw.com>
|
||||
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.
|
||||
Mark Whitley <markw@codepoet.org>
|
||||
grep, sed, cut, xargs(previous),
|
||||
style-guide, new-applet-HOWTO, bug fixes, etc.
|
||||
|
||||
Charles P. Wright <cpwright@villagenet.com>
|
||||
gzip, mini-netcat(nc)
|
||||
|
||||
Enrique Zanardi <ezanardi@ull.es>
|
||||
tarcat (since removed), loadkmap, various fixes, Debian maintenance
|
||||
|
||||
Emanuele Aina <emanuele.aina@tiscali.it>
|
||||
run-parts
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
1) Run 'make config' or 'make menuconfig' and select the
|
||||
functionality that you wish to enable.
|
||||
|
||||
2) make dep
|
||||
2) Run 'make dep'
|
||||
|
||||
3) Check the Makefile for any Makefile setting you wish
|
||||
to adjust for your system (things like like setting
|
||||
your cross compiler, adjusting optimizations, etc)
|
||||
|
||||
4) make
|
||||
4) Run 'make'
|
||||
|
||||
5) Run 'make install' or 'make PREFIX=/target install' to
|
||||
install busybox and all the needed links.
|
||||
5) Go get a drink of water, drink a soda, visit the bathroom,
|
||||
or whatever while it compiles. It doesn't take very
|
||||
long to compile, so you don't really need to waste too
|
||||
much time waiting...
|
||||
|
||||
6) Run 'make install' or 'make PREFIX=/target install' to
|
||||
install busybox and all the needed links. Some people
|
||||
will prefer to install using hardlinks and will instead
|
||||
want to run 'make install-hardlinks'....
|
||||
@@ -1,39 +1,3 @@
|
||||
Original release code (unless otherwise noted)
|
||||
Copyright 1995, 1996 Bruce Perens <bruce@pixar.com>
|
||||
|
||||
mkswap
|
||||
Copyright 1991 Linus Torvalds
|
||||
|
||||
tiny-ls(ls)
|
||||
Copyright 1996 Brian Candler <B.Candler@pobox.com>
|
||||
|
||||
tarcat, loadkmap, various fixes, Debian maintenance
|
||||
Copyright 1998 Enrique Zanardi <ezanardi@ull.es>
|
||||
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
Copyright 1998 Dave Cinege <dcinege@psychosis.com>
|
||||
|
||||
mini-gzip(gzip), mini-netcat(mnc)
|
||||
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
|
||||
|
||||
Tons of new stuff as noted in header files
|
||||
Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
Erik Andersen
|
||||
<andersen@codepoet.org>
|
||||
<andersee@debian.org>
|
||||
|
||||
|
||||
|
||||
Busybox may be used and distributed under the GNU General Public License.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
@@ -374,4 +338,3 @@ proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -17,211 +17,46 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
PROG := busybox
|
||||
VERSION := 0.61.pre
|
||||
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
||||
TOPDIR := ${shell /bin/pwd}
|
||||
HOSTCC := gcc
|
||||
HOSTCFLAGS:= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
|
||||
#--------------------------------------------------------------
|
||||
# You shouldn't need to mess with anything beyond this point...
|
||||
#--------------------------------------------------------------
|
||||
noconfig_targets := menuconfig config oldconfig randconfig \
|
||||
defconfig allyesconfig allnoconfig clean distclean \
|
||||
release tags
|
||||
TOPDIR=./
|
||||
include Rules.mak
|
||||
|
||||
DIRS:=applets archival archival/libunarchive coreutils console-tools \
|
||||
debianutils editors findutils init miscutils modutils networking \
|
||||
networking/libiproute networking/udhcp procps loginutils shell \
|
||||
sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb
|
||||
|
||||
# What OS are you compiling busybox for? This allows you to include
|
||||
# OS specific things, syscall overrides, etc.
|
||||
TARGET_OS := linux
|
||||
|
||||
# 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- CONFIG_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
|
||||
|
||||
# If you want to add some simple compiler switches (like -march=i686),
|
||||
# especially from the command line, use this instead of CFLAGS directly.
|
||||
# For optimization overrides, it's better still to set OPTIMIZATION.
|
||||
CFLAGS_EXTRA =
|
||||
|
||||
# If you want a static binary, turn this on.
|
||||
DOSTATIC = false
|
||||
|
||||
# Set the following to `true' to make a debuggable build.
|
||||
# Leave this set to `false' for production use.
|
||||
DODEBUG = false
|
||||
|
||||
# This enables compiling with dmalloc ( http://dmalloc.com/ )
|
||||
# which is an excellent public domain mem leak and malloc problem
|
||||
# detector. To enable dmalloc, before running busybox you will
|
||||
# want to first set up your environment.
|
||||
# eg: `export DMALLOC_OPTIONS=debug=0x14f47d83,inter=100,log=logfile`
|
||||
# Do not enable this for production builds...
|
||||
DODMALLOC = false
|
||||
|
||||
# Electric-fence is another very useful malloc debugging library.
|
||||
# Do not enable this for production builds...
|
||||
DOEFENCE = false
|
||||
|
||||
# If you want large file summit support, turn this on.
|
||||
# This has no effect if you don't have a kernel with lfs
|
||||
# support, and a system with libc-2.1.3 or later.
|
||||
# Some of the programs that can benefit from lfs support
|
||||
# are dd, gzip, mount, tar, and mkfs_minix.
|
||||
# LFS allows you to use the above programs for files
|
||||
# larger than 2GB!
|
||||
DOLFS = false
|
||||
|
||||
# If you have a "pristine" source directory, point CONFIG_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.
|
||||
CONFIG_SRC_DIR =
|
||||
|
||||
# If you are running a cross compiler, you may want to set CROSS
|
||||
# to something more interesting, like "arm-linux-".
|
||||
CROSS =
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
AS = $(CROSS)as
|
||||
LD = $(CROSS)ld
|
||||
NM = $(CROSS)nm
|
||||
STRIP = $(CROSS)strip
|
||||
CPP = $(CC) -E
|
||||
MAKEFILES = $(TOPDIR)/.config
|
||||
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
|
||||
|
||||
|
||||
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
|
||||
# Everything should compile and work as expected these days...
|
||||
#CC = /usr/i386-linux-uclibc/usr/bin/i386-uclibc-gcc
|
||||
|
||||
# To compile vs some other alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs...
|
||||
#
|
||||
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
|
||||
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
|
||||
# using the compatible RPMs (compat-*) at http://www.redhat.com !
|
||||
#LIBCDIR=/usr/i386-glibc20-linux
|
||||
#
|
||||
# The following is used for libc5 (if you install altgcc and libc5-altdev
|
||||
# on a Debian system).
|
||||
#LIBCDIR=/usr/i486-linuxlibc1
|
||||
#
|
||||
# For other libraries, you are on your own...
|
||||
#LDFLAGS+=-nostdlib
|
||||
#LIBRARIES = $(LIBCDIR)/lib/libc.a -lgcc
|
||||
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
|
||||
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null \
|
||||
>/dev/null 2>&1; then echo "-Os"; else echo "-O2" ; fi}
|
||||
GCC_STACK_BOUNDRY := ${shell if $(CC) -mpreferred-stack-boundary=2 -S -o /dev/null -xc /dev/null \
|
||||
>/dev/null 2>&1; then echo "-mpreferred-stack-boundary=2"; else echo "" ; fi}
|
||||
OPTIMIZATIONS=$(OPTIMIZATION) -fomit-frame-pointer $(GCC_STACK_BOUNDRY)
|
||||
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
|
||||
CFLAGS = -I$(TOPDIR)/include
|
||||
ARFLAGS = -r
|
||||
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# If you're going to do a lot of builds with a non-vanilla configuration,
|
||||
# it makes sense to adjust parameters above, so you can type "make"
|
||||
# by itself, instead of following it by the same half-dozen overrides
|
||||
# every time. The stuff below, on the other hand, is probably less
|
||||
# prone to casual user adjustment.
|
||||
#
|
||||
|
||||
ifeq ($(strip $(DOLFS)),true)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D__USE_FILE_OFFSET64
|
||||
endif
|
||||
ifeq ($(strip $(DODMALLOC)),true)
|
||||
# For testing mem leaks with dmalloc
|
||||
CFLAGS+=-DDMALLOC
|
||||
LIBRARIES = -ldmalloc
|
||||
# Force debug=true, since this is useless when not debugging...
|
||||
DODEBUG = true
|
||||
else
|
||||
ifeq ($(strip $(DOEFENCE)),true)
|
||||
LIBRARIES = -lefence
|
||||
# Force debug=true, since this is useless when not debugging...
|
||||
DODEBUG = true
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(DODEBUG)),true)
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIPCMD =
|
||||
else
|
||||
CFLAGS += $(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIPCMD = $(STRIP) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
endif
|
||||
ifeq ($(strip $(DOSTATIC)),true)
|
||||
LDFLAGS += --static
|
||||
ifeq ($(strip $(CONFIG_SELINUX)),y)
|
||||
CFLAGS += -I/usr/include/selinux
|
||||
LIBRARIES += -lsecure
|
||||
endif
|
||||
|
||||
ifndef $(PREFIX)
|
||||
PREFIX = `pwd`/_install
|
||||
endif
|
||||
ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# Include files in the build directory should take precedence over
|
||||
# the copy in CONFIG_SRC_DIR, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
#
|
||||
ifneq ($(strip $(CONFIG_SRC_DIR)),)
|
||||
VPATH = $(CONFIG_SRC_DIR)
|
||||
endif
|
||||
all: busybox busybox.links doc
|
||||
|
||||
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
|
||||
CFLAGS += $(CROSS_CFLAGS)
|
||||
ifdef CONFIG_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(CONFIG_INIT_SCRIPT)"'
|
||||
endif
|
||||
# In this section, we need .config
|
||||
-include .config.cmd
|
||||
include $(patsubst %,%/Makefile.in, $(DIRS))
|
||||
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
busybox: .depend include/config.h $(libraries-y)
|
||||
$(CC) $(LDFLAGS) -o $@ $(libraries-y) $(LIBRARIES)
|
||||
$(STRIPCMD) $@
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
all: do-it-all
|
||||
|
||||
#
|
||||
# Make "config" the default target if there is no configuration file or
|
||||
# "depend" the target if there is no top-level dependency information.
|
||||
ifeq (.config,$(wildcard .config))
|
||||
include .config
|
||||
ifeq (.depend,$(wildcard .depend))
|
||||
include .depend
|
||||
do-it-all: busybox busybox.links doc
|
||||
else
|
||||
CONFIGURATION = depend
|
||||
do-it-all: depend
|
||||
endif
|
||||
else
|
||||
CONFIGURATION = menuconfig
|
||||
do-it-all: menuconfig
|
||||
endif
|
||||
|
||||
|
||||
SUBDIRS =applets archival archival/libunarchive console-tools editors \
|
||||
fileutils findutils init miscutils modutils networking procps \
|
||||
pwd_grp shell shellutils sysklogd textutils util-linux libbb
|
||||
|
||||
bbsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))
|
||||
|
||||
$(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/config/MARKER
|
||||
$(MAKE) CFLAGS="$(CFLAGS)" -C $(patsubst _dir_%, %, $@)
|
||||
|
||||
busybox: config.h dep-files bbsubdirs
|
||||
$(CC) $(LDFLAGS) -o $@ applets/busybox.o $(shell find $(SUBDIRS) -name \*.a) $(LIBCONFIG_LIB) $(LIBRARIES)
|
||||
$(STRIPCMD)
|
||||
|
||||
busybox.links: applets/busybox.mkll
|
||||
busybox.links: applets/busybox.mkll include/config.h
|
||||
- $(SHELL) $^ >$@
|
||||
|
||||
install: applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
|
||||
uninstall: busybox busybox.links
|
||||
for i in `cat busybox.links` ; do rm -f $$PREFIX$$i; done
|
||||
|
||||
install-hardlinks: applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
@@ -249,15 +84,15 @@ docs/BusyBox.1: docs/busybox.pod
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$< > $@
|
||||
|
||||
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
|
||||
docs/BusyBox.html: docs/busybox.net/BusyBox.html
|
||||
- mkdir -p docs
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
|
||||
-@ ln -s busybox.net/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
|
||||
-@ mkdir -p docs/busybox.lineo.com
|
||||
docs/busybox.net/BusyBox.html: docs/busybox.pod
|
||||
-@ mkdir -p docs/busybox.net
|
||||
- pod2html --noindex $< > \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
docs/busybox.net/BusyBox.html
|
||||
-@ rm -f pod2htm*
|
||||
|
||||
|
||||
@@ -285,7 +120,7 @@ docs/busybox.pdf: docs/busybox.ps
|
||||
|
||||
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
|
||||
(cd docs/busybox.net; sgmltools -b html ../busybox.sgml)
|
||||
|
||||
# The nifty new buildsystem stuff
|
||||
scripts/mkdep: scripts/mkdep.c
|
||||
@@ -294,97 +129,104 @@ scripts/mkdep: scripts/mkdep.c
|
||||
scripts/split-include: scripts/split-include.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
|
||||
|
||||
dep-files: scripts/mkdep
|
||||
@if [ ! -f .depend ] ; then \
|
||||
rm -f .depend .hdepend; \
|
||||
mkdir -p $(TOPDIR)/include/config; \
|
||||
scripts/mkdep -I $(TOPDIR)/include -- \
|
||||
`find $(TOPDIR) -name \*.c -print` >> .depend; \
|
||||
scripts/mkdep -I $(TOPDIR)/include -- \
|
||||
`find $(TOPDIR) -name \*.h -print` >> .hdepend; \
|
||||
$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" ; \
|
||||
fi;
|
||||
.depend: scripts/mkdep
|
||||
rm -f .depend .hdepend;
|
||||
mkdir -p include/config;
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
|
||||
scripts/mkdep -I include -- \
|
||||
`find . -name \*.c -print` >> .depend;
|
||||
scripts/mkdep -I include -- \
|
||||
`find . -name \*.h -print` >> .hdepend;
|
||||
$(MAKE) $(patsubst %,_sfdep_%,$(DIRS)) _FASTDEP_ALL_SUB_DIRS="$(DIRS)" ;
|
||||
|
||||
depend dep: include/config.h .depend
|
||||
|
||||
depend dep: config.h dep-files
|
||||
@ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
|
||||
|
||||
CONFIG_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
||||
else if [ -x /bin/bash ]; then echo /bin/bash; \
|
||||
else echo sh; fi ; fi}
|
||||
|
||||
include/config/MARKER: scripts/split-include include/config.h
|
||||
include/config/MARKER: depend scripts/split-include
|
||||
scripts/split-include include/config.h include/config
|
||||
@ touch include/config/MARKER
|
||||
|
||||
config.h:
|
||||
@if [ ! -f include/config.h ] ; then \
|
||||
make oldconfig; \
|
||||
include/config.h: .config
|
||||
@if [ ! -x ./scripts/config/conf ] ; then \
|
||||
make -C scripts/config conf; \
|
||||
fi;
|
||||
@./scripts/config/conf -o sysdeps/$(TARGET_OS)/Config.in
|
||||
|
||||
menuconfig:
|
||||
mkdir -p $(TOPDIR)/include/config
|
||||
$(MAKE) -C scripts/lxdialog all
|
||||
$(CONFIG_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
config:
|
||||
mkdir -p $(TOPDIR)/include/config
|
||||
$(CONFIG_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
|
||||
|
||||
oldconfig:
|
||||
mkdir -p $(TOPDIR)/include/config
|
||||
$(CONFIG_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
|
||||
|
||||
|
||||
ifdef CONFIGURATION
|
||||
..$(CONFIGURATION):
|
||||
finished2:
|
||||
@echo
|
||||
@echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
|
||||
@echo Finished installing...
|
||||
@echo
|
||||
$(MAKE) $(CONFIGURATION)
|
||||
@echo
|
||||
@echo "Successful. Try re-making (ignore the error that follows)"
|
||||
@echo
|
||||
exit 1
|
||||
|
||||
dummy:
|
||||
else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
else
|
||||
all: menuconfig
|
||||
|
||||
dummy:
|
||||
# configuration
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
endif
|
||||
scripts/config/conf:
|
||||
make -C scripts/config conf
|
||||
-@if [ ! -f .config ] ; then \
|
||||
cp sysdeps/$(TARGET_OS)/defconfig .config; \
|
||||
fi
|
||||
scripts/config/mconf:
|
||||
make -C scripts/config ncurses conf mconf
|
||||
-@if [ ! -f .config ] ; then \
|
||||
cp sysdeps/$(TARGET_OS)/defconfig .config; \
|
||||
fi
|
||||
|
||||
include Rules.mak
|
||||
menuconfig: scripts/config/mconf
|
||||
@./scripts/config/mconf sysdeps/$(TARGET_OS)/Config.in
|
||||
|
||||
# Testing...
|
||||
test tests:
|
||||
# old way of doing it
|
||||
#cd tests && $(MAKE) all
|
||||
# new way of doing it
|
||||
config: scripts/config/conf
|
||||
@./scripts/config/conf sysdeps/$(TARGET_OS)/Config.in
|
||||
|
||||
oldconfig: scripts/config/conf
|
||||
@./scripts/config/conf -o sysdeps/$(TARGET_OS)/Config.in
|
||||
|
||||
randconfig: scripts/config/conf
|
||||
@./scripts/config/conf -r sysdeps/$(TARGET_OS)/Config.in
|
||||
|
||||
allyesconfig: scripts/config/conf
|
||||
@./scripts/config/conf -y sysdeps/$(TARGET_OS)/Config.in
|
||||
|
||||
allnoconfig: scripts/config/conf
|
||||
@./scripts/config/conf -n sysdeps/$(TARGET_OS)/Config.in
|
||||
|
||||
defconfig: scripts/config/conf
|
||||
@./scripts/config/conf -d sysdeps/$(TARGET_OS)/Config.in
|
||||
|
||||
test tests: busybox
|
||||
# Note that 'tests' is depricated. Use 'make check' instead
|
||||
# To use the nice new testsuite....
|
||||
cd tests && ./tester.sh
|
||||
|
||||
# Cleanup
|
||||
check: busybox
|
||||
cd testsuite && ./runtest
|
||||
|
||||
clean:
|
||||
- $(MAKE) -C tests clean
|
||||
- $(MAKE) -C scripts/lxdialog clean
|
||||
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
docs/busybox.net/BusyBox.html
|
||||
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pdf docs/busybox.lineo.com/busybox.html \
|
||||
docs/busybox.pdf docs/busybox.pod docs/busybox.net/busybox.html \
|
||||
docs/busybox _install pod2htm* *.gdb *.elf *~ core
|
||||
- rm -f busybox.links libbb/loop.h .config.old .hdepend
|
||||
- rm -f scripts/split-include scripts/mkdep .*config.log
|
||||
- rm -rf include/config include/config.h
|
||||
- find -name .\*.flags -o -name .depend -exec rm -f {} \;
|
||||
- find -name \*.o -exec rm -f {} \;
|
||||
- find -name \*.a -exec rm -f {} \;
|
||||
- rm -f busybox busybox.links libbb/loop.h .config.old .hdepend
|
||||
- rm -f .*config.log
|
||||
- find . -name .\*.flags -exec rm -f {} \;
|
||||
- find . -name \*.o -exec rm -f {} \;
|
||||
- find . -name \*.a -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f busybox
|
||||
- cd tests && $(MAKE) distclean
|
||||
- rm -f scripts/split-include scripts/mkdep
|
||||
- rm -rf include/config include/config.h
|
||||
- find . -name .depend -exec rm -f {} \;
|
||||
rm -f .config .config.old .config.cmd
|
||||
- $(MAKE) -C scripts/config clean
|
||||
|
||||
dist release: distclean doc
|
||||
release: distclean #doc
|
||||
cd ..; \
|
||||
rm -rf busybox-$(VERSION); \
|
||||
cp -a busybox busybox-$(VERSION); \
|
||||
@@ -401,11 +243,13 @@ dist release: distclean doc
|
||||
\
|
||||
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
|
||||
|
||||
|
||||
|
||||
.PHONY: tags check
|
||||
tags:
|
||||
ctags -R .
|
||||
|
||||
check: busybox
|
||||
cd testsuite && ./runtest
|
||||
|
||||
endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
.PHONY: dummy subdirs release distclean clean config oldconfig \
|
||||
menuconfig tags check test tests depend
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Please see the LICENSE file for copyright information.
|
||||
Please see the LICENSE file for details on copying and usage.
|
||||
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for most of the utilities
|
||||
@@ -8,19 +8,18 @@ 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 was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
|
||||
BusyBox has been written with size-optimization and limited resources in mind.
|
||||
It is also extremely modular so you can easily include or exclude commands (or
|
||||
features) at compile time. This makes it easy to customize your embedded
|
||||
systems. To create a working system, just add /dev, /etc, and a kernel.
|
||||
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
|
||||
As of version 0.20 there is now a version number. : ) Also as of version 0.20,
|
||||
BusyBox is now modularized to easily allow you to build only the components you
|
||||
need, thereby reducing binary size. To turn off unwanted BusyBox components,
|
||||
simply edit the file "Config.h" and comment out the components you do not need
|
||||
using C++ style (//) comments.
|
||||
need, thereby reducing binary size. Run 'make config' or 'make menuconfig'
|
||||
for select the functionality that you wish to enable.
|
||||
|
||||
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
|
||||
@@ -28,6 +27,9 @@ 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')
|
||||
|
||||
If you wish to install hardlinks, rather than symlinks, you can use
|
||||
'make install-hardlinks' instead.
|
||||
|
||||
----------------
|
||||
|
||||
Supported architectures:
|
||||
@@ -35,18 +37,22 @@ Supported architectures:
|
||||
Busybox in general will build on any architecture supported by gcc. It has
|
||||
a few specialized features added for __sparc__ and __alpha__. insmod
|
||||
functionality is currently limited to x86, ARM, SH3/4, powerpc, m68k,
|
||||
and MIPS.
|
||||
MIPS, and v850e.
|
||||
|
||||
Supported libcs:
|
||||
|
||||
glibc-2.0.x, glibc-2.1.x, glibc-2.2.x, Linux-libc5, uClibc. People
|
||||
glibc-2.0.x, glibc-2.1.x, glibc-2.2.x, glibc-2.3.x, uClibc. People
|
||||
are looking at newlib and diet-libc, but consider them unsupported,
|
||||
untested, or worse.
|
||||
untested, or worse. Linux-libc5 is no longer supported -- you
|
||||
should probably use uClibc instead if you want a small C library.
|
||||
|
||||
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.
|
||||
Full functionality requires Linux 2.2.x or better. A large fraction of the
|
||||
code should run on just about anything. While the current code is fairly
|
||||
Linux specific, it should be fairly easy to port the majority of the code
|
||||
to, say, FreeBSD or Solaris, or MacOsX, or even Windows (if you are into that
|
||||
sortof thing).
|
||||
|
||||
----------------
|
||||
|
||||
@@ -83,66 +89,71 @@ top of ash.c as well, so check those out if you want to tweak things.
|
||||
Getting help:
|
||||
|
||||
When you find you need help, you can check out the BusyBox mailing list
|
||||
archives at http://oss.lineo.com/lists/busybox/ or even join
|
||||
archives at http://busybox.net/lists/busybox/ or even join
|
||||
the mailing list if you are interested.
|
||||
|
||||
----------------
|
||||
|
||||
Bugs:
|
||||
|
||||
If you find bugs, please submit a bug report. Full instructions on how to
|
||||
report a bug are found at http://bugs.lineo.com/Reporting.html.
|
||||
If you find bugs, please submit a detailed bug report to the busybox mailing
|
||||
list at busybox@busybox.net. A well-written bug report should include a
|
||||
transcript of a shell session that demonstrates the bad behavior and enables
|
||||
anyone else to duplicate the bug on their own machine. The following is such
|
||||
an example:
|
||||
|
||||
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
|
||||
To: busybox@busybox.net
|
||||
From: diligent@testing.linux.org
|
||||
Subject: /bin/true doesn't work
|
||||
Subject: /bin/date doesn't work
|
||||
|
||||
Package: busybox
|
||||
Version: 0.51
|
||||
Version: 1.00
|
||||
|
||||
When I execute Busybox 'date' it produces unexpected results.
|
||||
With GNU date I get the following output:
|
||||
|
||||
$ date
|
||||
Wed Mar 21 14:19:41 MST 2001
|
||||
|
||||
But when I use BusyBox date I get this instead:
|
||||
|
||||
$ date
|
||||
llegal instruction
|
||||
|
||||
I am using Debian unstable, kernel version 2.4.19-rmk1 on an Netwinder,
|
||||
and the latest uClibc from CVS. Thanks for the wonderful program!
|
||||
|
||||
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.
|
||||
reports lacking such detail may never be fixed... Thanks for understanding.
|
||||
|
||||
----------------
|
||||
|
||||
FTP:
|
||||
|
||||
Source for the latest released version can always be downloaded from
|
||||
ftp://ftp.lineo.com/pub/busybox.
|
||||
Source for the latest released version, as well as daily snapshots, can always
|
||||
be downloaded from
|
||||
http://busybox.net/downloads/
|
||||
|
||||
----------------
|
||||
|
||||
CVS:
|
||||
|
||||
BusyBox now has its own publicly browsable CVS tree at:
|
||||
http://oss.lineo.com/cgi-bin/cvsweb/busybox/
|
||||
http://busybox.net/cgi-bin/cvsweb/busybox/
|
||||
|
||||
Anonymous CVS access is available. For instructions, check out:
|
||||
http://oss.lineo.com/cvs_anon.html
|
||||
http://busybox.net/cvs_anon.html
|
||||
|
||||
For those that are actively contributing there is even CVS write access:
|
||||
http://oss.lineo.com/cvs_write.html
|
||||
http://busybox.net/cvs_write.html
|
||||
|
||||
----------------
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
Erik Andersen
|
||||
<andersen@codepoet.org>
|
||||
<andersee@debian.org>
|
||||
<andersen@codepoet.org>
|
||||
|
||||
@@ -1,195 +1,212 @@
|
||||
# Rules.make for busybox
|
||||
#
|
||||
# This file contains rules which are shared between multiple Makefiles.
|
||||
# Copyright (C) 2001-2003 Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
#
|
||||
# False targets.
|
||||
#
|
||||
.PHONY: dummy
|
||||
|
||||
#
|
||||
# Special variables which should not be exported
|
||||
#
|
||||
unexport EXTRA_AFLAGS
|
||||
unexport EXTRA_CFLAGS
|
||||
unexport EXTRA_LDFLAGS
|
||||
unexport EXTRA_ARFLAGS
|
||||
unexport SUBDIRS
|
||||
unexport SUB_DIRS
|
||||
unexport ALL_SUB_DIRS
|
||||
unexport O_TARGET
|
||||
|
||||
unexport obj-y
|
||||
unexport obj-n
|
||||
unexport obj-
|
||||
unexport export-objs
|
||||
unexport subdir-y
|
||||
unexport subdir-n
|
||||
unexport subdir-
|
||||
|
||||
#
|
||||
# Get things started.
|
||||
#
|
||||
first_rule: sub_dirs
|
||||
$(MAKE) all_targets
|
||||
|
||||
SUB_DIRS := $(subdir-y)
|
||||
ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-n) $(subdir-))
|
||||
#--------------------------------------------------------
|
||||
PROG := busybox
|
||||
VERSION := 1.00-pre2
|
||||
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
||||
|
||||
|
||||
#
|
||||
# Common rules
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# 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
|
||||
#--------------------------------------------------------
|
||||
|
||||
%.s: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@
|
||||
# If you are running a cross compiler, you will want to set 'CROSS'
|
||||
# to something more interesting... Target architecture is determined
|
||||
# by asking the CC compiler what arch it compiles things for, so unless
|
||||
# your compiler is broken, you should not need to specify TARGET_ARCH
|
||||
CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
|
||||
#CROSS =/usr/i386-linux-uclibc/bin/i386-uclibc-
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
AS = $(CROSS)as
|
||||
LD = $(CROSS)ld
|
||||
NM = $(CROSS)nm
|
||||
STRIP = $(CROSS)strip
|
||||
CPP = $(CC) -E
|
||||
MAKEFILES = $(TOPDIR).config
|
||||
|
||||
%.i: %.c
|
||||
$(CPP) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) $< > $@
|
||||
# What OS are you compiling busybox for? This allows you to include
|
||||
# OS specific things, syscall overrides, etc.
|
||||
TARGET_OS=linux
|
||||
|
||||
# Select the compiler needed to build binaries for your development system
|
||||
HOSTCC = gcc
|
||||
HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
|
||||
|
||||
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
|
||||
LC_ALL:= C
|
||||
|
||||
# If you want to add some simple compiler switches (like -march=i686),
|
||||
# especially from the command line, use this instead of CFLAGS directly.
|
||||
# For optimization overrides, it's better still to set OPTIMIZATION.
|
||||
CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
|
||||
|
||||
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
|
||||
# Experimental and incomplete; tell the mailing list
|
||||
# <busybox@busybox.net> if you do or don't like it so far.
|
||||
BB_SRC_DIR=
|
||||
|
||||
# To compile vs some other alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs...
|
||||
#
|
||||
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
|
||||
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
|
||||
# using the compatible RPMs (compat-*) at http://www.redhat.com !
|
||||
#LIBCDIR:=/usr/i386-glibc20-linux
|
||||
#
|
||||
# For other libraries, you are on your own. But these may (or may not) help...
|
||||
#LDFLAGS+=-nostdlib
|
||||
#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
|
||||
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
|
||||
#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
|
||||
CFLAGS=-I$(TOPDIR)include
|
||||
ARFLAGS=-r
|
||||
|
||||
#--------------------------------------------------------
|
||||
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
|
||||
ifeq ($(strip $(TARGET_ARCH)),)
|
||||
TARGET_ARCH=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
|
||||
-e 's/i.86/i386/' \
|
||||
-e 's/sparc.*/sparc/' \
|
||||
-e 's/arm.*/arm/g' \
|
||||
-e 's/m68k.*/m68k/' \
|
||||
-e 's/ppc/powerpc/g' \
|
||||
-e 's/v850.*/v850/g' \
|
||||
-e 's/sh[234]/sh/' \
|
||||
-e 's/mips-.*/mips/' \
|
||||
-e 's/mipsel-.*/mipsel/' \
|
||||
-e 's/cris.*/cris/' \
|
||||
)
|
||||
endif
|
||||
|
||||
# Pull in the user's uClibc configuration
|
||||
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
|
||||
-include $(TOPDIR).config
|
||||
endif
|
||||
|
||||
# A nifty macro to make testing gcc features easier
|
||||
check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
|
||||
then echo "$(1)"; else echo "$(2)"; fi)
|
||||
|
||||
#--------------------------------------------------------
|
||||
# Arch specific compiler optimization stuff should go here.
|
||||
# Unless you want to override the defaults, do not set anything
|
||||
# for OPTIMIZATION...
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION=
|
||||
OPTIMIZATION=${call check_gcc,-Os,-O2}
|
||||
|
||||
# Some nice architecture specific optimizations
|
||||
ifeq ($(strip $(TARGET_ARCH)),arm)
|
||||
OPTIMIZATION+=-fstrict-aliasing
|
||||
endif
|
||||
ifeq ($(strip $(TARGET_ARCH)),i386)
|
||||
OPTIMIZATION+=$(call check_gcc,-march=i386,)
|
||||
OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
|
||||
OPTIMIZATION+=$(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,\
|
||||
-malign-functions=0 -malign-jumps=0 -malign-loops=0)
|
||||
endif
|
||||
OPTIMIZATIONS=$(OPTIMIZATION) -fomit-frame-pointer
|
||||
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# If you're going to do a lot of builds with a non-vanilla configuration,
|
||||
# it makes sense to adjust parameters above, so you can type "make"
|
||||
# by itself, instead of following it by the same half-dozen overrides
|
||||
# every time. The stuff below, on the other hand, is probably less
|
||||
# prone to casual user adjustment.
|
||||
#
|
||||
|
||||
ifeq ($(strip $(CONFIG_LFS)),y)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_DMALLOC)),y)
|
||||
# For testing mem leaks with dmalloc
|
||||
CFLAGS+=-DDMALLOC
|
||||
LIBRARIES:=-ldmalloc
|
||||
else
|
||||
ifeq ($(strip $(CONFIG_EFENCE)),y)
|
||||
LIBRARIES:=-lefence
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_DEBUG)),y)
|
||||
CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS +=-Wl,-warn-common
|
||||
STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
|
||||
else
|
||||
CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIPCMD:=$(STRIP) --remove-section=.note --remove-section=.comment
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_STATIC)),y)
|
||||
LDFLAGS += --static
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PREFIX)),)
|
||||
PREFIX:=`pwd`/_install
|
||||
endif
|
||||
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# Include files in the build directory should take precedence over
|
||||
# the copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
#
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
VPATH:=$(BB_SRC_DIR)
|
||||
endif
|
||||
|
||||
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
|
||||
CFLAGS += $(CROSS_CFLAGS)
|
||||
ifdef BB_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
||||
endif
|
||||
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<
|
||||
@ ( \
|
||||
echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \
|
||||
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
|
||||
echo 'endif' \
|
||||
) > $(dir $@)/.$(notdir $@).flags
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
%.o: %.s
|
||||
$(AS) $(AFLAGS) $(EXTRA_CFLAGS) -o $@ $<
|
||||
|
||||
# Old makefiles define their own rules for compiling .S files,
|
||||
# but these standard rules are available for any Makefile that
|
||||
# wants to use them. Our plan is to incrementally convert all
|
||||
# the Makefiles to these standard rules. -- rmk, mec
|
||||
ifdef USE_STANDARD_AS_RULE
|
||||
|
||||
%.s: %.S
|
||||
$(CPP) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) $< > $@
|
||||
|
||||
%.o: %.S
|
||||
$(CC) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) -c -o $@ $<
|
||||
|
||||
endif
|
||||
|
||||
%.lst: %.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $<
|
||||
$(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP)
|
||||
#
|
||||
#
|
||||
#
|
||||
all_targets: $(O_TARGET) $(L_TARGET)
|
||||
|
||||
#
|
||||
# Rule to compile a set of .o files into one .o file
|
||||
#
|
||||
ifdef O_TARGET
|
||||
$(O_TARGET): $(obj-y)
|
||||
rm -f $@
|
||||
ifneq "$(strip $(obj-y))" ""
|
||||
$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
|
||||
else
|
||||
$(AR) rcs $@
|
||||
endif
|
||||
@ ( \
|
||||
echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
|
||||
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
|
||||
echo 'endif' \
|
||||
) > $(dir $@)/.$(notdir $@).flags
|
||||
endif # O_TARGET
|
||||
|
||||
#
|
||||
# Rule to compile a set of .o files into one .a file
|
||||
#
|
||||
ifdef L_TARGET
|
||||
$(L_TARGET): $(obj-y)
|
||||
rm -f $@
|
||||
$(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y)
|
||||
@ ( \
|
||||
echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(obj-y))))' ; \
|
||||
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
|
||||
echo 'endif' \
|
||||
) > $(dir $@)/.$(notdir $@).flags
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# This make dependencies quickly
|
||||
#
|
||||
ifdef _FASTDEP_ALL_SUB_DIRS
|
||||
fastdep: dummy
|
||||
$(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS) -- $(wildcard *.[chS]) > .depend
|
||||
$(TOPDIR)scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -- $(wildcard *.[chS]) > .depend
|
||||
ifdef ALL_SUB_DIRS
|
||||
$(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)"
|
||||
endif
|
||||
|
||||
ifdef _FASTDEP_ALL_SUB_DIRS
|
||||
$(patsubst %,_sfdep_%,$(_FASTDEP_ALL_SUB_DIRS)):
|
||||
$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# A rule to make subdirectories
|
||||
#
|
||||
subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
|
||||
sub_dirs: dummy $(subdir-list)
|
||||
.PHONY: dummy
|
||||
|
||||
ifdef SUB_DIRS
|
||||
$(subdir-list) : dummy
|
||||
$(MAKE) -C $(patsubst _subdir_%,%,$@)
|
||||
endif
|
||||
|
||||
#
|
||||
# A rule to do nothing
|
||||
#
|
||||
dummy:
|
||||
|
||||
#
|
||||
# This is useful for testing
|
||||
#
|
||||
script:
|
||||
$(SCRIPT)
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
#
|
||||
# include dependency files if they exist
|
||||
#
|
||||
ifneq ($(wildcard .depend),)
|
||||
include .depend
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard $(TOPDIR)/.hdepend),)
|
||||
include $(TOPDIR)/.hdepend
|
||||
endif
|
||||
|
||||
#
|
||||
# Find files whose flags have changed and force recompilation.
|
||||
# For safety, this works in the converse direction:
|
||||
# every file is forced, except those whose flags are positively up-to-date.
|
||||
#
|
||||
FILES_FLAGS_UP_TO_DATE :=
|
||||
|
||||
# For use in expunging commas from flags, which mung our checking.
|
||||
comma = ,
|
||||
|
||||
FILES_FLAGS_EXIST := $(wildcard .*.flags)
|
||||
ifneq ($(FILES_FLAGS_EXIST),)
|
||||
include $(FILES_FLAGS_EXIST)
|
||||
endif
|
||||
|
||||
FILES_FLAGS_CHANGED := $(strip \
|
||||
$(filter-out $(FILES_FLAGS_UP_TO_DATE), \
|
||||
$(O_TARGET) $(L_TARGET) $(active-objs) \
|
||||
))
|
||||
|
||||
# A kludge: .S files don't get flag dependencies (yet),
|
||||
# because that will involve changing a lot of Makefiles. Also
|
||||
# suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
|
||||
# This allows handling of assembly files that get translated into
|
||||
# multiple object files (see arch/ia64/lib/idiv.S, for example).
|
||||
FILES_FLAGS_CHANGED := $(strip \
|
||||
$(filter-out $(patsubst %.S, %.o, $(wildcard *.S) $(IGNORE_FLAGS_OBJS)), \
|
||||
$(FILES_FLAGS_CHANGED)))
|
||||
|
||||
ifneq ($(FILES_FLAGS_CHANGED),)
|
||||
$(FILES_FLAGS_CHANGED): dummy
|
||||
endif
|
||||
@@ -1,15 +1,8 @@
|
||||
TODO list for busybox in no particular order. Just because something
|
||||
is listed here doesn't mean that it is going to be added to busybox,
|
||||
or that doing so is even a good idea. It just means that I _might_ get
|
||||
around to it some time. If you have any good ideas, please let me know.
|
||||
|
||||
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
|
||||
needed or wanted in busybox (or else I'd have to link to libcrypt).
|
||||
|
||||
* We _were_ going to split networking apps into a new package called
|
||||
netkit-tiny. Per discussions on the mailing list, this isn't going
|
||||
to happen. False alarm. Sorry about the confusion.
|
||||
|
||||
or that doing so is even a good idea. It just means that we _might_ get
|
||||
around to it some time. If you have any good ideas, please send them
|
||||
on in...
|
||||
|
||||
-Erik
|
||||
|
||||
@@ -17,10 +10,7 @@ around to it some time. If you have any good ideas, please let me know.
|
||||
|
||||
Possible apps to include some time:
|
||||
|
||||
* hwclock
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
* login/sulogin/passwd/etc are part of tinylogin. These are
|
||||
being merged into busybox as time allows.
|
||||
|
||||
-----------
|
||||
|
||||
@@ -47,12 +37,13 @@ libraries such as uClibc.
|
||||
Compile with debugging on, run 'nm --size-sort ./busybox'
|
||||
and then start with the biggest things and make them smaller...
|
||||
|
||||
-----------------------
|
||||
|
||||
du.c probably ought to have an -x switch like GNU du does...
|
||||
|
||||
-----------------------
|
||||
|
||||
xargs could use a -l option
|
||||
|
||||
------------------------------------------------------------------
|
||||
|
||||
libbb/unzip.c and archival/gzip.c have common constant static arrays and
|
||||
code for initializing the CRC array. Both use CRC-32 and could use
|
||||
common code for CRC calculation. Within archival/gzip.c, the CRC
|
||||
array should be malloc-ed as it is in libbb/unzip.c .
|
||||
+9
-13
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -17,18 +17,14 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR :=..
|
||||
L_TARGET := applets.a
|
||||
|
||||
obj-y :=
|
||||
obj-n :=
|
||||
obj- :=
|
||||
|
||||
obj-y += applets.o busybox.o usage.o
|
||||
|
||||
# Hand off to toplevel Rules.mak
|
||||
include $(TOPDIR)/Rules.mak
|
||||
TOPDIR:= ../
|
||||
APPLETS_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
|
||||
clean:
|
||||
rm -f $(L_TARGET) *.o core
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
APPLETS_AR:=applets.a
|
||||
ifndef $(APPLETS_DIR)
|
||||
APPLETS_DIR:=$(TOPDIR)applets/
|
||||
endif
|
||||
|
||||
APPLET_SRC:=applets.c busybox.c usage.c
|
||||
APPLET_OBJ:= $(patsubst %.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
|
||||
|
||||
|
||||
|
||||
libraries-y+=$(APPLETS_DIR)$(APPLETS_AR)
|
||||
|
||||
$(APPLET_OBJ): $(TOPDIR).config
|
||||
|
||||
$(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
|
||||
$(AR) -ro $@ $(APPLET_OBJ)
|
||||
|
||||
+384
-46
@@ -20,11 +20,12 @@
|
||||
* 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
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -40,71 +41,408 @@ struct BB_applet *applet_using;
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
extern void show_usage(void)
|
||||
{
|
||||
const char *format_string;
|
||||
const char *usage_string = usage_messages;
|
||||
int i;
|
||||
|
||||
for (i = applet_using - applets; i > 0; ) {
|
||||
if (!*usage_string++) {
|
||||
--i;
|
||||
}
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
|
||||
static void check_suid (struct BB_applet *app);
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#include "pwd_.h"
|
||||
#include "grp_.h"
|
||||
|
||||
static int parse_config_file (void);
|
||||
|
||||
static int config_ok;
|
||||
|
||||
#define CONFIG_FILE "/etc/busybox.conf"
|
||||
|
||||
/* applets [] is const, so we have to define this "override" structure */
|
||||
struct BB_suid_config
|
||||
{
|
||||
struct BB_applet *m_applet;
|
||||
|
||||
uid_t m_uid;
|
||||
gid_t m_gid;
|
||||
mode_t m_mode;
|
||||
|
||||
struct BB_suid_config *m_next;
|
||||
};
|
||||
|
||||
static struct BB_suid_config *suid_config;
|
||||
|
||||
#endif /* CONFIG_FEATURE_SUID_CONFIG */
|
||||
|
||||
#endif /* CONFIG_FEATURE_SUID */
|
||||
|
||||
|
||||
|
||||
extern void
|
||||
bb_show_usage (void)
|
||||
{
|
||||
const char *format_string;
|
||||
const char *usage_string = usage_messages;
|
||||
int i;
|
||||
|
||||
for (i = applet_using - applets; i > 0;) {
|
||||
if (!*usage_string++) {
|
||||
--i;
|
||||
}
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if(*usage_string == 0)
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf(stderr, format_string,
|
||||
full_version, applet_using->name, usage_string);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if (*usage_string == '\b')
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf (stderr, format_string, bb_msg_full_version, applet_using->name,
|
||||
usage_string);
|
||||
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static int applet_name_compare(const void *x, const void *y)
|
||||
static int
|
||||
applet_name_compare (const void *x, const void *y)
|
||||
{
|
||||
const char *name = x;
|
||||
const struct BB_applet *applet = y;
|
||||
const char *name = x;
|
||||
const struct BB_applet *applet = y;
|
||||
|
||||
return strcmp(name, applet->name);
|
||||
return strcmp (name, applet->name);
|
||||
}
|
||||
|
||||
extern const size_t NUM_APPLETS;
|
||||
|
||||
struct BB_applet *find_applet_by_name(const char *name)
|
||||
struct BB_applet *
|
||||
find_applet_by_name (const char *name)
|
||||
{
|
||||
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
|
||||
applet_name_compare);
|
||||
return bsearch (name, applets, NUM_APPLETS, sizeof (struct BB_applet),
|
||||
applet_name_compare);
|
||||
}
|
||||
|
||||
void run_applet_by_name(const char *name, int argc, char **argv)
|
||||
void
|
||||
run_applet_by_name (const char *name, int argc, char **argv)
|
||||
{
|
||||
static int recurse_level = 0;
|
||||
extern int been_there_done_that; /* From busybox.c */
|
||||
static int recurse_level = 0;
|
||||
extern int been_there_done_that; /* From busybox.c */
|
||||
|
||||
recurse_level++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
if ((applet_using = find_applet_by_name(name)) != NULL) {
|
||||
applet_name = applet_using->name;
|
||||
if (argv[1] && strcmp(argv[1], "--help") == 0) {
|
||||
if (strcmp(applet_using->name, "busybox")==0) {
|
||||
if(argv[2])
|
||||
applet_using = find_applet_by_name(argv[2]);
|
||||
else
|
||||
applet_using = NULL;
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
if (recurse_level == 0)
|
||||
config_ok = parse_config_file ();
|
||||
#endif
|
||||
|
||||
recurse_level++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
if ((applet_using = find_applet_by_name (name)) != NULL) {
|
||||
bb_applet_name = applet_using->name;
|
||||
if (argv[1] && strcmp (argv[1], "--help") == 0) {
|
||||
if (strcmp (applet_using->name, "busybox") == 0) {
|
||||
if (argv[2])
|
||||
applet_using = find_applet_by_name (argv[2]);
|
||||
else
|
||||
applet_using = NULL;
|
||||
}
|
||||
if (applet_using)
|
||||
bb_show_usage ();
|
||||
been_there_done_that = 1;
|
||||
busybox_main (0, NULL);
|
||||
}
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
check_suid (applet_using);
|
||||
#endif
|
||||
|
||||
exit ((*(applet_using->main)) (argc, argv));
|
||||
}
|
||||
/* Just in case they have renamed busybox - Check argv[1] */
|
||||
if (recurse_level == 1) {
|
||||
run_applet_by_name ("busybox", argc, argv);
|
||||
}
|
||||
recurse_level--;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
/* check if u is member of group g */
|
||||
static int
|
||||
ingroup (uid_t u, gid_t g)
|
||||
{
|
||||
struct group *grp = getgrgid (g);
|
||||
|
||||
if (grp) {
|
||||
char **mem;
|
||||
|
||||
for (mem = grp->gr_mem; *mem; mem++) {
|
||||
struct passwd *pwd = getpwnam (*mem);
|
||||
|
||||
if (pwd && (pwd->pw_uid == u))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
check_suid (struct BB_applet *applet)
|
||||
{
|
||||
uid_t ruid = getuid (); /* real [ug]id */
|
||||
uid_t rgid = getgid ();
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
if (config_ok) {
|
||||
struct BB_suid_config *sct;
|
||||
|
||||
for (sct = suid_config; sct; sct = sct->m_next) {
|
||||
if (sct->m_applet == applet)
|
||||
break;
|
||||
}
|
||||
if (sct) {
|
||||
mode_t m = sct->m_mode;
|
||||
|
||||
if (sct->m_uid == ruid) /* same uid */
|
||||
m >>= 6;
|
||||
else if ((sct->m_gid == rgid) || ingroup (ruid, sct->m_gid)) /* same group / in group */
|
||||
m >>= 3;
|
||||
|
||||
if (!(m & S_IXOTH)) /* is x bit not set ? */
|
||||
bb_error_msg_and_die ("You have no permission to run this applet!");
|
||||
|
||||
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
|
||||
if (setegid (sct->m_gid))
|
||||
bb_error_msg_and_die
|
||||
("BusyBox binary has insufficient rights to set proper GID for applet!");
|
||||
} else
|
||||
setgid (rgid); /* no sgid -> drop */
|
||||
|
||||
if (sct->m_mode & S_ISUID) {
|
||||
if (seteuid (sct->m_uid))
|
||||
bb_error_msg_and_die
|
||||
("BusyBox binary has insufficient rights to set proper UID for applet!");
|
||||
} else
|
||||
setuid (ruid); /* no suid -> drop */
|
||||
} else {
|
||||
/* default: drop all priviledges */
|
||||
setgid (rgid);
|
||||
setuid (ruid);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
|
||||
static int onetime = 0;
|
||||
|
||||
if (!onetime) {
|
||||
onetime = 1;
|
||||
fprintf (stderr, "Using fallback suid method\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (applet->need_suid == _BB_SUID_ALWAYS) {
|
||||
if (geteuid () != 0)
|
||||
bb_error_msg_and_die ("This applet requires root priviledges!");
|
||||
} else if (applet->need_suid == _BB_SUID_NEVER) {
|
||||
setgid (rgid); /* drop all priviledges */
|
||||
setuid (ruid);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
|
||||
#define parse_error(x) { err=x; goto pe_label; }
|
||||
|
||||
|
||||
int
|
||||
parse_config_file (void)
|
||||
{
|
||||
struct stat st;
|
||||
char *err = 0;
|
||||
FILE *f = 0;
|
||||
int lc = 0;
|
||||
|
||||
suid_config = 0;
|
||||
|
||||
/* is there a config file ? */
|
||||
if (stat (CONFIG_FILE, &st) == 0) {
|
||||
/* is it owned by root with no write perm. for group and others ? */
|
||||
if (S_ISREG (st.st_mode) && (st.st_uid == 0)
|
||||
&& (!(st.st_mode & (S_IWGRP | S_IWOTH)))) {
|
||||
/* that's ok .. then try to open it */
|
||||
f = fopen (CONFIG_FILE, "r");
|
||||
|
||||
if (f) {
|
||||
char buffer[256];
|
||||
int section = 0;
|
||||
|
||||
while (fgets (buffer, sizeof (buffer) - 1, f)) {
|
||||
char c = buffer[0];
|
||||
char *p;
|
||||
|
||||
lc++;
|
||||
|
||||
p = strchr (buffer, '#');
|
||||
if (p)
|
||||
*p = 0;
|
||||
p = buffer + bb_strlen (buffer);
|
||||
while ((p > buffer) && isspace (*--p))
|
||||
*p = 0;
|
||||
|
||||
if (p == buffer)
|
||||
continue;
|
||||
|
||||
if (c == '[') {
|
||||
p = strchr (buffer, ']');
|
||||
|
||||
if (!p || (p == (buffer + 1))) /* no matching ] or empty [] */
|
||||
parse_error ("malformed section header");
|
||||
|
||||
*p = 0;
|
||||
|
||||
if (strcasecmp (buffer + 1, "SUID") == 0)
|
||||
section = 1;
|
||||
else
|
||||
section = -1; /* unknown section - just skip */
|
||||
} else if (section) {
|
||||
switch (section) {
|
||||
case 1:{ /* SUID */
|
||||
int l;
|
||||
struct BB_applet *applet;
|
||||
|
||||
p = strchr (buffer, '='); /* <key>[::space::]*=[::space::]*<value> */
|
||||
|
||||
if (!p || (p == (buffer + 1))) /* no = or key is empty */
|
||||
parse_error ("malformed keyword");
|
||||
|
||||
l = p - buffer;
|
||||
while (isspace (buffer[--l])) {
|
||||
/* skip whitespace */
|
||||
}
|
||||
|
||||
buffer[l + 1] = 0;
|
||||
|
||||
if ((applet = find_applet_by_name (buffer))) {
|
||||
struct BB_suid_config *sct =
|
||||
xmalloc (sizeof (struct BB_suid_config));
|
||||
|
||||
sct->m_applet = applet;
|
||||
sct->m_next = suid_config;
|
||||
suid_config = sct;
|
||||
|
||||
while (isspace (*++p)) {
|
||||
/* skip whitespace */
|
||||
}
|
||||
|
||||
sct->m_mode = 0;
|
||||
|
||||
switch (*p++) {
|
||||
case 'S':
|
||||
sct->m_mode |= S_ISUID;
|
||||
break;
|
||||
case 's':
|
||||
sct->m_mode |= S_ISUID;
|
||||
/* no break */
|
||||
case 'x':
|
||||
sct->m_mode |= S_IXUSR;
|
||||
break;
|
||||
case '-':
|
||||
break;
|
||||
default:
|
||||
parse_error ("invalid user mode");
|
||||
}
|
||||
|
||||
switch (*p++) {
|
||||
case 's':
|
||||
sct->m_mode |= S_ISGID;
|
||||
/* no break */
|
||||
case 'x':
|
||||
sct->m_mode |= S_IXGRP;
|
||||
break;
|
||||
case 'S':
|
||||
break;
|
||||
case '-':
|
||||
break;
|
||||
default:
|
||||
parse_error ("invalid group mode");
|
||||
}
|
||||
|
||||
switch (*p) {
|
||||
case 't':
|
||||
case 'x':
|
||||
sct->m_mode |= S_IXOTH;
|
||||
break;
|
||||
case 'T':
|
||||
case '-':
|
||||
break;
|
||||
default:
|
||||
parse_error ("invalid other mode");
|
||||
}
|
||||
|
||||
while (isspace (*++p)) {
|
||||
/* skip whitespace */
|
||||
}
|
||||
|
||||
if (isdigit (*p)) {
|
||||
sct->m_uid = strtol (p, &p, 10);
|
||||
if (*p++ != '.')
|
||||
parse_error ("parsing <uid>.<gid>");
|
||||
} else {
|
||||
struct passwd *pwd;
|
||||
char *p2 = strchr (p, '.');
|
||||
|
||||
if (!p2)
|
||||
parse_error ("parsing <uid>.<gid>");
|
||||
|
||||
*p2 = 0;
|
||||
pwd = getpwnam (p);
|
||||
|
||||
if (!pwd)
|
||||
parse_error ("invalid user name");
|
||||
|
||||
sct->m_uid = pwd->pw_uid;
|
||||
p = p2 + 1;
|
||||
}
|
||||
if (isdigit (*p))
|
||||
sct->m_gid = strtol (p, &p, 10);
|
||||
else {
|
||||
struct group *grp = getgrnam (p);
|
||||
|
||||
if (!grp)
|
||||
parse_error ("invalid group name");
|
||||
|
||||
sct->m_gid = grp->gr_gid;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: /* unknown - skip */
|
||||
break;
|
||||
}
|
||||
if(applet_using)
|
||||
show_usage();
|
||||
been_there_done_that=1;
|
||||
busybox_main(0, NULL);
|
||||
} else
|
||||
parse_error ("keyword not within section");
|
||||
}
|
||||
exit((*(applet_using->main)) (argc, argv));
|
||||
fclose (f);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* Just in case they have renamed busybox - Check argv[1] */
|
||||
if (recurse_level == 1) {
|
||||
run_applet_by_name("busybox", argc, argv);
|
||||
}
|
||||
recurse_level--;
|
||||
}
|
||||
return 0; /* no config file or not readable (not an error) */
|
||||
|
||||
pe_label:
|
||||
fprintf (stderr, "Parse error in %s, line %d: %s\n", CONFIG_FILE, lc, err);
|
||||
|
||||
if (f)
|
||||
fclose (f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
|
||||
+20
-17
@@ -10,7 +10,7 @@
|
||||
#endif
|
||||
|
||||
int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *applet_name;
|
||||
const char *bb_applet_name;
|
||||
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
@@ -18,12 +18,15 @@ const char *applet_name;
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static char* install_dir[] = {
|
||||
"/",
|
||||
"/bin",
|
||||
"/sbin",
|
||||
"/usr/bin",
|
||||
"/usr/sbin",
|
||||
static const char usr_bin [] ="/usr/bin";
|
||||
static const char usr_sbin[] ="/usr/sbin";
|
||||
|
||||
static const char* const install_dir[] = {
|
||||
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
|
||||
&usr_bin [4], /* "/bin" */
|
||||
&usr_sbin[4], /* "/sbin" */
|
||||
usr_bin,
|
||||
usr_sbin
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
@@ -35,7 +38,7 @@ typedef int (*__link_f)(const char *, const char *);
|
||||
* malloc'd string w/ full pathname of busybox's location
|
||||
* NULL on failure
|
||||
*/
|
||||
static char *busybox_fullpath()
|
||||
static inline char *busybox_fullpath(void)
|
||||
{
|
||||
return xreadlink("/proc/self/exe");
|
||||
}
|
||||
@@ -57,7 +60,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, fpc);
|
||||
if (rc!=0 && errno!=EEXIST) {
|
||||
perror_msg("%s", fpc);
|
||||
bb_perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
@@ -69,14 +72,14 @@ int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
applet_name = argv[0];
|
||||
bb_applet_name = argv[0];
|
||||
|
||||
if (applet_name[0] == '-')
|
||||
applet_name++;
|
||||
if (bb_applet_name[0] == '-')
|
||||
bb_applet_name++;
|
||||
|
||||
for (s = applet_name; *s != '\0';) {
|
||||
for (s = bb_applet_name; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
bb_applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
@@ -88,8 +91,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
run_applet_by_name(bb_applet_name, argc, argv);
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +143,7 @@ int busybox_main(int argc, char **argv)
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use, and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as.\n"
|
||||
"\nCurrently defined functions:\n", full_version);
|
||||
"\nCurrently defined functions:\n", bb_msg_full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
menu "Archival Utilities"
|
||||
|
||||
config CONFIG_AR
|
||||
bool "ar"
|
||||
default n
|
||||
help
|
||||
ar is an archival utility program used to create, modify, and
|
||||
extract contents from archives. An archive is a single file holding
|
||||
a collection of other files in a structure that makes it possible to
|
||||
retrieve the original individual files (called archive members).
|
||||
The original files' contents, mode (permissions), timestamp, owner,
|
||||
and group are preserved in the archive, and can be restored on
|
||||
extraction.
|
||||
The stored filename is limited to 15 characters. (for more information
|
||||
see long filename support).
|
||||
ar has 60 bytes of overheads for every stored file.
|
||||
|
||||
This implementation of ar can extract archives, it cannot create or
|
||||
modify them.
|
||||
On an x86 system, the ar applet adds about XXX bytes.
|
||||
|
||||
Unless you have a specific application which requires ar, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
bool " Enable support for long filenames (not need for debs)"
|
||||
default n
|
||||
depends on CONFIG_AR
|
||||
help
|
||||
By default the ar format can only store the first 15 characters of the
|
||||
filename, this option removes that limitation.
|
||||
It supports the GNU ar long filename method which moves multiple long
|
||||
filenames into a the data section of a new ar entry.
|
||||
|
||||
config CONFIG_BUNZIP2
|
||||
bool "bunzip2"
|
||||
default n
|
||||
help
|
||||
bunzip2 is an compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
is generally considerably better than that achieved by more
|
||||
conventional LZ77/LZ78-based compressors, and approaches the
|
||||
performance of the PPM family of statistical compressors.
|
||||
|
||||
The BusyBox bunzip2 applet is limited to de-compression only.
|
||||
On an x86 system, this applet adds about XXX bytes.
|
||||
|
||||
Unless you have a specific application which requires bunzip2, you
|
||||
should probably say N here.
|
||||
|
||||
config CONFIG_CPIO
|
||||
bool "cpio"
|
||||
default n
|
||||
help
|
||||
cpio is an archival utility program used to create, modify, and extract
|
||||
contents from archives.
|
||||
cpio has 110 bytes of overheads for every stored file.
|
||||
|
||||
This implementation of cpio can extract cpio archives created in the
|
||||
"newc" or "crc" format, it cannot create or modify them.
|
||||
|
||||
Unless you have a specific application which requires cpio, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_DPKG
|
||||
bool "dpkg"
|
||||
default n
|
||||
help
|
||||
dpkg is a medium-level tool to install, build, remove and manage Debian packages.
|
||||
|
||||
This implementation of dpkg has a number of limitations, you should use the
|
||||
official dpkg if possible.
|
||||
|
||||
config CONFIG_DPKG_DEB
|
||||
bool "dpkg_deb"
|
||||
default n
|
||||
help
|
||||
dpkg-deb packs, unpacks and provides information about Debian archives.
|
||||
|
||||
This implementation of dpkg-deb cannot pack archives.
|
||||
|
||||
Unless you have a specific application which requires dpkg-deb, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
bool " extract only (-x)"
|
||||
default n
|
||||
depends on CONFIG_DPKG_DEB
|
||||
help
|
||||
This reduced dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
|
||||
However it saves space as none of the extra dpkg-deb, ar or tar options are
|
||||
needed, they are linked to internally.
|
||||
|
||||
config CONFIG_FEATURE_DEB_TAR_GZ
|
||||
bool " gzip debian packages (normal)"
|
||||
default y if CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
help
|
||||
This is the default compression method inside the debian ar file.
|
||||
|
||||
If you want compatability with standard .deb's you should say yes here.
|
||||
|
||||
config CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
bool " bzip2 debian packages"
|
||||
default n
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
help
|
||||
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
|
||||
with bzip2 instead of gzip.
|
||||
|
||||
You only want this is your are creating your own custom debian packages that
|
||||
use an internal control.tar.bz2 or data.tar.bz2.
|
||||
|
||||
config CONFIG_GUNZIP
|
||||
bool "gunzip"
|
||||
default n
|
||||
help
|
||||
gunzip is used to decompress archives created by gzip.
|
||||
You can use the `-t' option to test the integrity of
|
||||
an archive, without decompressing it.
|
||||
|
||||
config CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
bool " Uncompress support"
|
||||
default n
|
||||
depends on CONFIG_GUNZIP
|
||||
help
|
||||
If you want gunzip to have the ability to decompress
|
||||
archives created by the program compress (not much
|
||||
used anymore).
|
||||
|
||||
config CONFIG_GZIP
|
||||
bool "gzip"
|
||||
default n
|
||||
help
|
||||
gzip is used to compress files.
|
||||
It's probably the most used UNIX compression program.
|
||||
|
||||
config CONFIG_RPM2CPIO
|
||||
bool "rpm2cpio"
|
||||
default n
|
||||
help
|
||||
Converts an RPM file into a CPIO archive.
|
||||
|
||||
config CONFIG_RPM
|
||||
bool "rpm"
|
||||
default n
|
||||
help
|
||||
Mini RPM applet - querys and extracts
|
||||
|
||||
config CONFIG_TAR
|
||||
bool "tar"
|
||||
default n
|
||||
help
|
||||
tar is an archiving program. It's commonly used with gzip to
|
||||
create compressed archives. It's probably the most used
|
||||
UNIX archive program.
|
||||
|
||||
config CONFIG_FEATURE_TAR_CREATE
|
||||
bool " Enable archive creation"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option you'll be able to create
|
||||
tar archives using the `-c' option.
|
||||
|
||||
config CONFIG_FEATURE_TAR_BZIP2
|
||||
bool " Enable -j option to handle .tar.bz2 files"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option you'll be able to extract
|
||||
archives compressed with bzip2.
|
||||
|
||||
config CONFIG_FEATURE_TAR_EXCLUDE
|
||||
bool " Enable -X and --exclude options (exclude files)"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option you'll be able to specify
|
||||
a list of files to exclude from an archive.
|
||||
|
||||
config CONFIG_FEATURE_TAR_GZIP
|
||||
bool " Enable -z option"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option tar will be able to call gzip,
|
||||
when creating or extracting tar gziped archives.
|
||||
|
||||
config CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
|
||||
bool " Enable support for old tar header format"
|
||||
default N
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
This option is required to unpack archives created with
|
||||
in the old GNU format, help to kill this old format by
|
||||
repacking your ancient archives with the new format.
|
||||
|
||||
config CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
bool " Enable support for some GNU tar extensions"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
With this option busybox supports GNU long filenames and
|
||||
linknames.
|
||||
|
||||
config CONFIG_FEATURE_UNARCHIVE_TAPE
|
||||
bool " Enable tape drive support"
|
||||
default n
|
||||
depends on CONFIG_TAR || CONFIG_CPIO
|
||||
help
|
||||
I dont think this is needed anymore.
|
||||
|
||||
config CONFIG_UNCOMPRESS
|
||||
bool "uncompress"
|
||||
default n
|
||||
help
|
||||
uncompress is used to decompress archives created by compress.
|
||||
Not much used anymore, replaced by gzip/gunzip.
|
||||
|
||||
config CONFIG_UNZIP
|
||||
bool "unzip"
|
||||
default n
|
||||
help
|
||||
unzip will list or extract files from a ZIP archive,
|
||||
commonly found on DOS/WIN systems. The default behavior
|
||||
(with no options) is to extract the archive into the
|
||||
current directory. Use the `-d' option to extract to a
|
||||
directory of your choice.
|
||||
|
||||
endmenu
|
||||
+9
-23
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -17,28 +17,14 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR :=..
|
||||
L_TARGET := archival.a
|
||||
|
||||
obj-y :=
|
||||
obj-n :=
|
||||
obj- :=
|
||||
subdir-y := libunarchive
|
||||
|
||||
obj-$(CONFIG_AR) += ar.o
|
||||
obj-$(CONFIG_BUNZIP2) += bunzip2.o
|
||||
obj-$(CONFIG_CPIO) += cpio.o
|
||||
obj-$(CONFIG_DPKG) += dpkg.o
|
||||
obj-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
obj-$(CONFIG_GUNZIP) += gunzip.o
|
||||
obj-$(CONFIG_GZIP) += gzip.o
|
||||
obj-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
obj-$(CONFIG_TAR) += tar.o
|
||||
|
||||
|
||||
# Hand off to toplevel Rules.mak
|
||||
include $(TOPDIR)/Rules.mak
|
||||
TOPDIR:= ../
|
||||
ARCHIVAL_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
|
||||
clean:
|
||||
rm -f $(L_TARGET) *.o core
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
ARCHIVAL_AR:=archival.a
|
||||
ifndef $(ARCHIVAL_DIR)
|
||||
ARCHIVAL_DIR:=$(TOPDIR)archival/
|
||||
endif
|
||||
|
||||
ARCHIVAL-y:=
|
||||
ARCHIVAL-$(CONFIG_APT_GET) +=
|
||||
ARCHIVAL-$(CONFIG_AR) += ar.o
|
||||
ARCHIVAL-$(CONFIG_BUNZIP2) += bunzip2.o
|
||||
ARCHIVAL-$(CONFIG_CPIO) += cpio.o
|
||||
ARCHIVAL-$(CONFIG_DPKG) += dpkg.o
|
||||
ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
ARCHIVAL-$(CONFIG_GUNZIP) += gunzip.o
|
||||
ARCHIVAL-$(CONFIG_GZIP) += gzip.o
|
||||
ARCHIVAL-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
ARCHIVAL-$(CONFIG_RPM) += rpm.o
|
||||
ARCHIVAL-$(CONFIG_TAR) += tar.o
|
||||
ARCHIVAL-$(CONFIG_UNCOMPRESS) += uncompress.o
|
||||
ARCHIVAL-$(CONFIG_UNZIP) += unzip.o
|
||||
|
||||
libraries-y+=$(ARCHIVAL_DIR)$(ARCHIVAL_AR)
|
||||
|
||||
$(ARCHIVAL_DIR)$(ARCHIVAL_AR): $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
|
||||
$(AR) -ro $@ $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
|
||||
|
||||
+87
-33
@@ -21,70 +21,124 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* There is no signle standard to adhere to so ar may not portable
|
||||
* between different systems
|
||||
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <fnmatch.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
static void header_verbose_list_ar(const file_header_t *file_header)
|
||||
{
|
||||
const char *mode = bb_mode_string(file_header->mode);
|
||||
char *mtime;
|
||||
|
||||
mtime = ctime(&file_header->mtime);
|
||||
mtime[16] = ' ';
|
||||
memmove(&mtime[17], &mtime[20], 4);
|
||||
mtime[21] = '\0';
|
||||
printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid, (int) file_header->size, &mtime[4], file_header->name);
|
||||
}
|
||||
|
||||
#if !defined CONFIG_TAR && !defined CONFIG_DPKG_DEB && !defined CONFIG_CPIO
|
||||
/* This is simpler than data_extract_all */
|
||||
static void data_extract_regular_file(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header;
|
||||
int dst_fd;
|
||||
|
||||
file_header = archive_handle->file_header;
|
||||
dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT);
|
||||
archive_copy_file(archive_handle, dst_fd);
|
||||
close(dst_fd);
|
||||
|
||||
chmod(file_header->name, file_header->mode);
|
||||
chown(file_header->name, file_header->uid, file_header->gid);
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
|
||||
struct utimbuf t;
|
||||
t.actime = t.modtime = file_header->mtime;
|
||||
utime(file_header->name, &t);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
FILE *src_stream = NULL;
|
||||
char **extract_names = NULL;
|
||||
char ar_magic[8];
|
||||
int extract_function = extract_unconditional;
|
||||
archive_handle_t *archive_handle;
|
||||
int opt;
|
||||
int num_of_entries = 0;
|
||||
extern off_t archive_offset;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
#if !defined CONFIG_DPKG_DEB && !defined CONFIG_DPKG
|
||||
char magic[8];
|
||||
#endif
|
||||
archive_handle = init_handle();
|
||||
|
||||
while ((opt = getopt(argc, argv, "covtpxX")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
extract_function |= extract_preserve_date;
|
||||
case 'p': /* print */
|
||||
archive_handle->action_data = data_extract_to_stdout;
|
||||
break;
|
||||
case 'v':
|
||||
extract_function |= extract_verbose_list;
|
||||
case 't': /* list contents */
|
||||
archive_handle->action_header = header_list;
|
||||
break;
|
||||
case 't':
|
||||
extract_function |= extract_list;
|
||||
case 'X':
|
||||
archive_handle->action_header = header_verbose_list_ar;
|
||||
case 'x': /* extract */
|
||||
#if defined CONFIG_TAR || defined CONFIG_DPKG_DEB || defined CONFIG_CPIO
|
||||
archive_handle->action_data = data_extract_all;
|
||||
#else
|
||||
archive_handle->action_data = data_extract_regular_file;
|
||||
#endif
|
||||
break;
|
||||
case 'p':
|
||||
extract_function |= extract_to_stdout;
|
||||
/* Modifiers */
|
||||
case 'o': /* preserve original dates */
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
break;
|
||||
case 'x':
|
||||
extract_function |= extract_all_to_fs;
|
||||
case 'v': /* verbose */
|
||||
archive_handle->action_header = header_verbose_list_ar;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc) {
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
src_stream = xfopen(argv[optind++], "r");
|
||||
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
|
||||
/* check ar magic */
|
||||
fread(ar_magic, 1, 8, src_stream);
|
||||
archive_offset = 8;
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
/* Create a list of files to extract */
|
||||
/* TODO: This is the same as in tar, seperate function ? */
|
||||
while (optind < argc) {
|
||||
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
|
||||
extract_names[num_of_entries] = xstrdup(argv[optind]);
|
||||
num_of_entries++;
|
||||
extract_names[num_of_entries] = NULL;
|
||||
archive_handle->filter = filter_accept_list;
|
||||
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
unarchive(src_stream, stdout, &get_header_ar, extract_function, "./", extract_names, NULL);
|
||||
#if defined CONFIG_DPKG_DEB || defined CONFIG_DPKG
|
||||
unpack_ar_archive(archive_handle);
|
||||
#else
|
||||
archive_xread_all(archive_handle, magic, 7);
|
||||
if (strncmp(magic, "!<arch>", 7) != 0) {
|
||||
bb_error_msg_and_die("Invalid ar magic");
|
||||
}
|
||||
archive_handle->offset += 7;
|
||||
|
||||
while (get_header_ar(archive_handle) == EXIT_SUCCESS);
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+71
-2338
File diff suppressed because it is too large.
Load diff
@@ -1,23 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
mainmenu_option next_comment
|
||||
comment 'Archival Utilities'
|
||||
|
||||
bool 'ar' CONFIG_AR
|
||||
bool 'bunzip2' CONFIG_BUNZIP2
|
||||
bool 'cpio' CONFIG_CPIO
|
||||
bool 'dpkg' CONFIG_DPKG
|
||||
bool 'dpkg_deb' CONFIG_DPKG_DEB
|
||||
bool 'gunzip' CONFIG_GUNZIP
|
||||
bool 'gzip' CONFIG_GZIP
|
||||
bool 'rpm2cpio' CONFIG_RPM2CPIO
|
||||
bool 'tar' CONFIG_TAR
|
||||
if [ "$CONFIG_TAR" = "y" ] ; then
|
||||
bool ' Enable archive creation' CONFIG_FEATURE_TAR_CREATE
|
||||
bool ' Enable -X and --exclude options (exclude files)' CONFIG_FEATURE_TAR_EXCLUDE
|
||||
bool ' Enable -z option (currently only for extracting)' CONFIG_FEATURE_TAR_GZIP
|
||||
fi
|
||||
endmenu
|
||||
+28
-40
@@ -33,64 +33,52 @@
|
||||
|
||||
extern int cpio_main(int argc, char **argv)
|
||||
{
|
||||
FILE *src_stream = stdin;
|
||||
char **extract_names = NULL;
|
||||
int extract_function = 0;
|
||||
int num_of_entries = 0;
|
||||
int opt = 0;
|
||||
mode_t oldmask = 0;
|
||||
archive_handle_t *archive_handle;
|
||||
int opt;
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->src_fd = fileno(stdin);
|
||||
archive_handle->seek = seek_by_char;
|
||||
archive_handle->action_header = header_list;
|
||||
|
||||
while ((opt = getopt(argc, argv, "idmuvtF:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i': // extract
|
||||
extract_function |= extract_all_to_fs;
|
||||
case 'i': /* extract */
|
||||
archive_handle->action_data = data_extract_all;
|
||||
break;
|
||||
case 'd': // create _leading_ directories
|
||||
extract_function |= extract_create_leading_dirs;
|
||||
oldmask = umask(077); /* Make make_directory act like GNU cpio */
|
||||
case 'd': /* create _leading_ directories */
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
break;
|
||||
case 'm': // preserve modification time
|
||||
extract_function |= extract_preserve_date;
|
||||
case 'm': /* preserve modification time */
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
break;
|
||||
case 'v': // verbosly list files
|
||||
extract_function |= extract_verbose_list;
|
||||
case 'v': /* verbosly list files */
|
||||
archive_handle->action_header = header_verbose_list;
|
||||
break;
|
||||
case 'u': // unconditional
|
||||
extract_function |= extract_unconditional;
|
||||
case 'u': /* unconditional */
|
||||
archive_handle->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
break;
|
||||
case 't': // list files
|
||||
extract_function |= extract_list;
|
||||
case 't': /* list files */
|
||||
archive_handle->action_header = header_list;
|
||||
break;
|
||||
case 'F':
|
||||
src_stream = xfopen(optarg, "r");
|
||||
archive_handle->src_fd = bb_xopen(optarg, O_RDONLY);
|
||||
archive_handle->seek = seek_by_jump;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if ((extract_function & extract_all_to_fs) && (extract_function & extract_list)) {
|
||||
extract_function ^= extract_all_to_fs; /* If specify t, don't extract*/
|
||||
}
|
||||
|
||||
if ((extract_function & extract_all_to_fs) && (extract_function & extract_verbose_list)) {
|
||||
/* The meaning of v changes on extract */
|
||||
extract_function ^= extract_verbose_list;
|
||||
extract_function |= extract_list;
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
|
||||
extract_names[num_of_entries] = xstrdup(argv[optind]);
|
||||
num_of_entries++;
|
||||
extract_names[num_of_entries] = NULL;
|
||||
archive_handle->filter = filter_accept_list;
|
||||
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names, NULL);
|
||||
if (oldmask) {
|
||||
umask(oldmask); /* Restore umask if we changed it */
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
+326
-184
@@ -38,6 +38,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -176,7 +177,7 @@ int search_name_hashtable(const char *key)
|
||||
}
|
||||
}
|
||||
}
|
||||
name_hashtable[probe_address] = xstrdup(key);
|
||||
name_hashtable[probe_address] = bb_xstrdup(key);
|
||||
return(probe_address);
|
||||
}
|
||||
|
||||
@@ -217,10 +218,10 @@ int version_compare_part(const char *version1, const char *version2)
|
||||
int ret;
|
||||
|
||||
if (version1 == NULL) {
|
||||
version1 = xstrdup("");
|
||||
version1 = bb_xstrdup("");
|
||||
}
|
||||
if (version2 == NULL) {
|
||||
version2 = xstrdup("");
|
||||
version2 = bb_xstrdup("");
|
||||
}
|
||||
upstream_len1 = strlen(version1);
|
||||
upstream_len2 = strlen(version2);
|
||||
@@ -228,10 +229,10 @@ int version_compare_part(const char *version1, const char *version2)
|
||||
while ((len1 < upstream_len1) || (len2 < upstream_len2)) {
|
||||
/* Compare non-digit section */
|
||||
tmp_int = strcspn(&version1[len1], "0123456789");
|
||||
name1_char = xstrndup(&version1[len1], tmp_int);
|
||||
name1_char = bb_xstrndup(&version1[len1], tmp_int);
|
||||
len1 += tmp_int;
|
||||
tmp_int = strcspn(&version2[len2], "0123456789");
|
||||
name2_char = xstrndup(&version2[len2], tmp_int);
|
||||
name2_char = bb_xstrndup(&version2[len2], tmp_int);
|
||||
len2 += tmp_int;
|
||||
tmp_int = strcmp(name1_char, name2_char);
|
||||
free(name1_char);
|
||||
@@ -243,10 +244,10 @@ int version_compare_part(const char *version1, const char *version2)
|
||||
|
||||
/* Compare digits */
|
||||
tmp_int = strspn(&version1[len1], "0123456789");
|
||||
name1_char = xstrndup(&version1[len1], tmp_int);
|
||||
name1_char = bb_xstrndup(&version1[len1], tmp_int);
|
||||
len1 += tmp_int;
|
||||
tmp_int = strspn(&version2[len2], "0123456789");
|
||||
name2_char = xstrndup(&version2[len2], tmp_int);
|
||||
name2_char = bb_xstrndup(&version2[len2], tmp_int);
|
||||
len2 += tmp_int;
|
||||
ver_num1 = atoi(name1_char);
|
||||
ver_num2 = atoi(name2_char);
|
||||
@@ -305,8 +306,8 @@ int version_compare(const unsigned int ver1, const unsigned int ver2)
|
||||
}
|
||||
|
||||
/* Compare upstream version */
|
||||
upstream_ver1 = xstrdup(ver1_ptr);
|
||||
upstream_ver2 = xstrdup(ver2_ptr);
|
||||
upstream_ver1 = bb_xstrdup(ver1_ptr);
|
||||
upstream_ver2 = bb_xstrdup(ver2_ptr);
|
||||
|
||||
/* Chop off debian version, and store for later use */
|
||||
deb_ver1 = strrchr(upstream_ver1, '-');
|
||||
@@ -396,7 +397,7 @@ int search_package_hashtable(const unsigned int name, const unsigned int version
|
||||
*/
|
||||
void add_split_dependencies(common_node_t *parent_node, const char *whole_line, unsigned int edge_type)
|
||||
{
|
||||
char *line = xstrdup(whole_line);
|
||||
char *line = bb_xstrdup(whole_line);
|
||||
char *line2;
|
||||
char *line_ptr1 = NULL;
|
||||
char *line_ptr2 = NULL;
|
||||
@@ -409,7 +410,7 @@ void add_split_dependencies(common_node_t *parent_node, const char *whole_line,
|
||||
|
||||
field = strtok_r(line, ",", &line_ptr1);
|
||||
do {
|
||||
line2 = xstrdup(field);
|
||||
line2 = bb_xstrdup(field);
|
||||
field2 = strtok_r(line2, "|", &line_ptr2);
|
||||
if ((edge_type == EDGE_DEPENDS) && (strcmp(field, field2) != 0)) {
|
||||
type = EDGE_OR_DEPENDS;
|
||||
@@ -456,7 +457,7 @@ void add_split_dependencies(common_node_t *parent_node, const char *whole_line,
|
||||
else if (strncmp(version, ">=", offset_ch) == 0) {
|
||||
edge->operator = VER_MORE_EQUAL;
|
||||
} else {
|
||||
error_msg_and_die("Illegal operator\n");
|
||||
bb_error_msg_and_die("Illegal operator\n");
|
||||
}
|
||||
}
|
||||
/* skip to start of version numbers */
|
||||
@@ -487,26 +488,21 @@ void add_split_dependencies(common_node_t *parent_node, const char *whole_line,
|
||||
|
||||
void free_package(common_node_t *node)
|
||||
{
|
||||
int i;
|
||||
if (node != NULL) {
|
||||
unsigned short i;
|
||||
if (node) {
|
||||
for (i = 0; i < node->num_of_edges; i++) {
|
||||
if (node->edge[i] != NULL) {
|
||||
free(node->edge[i]);
|
||||
}
|
||||
}
|
||||
if (node->edge != NULL) {
|
||||
free(node->edge);
|
||||
}
|
||||
if (node != NULL) {
|
||||
free(node);
|
||||
free(node->edge[i]);
|
||||
}
|
||||
free(node->edge);
|
||||
free(node);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int fill_package_struct(char *control_buffer)
|
||||
{
|
||||
common_node_t *new_node = (common_node_t *) xcalloc(1, sizeof(common_node_t));
|
||||
|
||||
const char *field_names[] = { "Package", "Version", "Pre-Depends", "Depends",
|
||||
"Replaces", "Provides", "Conflicts", "Suggests", "Recommends", "Enhances", 0};
|
||||
char *field_name;
|
||||
char *field_value;
|
||||
int field_start = 0;
|
||||
@@ -515,50 +511,51 @@ unsigned int fill_package_struct(char *control_buffer)
|
||||
|
||||
new_node->version = search_name_hashtable("unknown");
|
||||
while (field_start < buffer_length) {
|
||||
unsigned short field_num;
|
||||
|
||||
field_start += read_package_field(&control_buffer[field_start],
|
||||
&field_name, &field_value);
|
||||
|
||||
if (field_name == NULL) {
|
||||
goto fill_package_struct_cleanup; // Oh no, the dreaded goto statement !!
|
||||
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement ! */
|
||||
}
|
||||
|
||||
if (strcmp(field_name, "Package") == 0) {
|
||||
new_node->name = search_name_hashtable(field_value);
|
||||
}
|
||||
else if (strcmp(field_name, "Version") == 0) {
|
||||
new_node->version = search_name_hashtable(field_value);
|
||||
}
|
||||
else if (strcmp(field_name, "Pre-Depends") == 0) {
|
||||
add_split_dependencies(new_node, field_value, EDGE_PRE_DEPENDS);
|
||||
}
|
||||
else if (strcmp(field_name, "Depends") == 0) {
|
||||
add_split_dependencies(new_node, field_value, EDGE_DEPENDS);
|
||||
}
|
||||
else if (strcmp(field_name, "Replaces") == 0) {
|
||||
add_split_dependencies(new_node, field_value, EDGE_REPLACES);
|
||||
}
|
||||
else if (strcmp(field_name, "Provides") == 0) {
|
||||
add_split_dependencies(new_node, field_value, EDGE_PROVIDES);
|
||||
}
|
||||
else if (strcmp(field_name, "Conflicts") == 0) {
|
||||
add_split_dependencies(new_node, field_value, EDGE_CONFLICTS);
|
||||
}
|
||||
else if (strcmp(field_name, "Suggests") == 0) {
|
||||
add_split_dependencies(new_node, field_value, EDGE_SUGGESTS);
|
||||
}
|
||||
else if (strcmp(field_name, "Recommends") == 0) {
|
||||
add_split_dependencies(new_node, field_value, EDGE_RECOMMENDS);
|
||||
}
|
||||
else if (strcmp(field_name, "Enhances") == 0) {
|
||||
add_split_dependencies(new_node, field_value, EDGE_ENHANCES);
|
||||
field_num = compare_string_array(field_names, field_name);
|
||||
switch(field_num) {
|
||||
case 0: /* Package */
|
||||
new_node->name = search_name_hashtable(field_value);
|
||||
break;
|
||||
case 1: /* Version */
|
||||
new_node->version = search_name_hashtable(field_value);
|
||||
break;
|
||||
case 2: /* Pre-Depends */
|
||||
add_split_dependencies(new_node, field_value, EDGE_PRE_DEPENDS);
|
||||
break;
|
||||
case 3: /* Depends */
|
||||
add_split_dependencies(new_node, field_value, EDGE_DEPENDS);
|
||||
break;
|
||||
case 4: /* Replaces */
|
||||
add_split_dependencies(new_node, field_value, EDGE_REPLACES);
|
||||
break;
|
||||
case 5: /* Provides */
|
||||
add_split_dependencies(new_node, field_value, EDGE_PROVIDES);
|
||||
break;
|
||||
case 6: /* Conflicts */
|
||||
add_split_dependencies(new_node, field_value, EDGE_CONFLICTS);
|
||||
break;
|
||||
case 7: /* Suggests */
|
||||
add_split_dependencies(new_node, field_value, EDGE_SUGGESTS);
|
||||
break;
|
||||
case 8: /* Recommends */
|
||||
add_split_dependencies(new_node, field_value, EDGE_RECOMMENDS);
|
||||
break;
|
||||
case 9: /* Enhances */
|
||||
add_split_dependencies(new_node, field_value, EDGE_ENHANCES);
|
||||
break;
|
||||
}
|
||||
fill_package_struct_cleanup:
|
||||
if (field_name) {
|
||||
free(field_name);
|
||||
}
|
||||
if (field_value) {
|
||||
free(field_value);
|
||||
}
|
||||
free(field_name);
|
||||
free(field_value);
|
||||
}
|
||||
|
||||
if (new_node->version == search_name_hashtable("unknown")) {
|
||||
@@ -591,7 +588,7 @@ unsigned int get_status(const unsigned int status_node, const int num)
|
||||
status_string += strspn(status_string, " ");
|
||||
}
|
||||
len = strcspn(status_string, " \n\0");
|
||||
state_sub_string = xstrndup(status_string, len);
|
||||
state_sub_string = bb_xstrndup(status_string, len);
|
||||
state_sub_num = search_name_hashtable(state_sub_string);
|
||||
free(state_sub_string);
|
||||
return(state_sub_num);
|
||||
@@ -623,7 +620,7 @@ void set_status(const unsigned int status_node_num, const char *new_value, const
|
||||
status_len = new_value_len;
|
||||
break;
|
||||
default:
|
||||
error_msg_and_die("DEBUG ONLY: this shouldnt happen");
|
||||
bb_error_msg_and_die("DEBUG ONLY: this shouldnt happen");
|
||||
}
|
||||
|
||||
new_status = (char *) xmalloc(want_len + flag_len + status_len + 3);
|
||||
@@ -641,7 +638,7 @@ void index_status_file(const char *filename)
|
||||
status_node_t *status_node = NULL;
|
||||
unsigned int status_num;
|
||||
|
||||
status_file = xfopen(filename, "r");
|
||||
status_file = bb_xfopen(filename, "r");
|
||||
while ((control_buffer = fgets_str(status_file, "\n\n")) != NULL) {
|
||||
const unsigned int package_num = fill_package_struct(control_buffer);
|
||||
if (package_num != -1) {
|
||||
@@ -651,7 +648,7 @@ void index_status_file(const char *filename)
|
||||
if (status_line != NULL) {
|
||||
status_line += 7;
|
||||
status_line += strspn(status_line, " \n\t");
|
||||
status_line = xstrndup(status_line, strcspn(status_line, "\n\0"));
|
||||
status_line = bb_xstrndup(status_line, strcspn(status_line, "\n\0"));
|
||||
status_node->status = search_name_hashtable(status_line);
|
||||
free(status_line);
|
||||
}
|
||||
@@ -757,8 +754,8 @@ void write_buffer_no_status(FILE *new_status_file, const char *control_buffer)
|
||||
/* This could do with a cleanup */
|
||||
void write_status_file(deb_file_t **deb_file)
|
||||
{
|
||||
FILE *old_status_file = xfopen("/var/lib/dpkg/status", "r");
|
||||
FILE *new_status_file = xfopen("/var/lib/dpkg/status.udeb", "w");
|
||||
FILE *old_status_file = bb_xfopen("/var/lib/dpkg/status", "r");
|
||||
FILE *new_status_file = bb_xfopen("/var/lib/dpkg/status.udeb", "w");
|
||||
char *package_name;
|
||||
char *status_from_file;
|
||||
char *control_buffer = NULL;
|
||||
@@ -776,14 +773,14 @@ void write_status_file(deb_file_t **deb_file)
|
||||
|
||||
tmp_string += 8;
|
||||
tmp_string += strspn(tmp_string, " \n\t");
|
||||
package_name = xstrndup(tmp_string, strcspn(tmp_string, "\n\0"));
|
||||
package_name = bb_xstrndup(tmp_string, strcspn(tmp_string, "\n\0"));
|
||||
write_flag = FALSE;
|
||||
tmp_string = strstr(control_buffer, "Status:");
|
||||
if (tmp_string != NULL) {
|
||||
/* Seperate the status value from the control buffer */
|
||||
tmp_string += 7;
|
||||
tmp_string += strspn(tmp_string, " \n\t");
|
||||
status_from_file = xstrndup(tmp_string, strcspn(tmp_string, "\n"));
|
||||
status_from_file = bb_xstrndup(tmp_string, strcspn(tmp_string, "\n"));
|
||||
} else {
|
||||
status_from_file = NULL;
|
||||
}
|
||||
@@ -813,7 +810,7 @@ void write_status_file(deb_file_t **deb_file)
|
||||
}
|
||||
/* This is temperary, debugging only */
|
||||
if (deb_file[i] == NULL) {
|
||||
error_msg_and_die("ALERT: Couldnt find a control file, your status file may be broken, status may be incorrect for %s", package_name);
|
||||
bb_error_msg_and_die("ALERT: Couldnt find a control file, your status file may be broken, status may be incorrect for %s", package_name);
|
||||
}
|
||||
}
|
||||
else if (strcmp("not-installed", name_hashtable[state_status]) == 0) {
|
||||
@@ -858,13 +855,11 @@ void write_status_file(deb_file_t **deb_file)
|
||||
}
|
||||
}
|
||||
/* If the package from the status file wasnt handle above, do it now*/
|
||||
if (write_flag == FALSE) {
|
||||
if (! write_flag) {
|
||||
fprintf(new_status_file, "%s\n\n", control_buffer);
|
||||
}
|
||||
|
||||
if (status_from_file != NULL) {
|
||||
free(status_from_file);
|
||||
}
|
||||
free(status_from_file);
|
||||
free(package_name);
|
||||
free(control_buffer);
|
||||
}
|
||||
@@ -886,15 +881,15 @@ void write_status_file(deb_file_t **deb_file)
|
||||
if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
|
||||
struct stat stat_buf;
|
||||
if (stat("/var/lib/dpkg/status", &stat_buf) == 0) {
|
||||
error_msg_and_die("Couldnt create backup status file");
|
||||
bb_error_msg_and_die("Couldnt create backup status file");
|
||||
}
|
||||
/* Its ok if renaming the status file fails becasue status
|
||||
* file doesnt exist, maybe we are starting from scratch */
|
||||
error_msg("No status file found, creating new one");
|
||||
bb_error_msg("No status file found, creating new one");
|
||||
}
|
||||
|
||||
if (rename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status") == -1) {
|
||||
error_msg_and_die("DANGER: Couldnt create status file, you need to manually repair your status file");
|
||||
bb_error_msg_and_die("DANGER: Couldnt create status file, you need to manually repair your status file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -905,9 +900,8 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
int state_status;
|
||||
int state_flag;
|
||||
int state_want;
|
||||
unsigned int status_package_num;
|
||||
int i = deb_start;
|
||||
int j, k;
|
||||
int j;
|
||||
|
||||
/* Check for conflicts
|
||||
* TODO: TEST if conflicts with other packages to be installed
|
||||
@@ -948,38 +942,49 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
}
|
||||
|
||||
/* Check conflicts */
|
||||
for (i = 0; i < conflicts_num; i++) {
|
||||
/* Check for conflicts */
|
||||
for (j = 0; j < STATUS_HASH_PRIME; j++) {
|
||||
if (status_hashtable[j] == NULL) {
|
||||
continue;
|
||||
}
|
||||
state_flag = get_status(j, 2);
|
||||
state_status = get_status(j, 3);
|
||||
if ((state_status != search_name_hashtable("installed"))
|
||||
&& (state_flag != search_name_hashtable("want-install"))) {
|
||||
continue;
|
||||
}
|
||||
status_package_num = status_hashtable[j]->package;
|
||||
for (k = 0; k < package_hashtable[status_package_num]->num_of_edges; k++) {
|
||||
const edge_t *package_edge = package_hashtable[status_package_num]->edge[k];
|
||||
if (package_edge->type != EDGE_CONFLICTS) {
|
||||
continue;
|
||||
i = 0;
|
||||
while (deb_file[i] != NULL) {
|
||||
const common_node_t *package_node = package_hashtable[deb_file[i]->package];
|
||||
int status_num = 0;
|
||||
status_num = search_status_hashtable(name_hashtable[package_node->name]);
|
||||
|
||||
if (get_status(status_num, 3) == search_name_hashtable("installed")) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < package_node->num_of_edges; j++) {
|
||||
const edge_t *package_edge = package_node->edge[j];
|
||||
const unsigned int package_num =
|
||||
search_package_hashtable(package_edge->name,
|
||||
package_edge->version, package_edge->operator);
|
||||
|
||||
if (package_edge->type == EDGE_CONFLICTS) {
|
||||
int result = 0;
|
||||
if (package_hashtable[package_num] != NULL) {
|
||||
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
|
||||
state_status = get_status(status_num, 3);
|
||||
state_flag = get_status(status_num, 1);
|
||||
|
||||
result = (state_status == search_name_hashtable("installed")) ||
|
||||
(state_flag == search_name_hashtable("want-install"));
|
||||
|
||||
if (result) {
|
||||
result = test_version(package_hashtable[deb_file[i]->package]->version,
|
||||
package_edge->version, package_edge->operator);
|
||||
}
|
||||
}
|
||||
if (package_edge->name != package_hashtable[conflicts[i]]->name) {
|
||||
continue;
|
||||
}
|
||||
/* There is a conflict against the package name
|
||||
* check if version conflict as well */
|
||||
if (test_version(package_hashtable[deb_file[i]->package]->version,
|
||||
package_edge->version, package_edge->operator)) {
|
||||
error_msg_and_die("Package %s conflict with %s",
|
||||
name_hashtable[package_hashtable[deb_file[i]->package]->name],
|
||||
name_hashtable[package_hashtable[status_package_num]->name]);
|
||||
|
||||
if (result) {
|
||||
bb_error_msg_and_die("Package %s conflicts with %s",
|
||||
name_hashtable[package_node->name],
|
||||
name_hashtable[package_edge->name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
/* Check dependendcies */
|
||||
i = 0;
|
||||
@@ -987,36 +992,58 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
const common_node_t *package_node = package_hashtable[deb_file[i]->package];
|
||||
int status_num = 0;
|
||||
|
||||
status_num = search_status_hashtable(name_hashtable[package_node->name]);
|
||||
state_status = get_status(status_num, 3);
|
||||
state_want = get_status(status_num, 1);
|
||||
|
||||
if (state_status == search_name_hashtable("installed")) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < package_hashtable[deb_file[i]->package]->num_of_edges; j++) {
|
||||
const edge_t *package_edge = package_node->edge[j];
|
||||
const unsigned int package_num = search_package_hashtable(package_edge->name,
|
||||
package_edge->version, package_edge->operator);
|
||||
unsigned int package_num;
|
||||
|
||||
package_num = search_package_hashtable(package_edge->name, package_edge->version, package_edge->operator);
|
||||
|
||||
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
|
||||
state_status = get_status(status_num, 3);
|
||||
state_want = get_status(status_num, 1);
|
||||
switch (package_edge->type) {
|
||||
case(EDGE_PRE_DEPENDS):
|
||||
case(EDGE_OR_PRE_DEPENDS):
|
||||
case(EDGE_OR_PRE_DEPENDS): {
|
||||
int result=1;
|
||||
/* It must be already installed */
|
||||
/* NOTE: This is untested, nothing apropriate in my status file */
|
||||
if ((package_hashtable[package_num] == NULL) || (state_status != search_name_hashtable("installed"))) {
|
||||
error_msg_and_die("Package %s pre-depends on %s, but it is not installed",
|
||||
if (package_hashtable[package_num] != NULL) {
|
||||
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
|
||||
state_status = get_status(status_num, 3);
|
||||
state_want = get_status(status_num, 1);
|
||||
result = (state_status != search_name_hashtable("installed"));
|
||||
}
|
||||
|
||||
if (result) {
|
||||
bb_error_msg_and_die("Package %s pre-depends on %s, but it is not installed",
|
||||
name_hashtable[package_node->name],
|
||||
name_hashtable[package_edge->name]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(EDGE_DEPENDS):
|
||||
case(EDGE_OR_DEPENDS):
|
||||
case(EDGE_OR_DEPENDS): {
|
||||
int result=1;
|
||||
if (package_hashtable[package_num] != NULL) {
|
||||
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
|
||||
state_status = get_status(status_num, 3);
|
||||
state_want = get_status(status_num, 1);
|
||||
result=(state_status != search_name_hashtable("installed")) && (state_want != search_name_hashtable("want-install"));
|
||||
}
|
||||
/* It must be already installed, or to be installed */
|
||||
if ((package_hashtable[package_num] == NULL) ||
|
||||
((state_status != search_name_hashtable("installed")) &&
|
||||
(state_want != search_name_hashtable("want_install")))) {
|
||||
error_msg_and_die("Package %s depends on %s, but it is not installed, or flaged to be installed",
|
||||
if (result) {
|
||||
bb_error_msg_and_die("Package %s depends on %s, but it is not installed, or flaged to be installed",
|
||||
name_hashtable[package_node->name],
|
||||
name_hashtable[package_edge->name]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
@@ -1028,30 +1055,22 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
char **create_list(const char *filename)
|
||||
{
|
||||
FILE *list_stream;
|
||||
char **file_list = xmalloc(sizeof(char *));
|
||||
char **file_list = NULL;
|
||||
char *line = NULL;
|
||||
char *last_char;
|
||||
int length = 0;
|
||||
int count = 0;
|
||||
|
||||
/* dont use [xw]fopen here, handle error ourself */
|
||||
list_stream = fopen(filename, "r");
|
||||
if (list_stream == NULL) {
|
||||
*file_list = NULL;
|
||||
return(file_list);
|
||||
return(NULL);
|
||||
}
|
||||
while (getline(&line, &length, list_stream) != -1) {
|
||||
/* +2 as we need to include space for the terminating NULL pointer */
|
||||
file_list = xrealloc(file_list, sizeof(char *) * (length + 2));
|
||||
last_char = last_char_is(line, '\n');
|
||||
if (last_char) {
|
||||
*last_char = '\0';
|
||||
}
|
||||
file_list[count] = xstrdup(line);
|
||||
|
||||
while ((line = bb_get_chomped_line_from_file(list_stream)) != NULL) {
|
||||
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
|
||||
file_list[count] = line;
|
||||
count++;
|
||||
}
|
||||
fclose(list_stream);
|
||||
free(line);
|
||||
|
||||
if (count == 0) {
|
||||
return(NULL);
|
||||
@@ -1119,20 +1138,37 @@ int run_package_script(const char *package_name, const char *script_type)
|
||||
return(result);
|
||||
}
|
||||
|
||||
void all_control_list(char **remove_files, const char *package_name)
|
||||
char **all_control_list(const char *package_name)
|
||||
{
|
||||
const char *all_extensions[11] = {"preinst", "postinst", "prerm", "postrm",
|
||||
const char *extensions[11] = {"preinst", "postinst", "prerm", "postrm",
|
||||
"list", "md5sums", "shlibs", "conffiles", "config", "templates", NULL };
|
||||
int i;
|
||||
unsigned short i = 0;
|
||||
char **remove_files;
|
||||
|
||||
/* Create a list of all /var/lib/dpkg/info/<package> files */
|
||||
for(i = 0; i < 10; i++) {
|
||||
remove_files[i] = xmalloc(strlen(package_name) + strlen(all_extensions[i]) + 21);
|
||||
sprintf(remove_files[i], "/var/lib/dpkg/info/%s.%s", package_name, all_extensions[i]);
|
||||
remove_files = malloc(sizeof(char *) * 11);
|
||||
while (extensions[i]) {
|
||||
remove_files[i] = xmalloc(strlen(package_name) + strlen(extensions[i]) + 21);
|
||||
sprintf(remove_files[i], "/var/lib/dpkg/info/%s.%s", package_name, extensions[i]);
|
||||
i++;
|
||||
}
|
||||
remove_files[10] = NULL;
|
||||
|
||||
return(remove_files);
|
||||
}
|
||||
|
||||
void free_array(char **array)
|
||||
{
|
||||
|
||||
if (array) {
|
||||
unsigned short i = 0;
|
||||
while (array[i]) {
|
||||
free(array[i]);
|
||||
i++;
|
||||
}
|
||||
free(array);
|
||||
}
|
||||
}
|
||||
|
||||
/* This function lists information on the installed packages. It loops through
|
||||
* the status_hashtable to retrieve the info. This results in smaller code than
|
||||
@@ -1191,7 +1227,7 @@ void remove_package(const unsigned int package_num)
|
||||
/* run prerm script */
|
||||
return_value = run_package_script(package_name, "prerm");
|
||||
if (return_value == -1) {
|
||||
error_msg_and_die("script failed, prerm failure");
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
|
||||
/* Create a list of files to remove, and a seperate list of those to keep */
|
||||
@@ -1202,20 +1238,23 @@ void remove_package(const unsigned int package_num)
|
||||
exclude_files = create_list(conffile_name);
|
||||
|
||||
/* Some directories cant be removed straight away, so do multiple passes */
|
||||
while (remove_file_array(remove_files, exclude_files) == TRUE);
|
||||
|
||||
/* Create a list of all /var/lib/dpkg/info/<package> files */
|
||||
remove_files = xmalloc(11);
|
||||
all_control_list(remove_files, package_name);
|
||||
while (remove_file_array(remove_files, exclude_files));
|
||||
free_array(exclude_files);
|
||||
free_array(remove_files);
|
||||
|
||||
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
|
||||
exclude_files = xmalloc(sizeof(char*) * 3);
|
||||
exclude_files[0] = xstrdup(conffile_name);
|
||||
exclude_files[0] = bb_xstrdup(conffile_name);
|
||||
exclude_files[1] = xmalloc(package_name_length + 27);
|
||||
sprintf(exclude_files[1], "/var/lib/dpkg/info/%s.postrm", package_name);
|
||||
exclude_files[2] = NULL;
|
||||
|
||||
/* Create a list of all /var/lib/dpkg/info/<package> files */
|
||||
remove_files = all_control_list(package_name);
|
||||
|
||||
remove_file_array(remove_files, exclude_files);
|
||||
free_array(remove_files);
|
||||
free_array(exclude_files);
|
||||
|
||||
/* rename <package>.conffile to <package>.list */
|
||||
rename(conffile_name, list_name);
|
||||
@@ -1235,27 +1274,29 @@ void purge_package(const unsigned int package_num)
|
||||
|
||||
/* run prerm script */
|
||||
if (run_package_script(package_name, "prerm") != 0) {
|
||||
error_msg_and_die("script failed, prerm failure");
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
|
||||
/* Create a list of files to remove */
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
|
||||
remove_files = create_list(list_name);
|
||||
|
||||
exclude_files = xmalloc(1);
|
||||
exclude_files = xmalloc(sizeof(char*));
|
||||
exclude_files[0] = NULL;
|
||||
|
||||
/* Some directories cant be removed straight away, so do multiple passes */
|
||||
while (remove_file_array(remove_files, exclude_files) == TRUE);
|
||||
while (remove_file_array(remove_files, exclude_files));
|
||||
free_array(remove_files);
|
||||
|
||||
/* Create a list of all /var/lib/dpkg/info/<package> files */
|
||||
remove_files = xmalloc(11);
|
||||
all_control_list(remove_files, package_name);
|
||||
remove_files = all_control_list(package_name);
|
||||
remove_file_array(remove_files, exclude_files);
|
||||
free_array(remove_files);
|
||||
free(exclude_files);
|
||||
|
||||
/* run postrm script */
|
||||
if (run_package_script(package_name, "postrm") == -1) {
|
||||
error_msg_and_die("postrm fialure.. set status to what?");
|
||||
bb_error_msg_and_die("postrm fialure.. set status to what?");
|
||||
}
|
||||
|
||||
/* Change package status */
|
||||
@@ -1263,14 +1304,97 @@ void purge_package(const unsigned int package_num)
|
||||
set_status(status_num, "not-installed", 3);
|
||||
}
|
||||
|
||||
void unpack_package(deb_file_t *deb_file)
|
||||
static archive_handle_t *init_archive_deb_ar(const char *filename)
|
||||
{
|
||||
archive_handle_t *ar_handle;
|
||||
|
||||
/* Setup an ar archive handle that refers to the gzip sub archive */
|
||||
ar_handle = init_handle();
|
||||
ar_handle->filter = filter_accept_list_reassign;
|
||||
ar_handle->src_fd = bb_xopen(filename, O_RDONLY);
|
||||
|
||||
return(ar_handle);
|
||||
}
|
||||
|
||||
static void init_archive_deb_control(archive_handle_t *ar_handle)
|
||||
{
|
||||
archive_handle_t *tar_handle;
|
||||
|
||||
/* Setup the tar archive handle */
|
||||
tar_handle = init_handle();
|
||||
tar_handle->filter = filter_accept_list;
|
||||
tar_handle->src_fd = ar_handle->src_fd;
|
||||
|
||||
/* We dont care about data.tar.* or debian-binary, just control.tar.* */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
ar_handle->accept = llist_add_to(NULL, "control.tar.gz");
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
ar_handle->accept = llist_add_to(ar_handle->accept, "control.tar.bz2");
|
||||
#endif
|
||||
|
||||
/* Assign the tar handle as a subarchive of the ar handle */
|
||||
ar_handle->sub_archive = tar_handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void init_archive_deb_data(archive_handle_t *ar_handle)
|
||||
{
|
||||
archive_handle_t *tar_handle;
|
||||
|
||||
/* Setup the tar archive handle */
|
||||
tar_handle = init_handle();
|
||||
tar_handle->filter = filter_accept_all;
|
||||
tar_handle->src_fd = ar_handle->src_fd;
|
||||
|
||||
/* We dont care about data.tar.* or debian-binary, just control.tar.* */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
tar_handle->accept = llist_add_to(NULL, "data.tar.gz");
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
tar_handle->accept = llist_add_to(ar_handle->accept, "data.tar.bz2");
|
||||
#endif
|
||||
|
||||
/* Assign the tar handle as a subarchive of the ar handle */
|
||||
ar_handle->sub_archive = tar_handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *accept)
|
||||
{
|
||||
ar_handle->sub_archive->action_data = data_extract_to_buffer;
|
||||
ar_handle->sub_archive->accept = accept;
|
||||
|
||||
unpack_ar_archive(ar_handle);
|
||||
close(ar_handle->src_fd);
|
||||
|
||||
return(ar_handle->sub_archive->buffer);
|
||||
}
|
||||
|
||||
static void data_extract_all_prefix(archive_handle_t *archive_handle)
|
||||
{
|
||||
char *name_ptr = archive_handle->file_header->name;
|
||||
|
||||
name_ptr += strspn(name_ptr, "./");
|
||||
if (name_ptr[0] != '\0') {
|
||||
archive_handle->file_header->name = xmalloc(strlen(archive_handle->buffer) + 2 + strlen(name_ptr));
|
||||
strcpy(archive_handle->file_header->name, archive_handle->buffer);
|
||||
strcat(archive_handle->file_header->name, name_ptr);
|
||||
data_extract_all(archive_handle);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void unpack_package(deb_file_t *deb_file)
|
||||
{
|
||||
const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name];
|
||||
const unsigned int status_num = search_status_hashtable(package_name);
|
||||
const unsigned int status_package_num = status_hashtable[status_num]->package;
|
||||
|
||||
FILE *out_stream;
|
||||
char *info_prefix;
|
||||
archive_handle_t *archive_handle;
|
||||
FILE *out_stream;
|
||||
|
||||
/* If existing version, remove it first */
|
||||
if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
|
||||
@@ -1284,23 +1408,34 @@ void unpack_package(deb_file_t *deb_file)
|
||||
}
|
||||
|
||||
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
|
||||
info_prefix = (char *) xmalloc(sizeof(package_name) + 20 + 4 + 1);
|
||||
info_prefix = (char *) xmalloc(strlen(package_name) + 20 + 4 + 2);
|
||||
sprintf(info_prefix, "/var/lib/dpkg/info/%s.", package_name);
|
||||
deb_extract(deb_file->filename, stdout, (extract_quiet | extract_control_tar_gz | extract_all_to_fs | extract_unconditional), info_prefix, NULL);
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
init_archive_deb_control(archive_handle);
|
||||
archive_handle->sub_archive->action_data = data_extract_all_prefix;
|
||||
archive_handle->sub_archive->buffer = info_prefix;
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
/* Run the preinst prior to extracting */
|
||||
if (run_package_script(package_name, "preinst") != 0) {
|
||||
/* when preinst returns exit code != 0 then quit installation process */
|
||||
error_msg_and_die("subprocess pre-installation script returned error.");
|
||||
bb_error_msg_and_die("subprocess pre-installation script returned error.");
|
||||
}
|
||||
|
||||
/* Extract data.tar.gz to the root directory */
|
||||
deb_extract(deb_file->filename, stdout, (extract_quiet | extract_data_tar_gz | extract_all_to_fs | extract_unconditional), "/", NULL);
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
init_archive_deb_data(archive_handle);
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
/* Create the list file */
|
||||
strcat(info_prefix, "list");
|
||||
out_stream = xfopen(info_prefix, "w");
|
||||
deb_extract(deb_file->filename, out_stream, (extract_quiet | extract_data_tar_gz | extract_list), "/", NULL);
|
||||
out_stream = bb_xfopen(info_prefix, "w");
|
||||
while (archive_handle->passed) {
|
||||
/* blindly skip over the leading '.' */
|
||||
fputs(archive_handle->passed->data + 1, out_stream);
|
||||
fputc('\n', out_stream);
|
||||
archive_handle->passed = archive_handle->passed->link;
|
||||
}
|
||||
fclose(out_stream);
|
||||
|
||||
/* change status */
|
||||
@@ -1321,14 +1456,14 @@ void configure_package(deb_file_t *deb_file)
|
||||
/* Run the postinst script */
|
||||
if (run_package_script(package_name, "postinst") != 0) {
|
||||
/* TODO: handle failure gracefully */
|
||||
error_msg_and_die("postrm failure.. set status to what?");
|
||||
bb_error_msg_and_die("postrm failure.. set status to what?");
|
||||
}
|
||||
/* Change status to reflect success */
|
||||
set_status(status_num, "install", 1);
|
||||
set_status(status_num, "installed", 3);
|
||||
}
|
||||
|
||||
extern int dpkg_main(int argc, char **argv)
|
||||
int dpkg_main(int argc, char **argv)
|
||||
{
|
||||
deb_file_t **deb_file = NULL;
|
||||
status_node_t *status_node;
|
||||
@@ -1370,12 +1505,12 @@ extern int dpkg_main(int argc, char **argv)
|
||||
dpkg_opt |= dpkg_opt_filename;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
/* check for non-otion argument if expected */
|
||||
if ((dpkg_opt == 0) || ((argc == optind) && !(dpkg_opt && dpkg_opt_list_installed))) {
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
|
||||
@@ -1388,27 +1523,35 @@ extern int dpkg_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Read arguments and store relevant info in structs */
|
||||
deb_file = xmalloc(sizeof(deb_file_t));
|
||||
while (optind < argc) {
|
||||
/* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
|
||||
deb_file = xrealloc(deb_file, sizeof(deb_file_t *) * (deb_count + 2));
|
||||
deb_file[deb_count] = (deb_file_t *) xmalloc(sizeof(deb_file_t));
|
||||
if (dpkg_opt & dpkg_opt_filename) {
|
||||
deb_file[deb_count]->filename = xstrdup(argv[optind]);
|
||||
deb_file[deb_count]->control_file = deb_extract(argv[optind], stdout, (extract_control_tar_gz | extract_one_to_buffer), NULL, "./control");
|
||||
archive_handle_t *archive_handle;
|
||||
llist_t *control_list = NULL;
|
||||
|
||||
/* Extract the control file */
|
||||
control_list = llist_add_to(NULL, "./control");
|
||||
archive_handle = init_archive_deb_ar(argv[optind]);
|
||||
init_archive_deb_control(archive_handle);
|
||||
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
|
||||
if (deb_file[deb_count]->control_file == NULL) {
|
||||
error_msg_and_die("Couldnt extract control file");
|
||||
bb_error_msg_and_die("Couldnt extract control file");
|
||||
}
|
||||
deb_file[deb_count]->filename = bb_xstrdup(argv[optind]);
|
||||
package_num = fill_package_struct(deb_file[deb_count]->control_file);
|
||||
|
||||
if (package_num == -1) {
|
||||
error_msg("Invalid control file in %s", argv[optind]);
|
||||
bb_error_msg("Invalid control file in %s", argv[optind]);
|
||||
continue;
|
||||
}
|
||||
deb_file[deb_count]->package = (unsigned int) package_num;
|
||||
|
||||
/* Add the package to the status hashtable */
|
||||
if ((dpkg_opt & dpkg_opt_unpack) || (dpkg_opt & dpkg_opt_install)) {
|
||||
status_node = (status_node_t *) xmalloc(sizeof(status_node_t));
|
||||
status_node->package = deb_file[deb_count]->package;
|
||||
|
||||
/* Try and find a currently installed version of this package */
|
||||
status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
|
||||
/* If no previous entry was found initialise a new entry */
|
||||
@@ -1416,10 +1559,10 @@ extern int dpkg_main(int argc, char **argv)
|
||||
(status_hashtable[status_num]->status == 0)) {
|
||||
/* reinstreq isnt changed to "ok" until the package control info
|
||||
* is written to the status file*/
|
||||
status_node->status = search_name_hashtable("install reinstreq not-installed");
|
||||
status_node->status = search_name_hashtable("want-install reinstreq not-installed");
|
||||
status_hashtable[status_num] = status_node;
|
||||
} else {
|
||||
status_hashtable[status_num]->status = search_name_hashtable("install reinstreq installed");
|
||||
status_hashtable[status_num]->status = search_name_hashtable("want-install reinstreq not-installed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1430,7 +1573,7 @@ extern int dpkg_main(int argc, char **argv)
|
||||
search_name_hashtable(argv[optind]),
|
||||
search_name_hashtable("ANY"), VER_ANY);
|
||||
if (package_hashtable[deb_file[deb_count]->package] == NULL) {
|
||||
error_msg_and_die("Package %s is uninstalled or unknown\n", argv[optind]);
|
||||
bb_error_msg_and_die("Package %s is uninstalled or unknown\n", argv[optind]);
|
||||
}
|
||||
state_status = get_status(search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]), 3);
|
||||
|
||||
@@ -1438,13 +1581,13 @@ extern int dpkg_main(int argc, char **argv)
|
||||
if (dpkg_opt & dpkg_opt_remove) {
|
||||
if ((strcmp(name_hashtable[state_status], "not-installed") == 0) ||
|
||||
(strcmp(name_hashtable[state_status], "config-files") == 0)) {
|
||||
error_msg_and_die("%s is already removed.", name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
|
||||
bb_error_msg_and_die("%s is already removed.", name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
|
||||
}
|
||||
}
|
||||
else if (dpkg_opt & dpkg_opt_purge) {
|
||||
/* if package status is "conf-files" then its ok */
|
||||
if (strcmp(name_hashtable[state_status], "not-installed") == 0) {
|
||||
error_msg_and_die("%s is already purged.", name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
|
||||
bb_error_msg_and_die("%s is already purged.", name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1457,7 +1600,7 @@ extern int dpkg_main(int argc, char **argv)
|
||||
/* TODO: check dependencies before removing */
|
||||
if ((dpkg_opt & dpkg_opt_force_ignore_depends) != dpkg_opt_force_ignore_depends) {
|
||||
if (!check_deps(deb_file, 0, deb_count)) {
|
||||
error_msg_and_die("Dependency check failed");
|
||||
bb_error_msg_and_die("Dependency check failed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1488,22 +1631,21 @@ extern int dpkg_main(int argc, char **argv)
|
||||
free(deb_file[i]->filename);
|
||||
free(deb_file[i]);
|
||||
}
|
||||
|
||||
free(deb_file);
|
||||
|
||||
for (i = 0; i < NAME_HASH_PRIME; i++) {
|
||||
if (name_hashtable[i] != NULL) {
|
||||
free(name_hashtable[i]);
|
||||
}
|
||||
free(name_hashtable[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < PACKAGE_HASH_PRIME; i++) {
|
||||
free_package(package_hashtable[i]);
|
||||
if (package_hashtable[i] != NULL) {
|
||||
free_package(package_hashtable[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < STATUS_HASH_PRIME; i++) {
|
||||
if (status_hashtable[i] != NULL) {
|
||||
free(status_hashtable[i]);
|
||||
}
|
||||
free(status_hashtable[i]);
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
|
||||
+59
-83
@@ -13,119 +13,95 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
char *prefix = NULL;
|
||||
char *filename = NULL;
|
||||
char *output_buffer = NULL;
|
||||
archive_handle_t *ar_archive;
|
||||
archive_handle_t *tar_archive;
|
||||
int opt = 0;
|
||||
int arg_type = 0;
|
||||
int deb_extract_funct = extract_create_leading_dirs | extract_unconditional;
|
||||
#ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
llist_t *control_tar_llist = NULL;
|
||||
#endif
|
||||
|
||||
const int arg_type_prefix = 1;
|
||||
const int arg_type_field = 2;
|
||||
const int arg_type_filename = 4;
|
||||
// const int arg_type_un_ar_gz = 8;
|
||||
/* Setup the tar archive handle */
|
||||
tar_archive = init_handle();
|
||||
|
||||
while ((opt = getopt(argc, argv, "ceftXxI")) != -1) {
|
||||
/* Setup an ar archive handle that refers to the gzip sub archive */
|
||||
ar_archive = init_handle();
|
||||
ar_archive->sub_archive = tar_archive;
|
||||
ar_archive->filter = filter_accept_list_reassign;
|
||||
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
ar_archive->accept = llist_add_to(NULL, "data.tar.gz");
|
||||
# ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
control_tar_llist = llist_add_to(NULL, "control.tar.gz");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
ar_archive->accept = llist_add_to(ar_archive->accept, "data.tar.bz2");
|
||||
# ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
control_tar_llist = llist_add_to(control_tar_llist, "control.tar.bz2");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
while ((opt = getopt(argc, argv, "cefXx")) != -1) {
|
||||
#else
|
||||
while ((opt = getopt(argc, argv, "x")) != -1) {
|
||||
#endif
|
||||
switch (opt) {
|
||||
#ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
case 'c':
|
||||
deb_extract_funct |= extract_data_tar_gz;
|
||||
deb_extract_funct |= extract_verbose_list;
|
||||
tar_archive->action_header = header_verbose_list;
|
||||
break;
|
||||
case 'e':
|
||||
arg_type = arg_type_prefix;
|
||||
deb_extract_funct |= extract_control_tar_gz;
|
||||
deb_extract_funct |= extract_all_to_fs;
|
||||
ar_archive->accept = control_tar_llist;
|
||||
tar_archive->action_data = data_extract_all;
|
||||
break;
|
||||
case 'f':
|
||||
arg_type = arg_type_field;
|
||||
deb_extract_funct |= extract_control_tar_gz;
|
||||
deb_extract_funct |= extract_one_to_buffer;
|
||||
filename = xstrdup("./control");
|
||||
break;
|
||||
case 't': /* --fsys-tarfile, i just made up this short name */
|
||||
/* Integrate the functionality needed with some code from ar.c */
|
||||
error_msg_and_die("Option disabled");
|
||||
// arg_type = arg_type_un_ar_gz;
|
||||
/* Print the entire control file
|
||||
* it should accept a second argument which specifies a
|
||||
* specific field to print */
|
||||
ar_archive->accept = control_tar_llist;
|
||||
tar_archive->accept = llist_add_to(NULL, "./control");;
|
||||
tar_archive->filter = filter_accept_list;
|
||||
tar_archive->action_data = data_extract_to_stdout;
|
||||
break;
|
||||
case 'X':
|
||||
arg_type = arg_type_prefix;
|
||||
deb_extract_funct |= extract_data_tar_gz;
|
||||
deb_extract_funct |= extract_all_to_fs;
|
||||
deb_extract_funct |= extract_list;
|
||||
tar_archive->action_header = header_list;
|
||||
#endif
|
||||
case 'x':
|
||||
arg_type = arg_type_prefix;
|
||||
deb_extract_funct |= extract_data_tar_gz;
|
||||
deb_extract_funct |= extract_all_to_fs;
|
||||
break;
|
||||
case 'I':
|
||||
arg_type = arg_type_filename;
|
||||
deb_extract_funct |= extract_control_tar_gz;
|
||||
deb_extract_funct |= extract_one_to_buffer;
|
||||
tar_archive->action_data = data_extract_all;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc) {
|
||||
show_usage();
|
||||
if (optind + 2 < argc) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
tar_archive->src_fd = ar_archive->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
|
||||
/* Workout where to extract the files */
|
||||
if (arg_type == arg_type_prefix) {
|
||||
/* argument is a dir name */
|
||||
if ((optind + 1) == argc ) {
|
||||
prefix = xstrdup("./DEBIAN/");
|
||||
} else {
|
||||
prefix = (char *) xmalloc(strlen(argv[optind + 1]) + 2);
|
||||
strcpy(prefix, argv[optind + 1]);
|
||||
/* Make sure the directory has a trailing '/' */
|
||||
if (last_char_is(prefix, '/') == NULL) {
|
||||
strcat(prefix, "/");
|
||||
}
|
||||
}
|
||||
mkdir(prefix, 0777);
|
||||
}
|
||||
/* 2nd argument is a dir name */
|
||||
mkdir(argv[optind], 0777);
|
||||
chdir(argv[optind]);
|
||||
|
||||
if (arg_type == arg_type_filename) {
|
||||
if ((optind + 1) != argc) {
|
||||
filename = xstrdup(argv[optind + 1]);
|
||||
} else {
|
||||
error_msg_and_die("-I currently requires a filename to be specified");
|
||||
}
|
||||
}
|
||||
unpack_ar_archive(ar_archive);
|
||||
|
||||
output_buffer = deb_extract(argv[optind], stdout, deb_extract_funct, prefix, filename);
|
||||
|
||||
if ((arg_type == arg_type_filename) && (output_buffer != NULL)) {
|
||||
puts(output_buffer);
|
||||
}
|
||||
else if (arg_type == arg_type_field) {
|
||||
char *field = NULL;
|
||||
char *name;
|
||||
char *value;
|
||||
int field_start = 0;
|
||||
|
||||
while (1) {
|
||||
field_start += read_package_field(&output_buffer[field_start], &name, &value);
|
||||
if (name == NULL) {
|
||||
break;
|
||||
}
|
||||
if (strcmp(name, argv[optind + 1]) == 0) {
|
||||
puts(value);
|
||||
}
|
||||
free(field);
|
||||
}
|
||||
}
|
||||
/* Cleanup */
|
||||
close (ar_archive->src_fd);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
+121
-88
@@ -7,9 +7,9 @@
|
||||
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
|
||||
* based on gzip sources
|
||||
*
|
||||
* Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* to support files as well as stdin/stdout, and to generally behave itself wrt
|
||||
* command line handling.
|
||||
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support files as
|
||||
* well as stdin/stdout, and to generally behave itself wrt command line
|
||||
* handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@optushome.com.au>
|
||||
@@ -64,31 +64,29 @@ static char *license_msg[] = {
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
const char gunzip_to_stdout = 1;
|
||||
const char gunzip_force = 2;
|
||||
const char gunzip_test = 4;
|
||||
|
||||
extern int gunzip_main(int argc, char **argv)
|
||||
{
|
||||
FILE *in_file = stdin;
|
||||
FILE *out_file = NULL;
|
||||
struct stat stat_buf;
|
||||
|
||||
char *if_name = NULL;
|
||||
char *of_name = NULL;
|
||||
char *delete_file_name = NULL;
|
||||
|
||||
const int gunzip_to_stdout = 1;
|
||||
const int gunzip_force = 2;
|
||||
const int gunzip_test = 4;
|
||||
|
||||
int flags = 0;
|
||||
int opt = 0;
|
||||
int delete_old_file = FALSE;
|
||||
char status = EXIT_SUCCESS;
|
||||
char flags = 0;
|
||||
int opt;
|
||||
|
||||
/* if called as zcat */
|
||||
if (strcmp(applet_name, "zcat") == 0)
|
||||
if (strcmp(bb_applet_name, "zcat") == 0) {
|
||||
flags |= gunzip_to_stdout;
|
||||
}
|
||||
|
||||
while ((opt = getopt(argc, argv, "ctfhdq")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "ctfhd")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
flags |= gunzip_to_stdout;
|
||||
@@ -99,85 +97,120 @@ extern int gunzip_main(int argc, char **argv)
|
||||
case 't':
|
||||
flags |= gunzip_test;
|
||||
break;
|
||||
case 'd': /* Used to convert gzip to gunzip. */
|
||||
case 'd': /* Used to convert gzip to gunzip. */
|
||||
break;
|
||||
case 'q':
|
||||
error_msg("-q option not supported, ignored");
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
show_usage(); /* exit's inside usage */
|
||||
bb_show_usage(); /* exit's inside usage */
|
||||
}
|
||||
}
|
||||
|
||||
/* Set input filename and number */
|
||||
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
|
||||
flags |= gunzip_to_stdout;
|
||||
} else {
|
||||
if_name = xstrdup(argv[optind]);
|
||||
/* Open input file */
|
||||
in_file = xfopen(if_name, "r");
|
||||
do {
|
||||
struct stat stat_buf;
|
||||
const char *old_path = argv[optind];
|
||||
const char *delete_path = NULL;
|
||||
char *new_path = NULL;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
/* set the buffer size */
|
||||
setvbuf(in_file, NULL, _IOFBF, 0x8000);
|
||||
optind++;
|
||||
|
||||
/* Get the time stamp on the input file. */
|
||||
if (stat(if_name, &stat_buf) < 0) {
|
||||
error_msg_and_die("Couldn't stat file %s", if_name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(fileno(in_file)) && (flags & gunzip_force) == 0)
|
||||
error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
|
||||
|
||||
/* Set output filename and number */
|
||||
if (flags & gunzip_test) {
|
||||
out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
|
||||
} else if (flags & gunzip_to_stdout) {
|
||||
out_file = stdout;
|
||||
} else {
|
||||
char *extension;
|
||||
int length = strlen(if_name);
|
||||
|
||||
delete_old_file = TRUE;
|
||||
extension = strrchr(if_name, '.');
|
||||
if (extension && strcmp(extension, ".gz") == 0) {
|
||||
length -= 3;
|
||||
} else if (extension && strcmp(extension, ".tgz") == 0) {
|
||||
length -= 4;
|
||||
if (old_path == NULL || strcmp(old_path, "-") == 0) {
|
||||
src_fd = fileno(stdin);
|
||||
flags |= gunzip_to_stdout;
|
||||
} else {
|
||||
error_msg_and_die("Invalid extension");
|
||||
src_fd = bb_xopen(old_path, O_RDONLY);
|
||||
|
||||
/* Get the time stamp on the input file. */
|
||||
if (stat(old_path, &stat_buf) < 0) {
|
||||
bb_error_msg_and_die("Couldn't stat file %s", old_path);
|
||||
}
|
||||
}
|
||||
of_name = (char *) xcalloc(sizeof(char), length + 1);
|
||||
strncpy(of_name, if_name, length);
|
||||
|
||||
/* Open output file */
|
||||
out_file = xfopen(of_name, "w");
|
||||
|
||||
/* Set permissions on the file */
|
||||
chmod(of_name, stat_buf.st_mode);
|
||||
}
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if (unzip(in_file, out_file) == 0) {
|
||||
/* Success, remove .gz file */
|
||||
delete_file_name = if_name;
|
||||
} else {
|
||||
/* remove failed attempt */
|
||||
delete_file_name = of_name;
|
||||
}
|
||||
|
||||
fclose(out_file);
|
||||
fclose(in_file);
|
||||
|
||||
if (delete_old_file == TRUE) {
|
||||
if (unlink(delete_file_name) < 0) {
|
||||
error_msg_and_die("Couldnt remove %s", delete_file_name);
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && ((flags & gunzip_force) == 0)) {
|
||||
bb_error_msg_and_die
|
||||
("compressed data not read from terminal. Use -f to force it.");
|
||||
}
|
||||
}
|
||||
|
||||
free(of_name);
|
||||
/* Set output filename and number */
|
||||
if (flags & gunzip_test) {
|
||||
dst_fd = bb_xopen("/dev/null", O_WRONLY); /* why does test use filenum 2 ? */
|
||||
} else if (flags & gunzip_to_stdout) {
|
||||
dst_fd = fileno(stdout);
|
||||
} else {
|
||||
char *extension;
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
new_path = bb_xstrdup(old_path);
|
||||
|
||||
extension = strrchr(new_path, '.');
|
||||
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
if (extension && (strcmp(extension, ".Z") == 0)) {
|
||||
*extension = '\0';
|
||||
} else
|
||||
#endif
|
||||
if (extension && (strcmp(extension, ".gz") == 0)) {
|
||||
*extension = '\0';
|
||||
} else if (extension && (strcmp(extension, ".tgz") == 0)) {
|
||||
extension[2] = 'a';
|
||||
extension[3] = 'r';
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
|
||||
/* Open output file */
|
||||
dst_fd = bb_xopen(new_path, O_WRONLY | O_CREAT);
|
||||
|
||||
/* Set permissions on the file */
|
||||
chmod(new_path, stat_buf.st_mode);
|
||||
|
||||
/* If unzip succeeds remove the old file */
|
||||
delete_path = old_path;
|
||||
}
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if (bb_xread_char(src_fd) == 0x1f) {
|
||||
unsigned char magic2;
|
||||
|
||||
magic2 = bb_xread_char(src_fd);
|
||||
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
if (magic2 == 0x9d) {
|
||||
status = uncompress(src_fd, dst_fd);
|
||||
} else
|
||||
#endif
|
||||
if (magic2 == 0x8b) {
|
||||
check_header_gzip(src_fd);
|
||||
status = inflate(src_fd, dst_fd);
|
||||
if (status != 0) {
|
||||
bb_error_msg_and_die("Error inflating");
|
||||
}
|
||||
check_trailer_gzip(src_fd);
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
|
||||
if ((status != EXIT_SUCCESS) && (new_path)) {
|
||||
/* Unzip failed, remove new path instead of old path */
|
||||
delete_path = new_path;
|
||||
}
|
||||
|
||||
if (dst_fd != fileno(stdout)) {
|
||||
close(dst_fd);
|
||||
}
|
||||
if (src_fd != fileno(stdin)) {
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
/* delete_path will be NULL if in test mode or from stdin */
|
||||
if (delete_path && (unlink(delete_path) == -1)) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", delete_path);
|
||||
}
|
||||
|
||||
free(new_path);
|
||||
|
||||
} while (optind < argc);
|
||||
|
||||
return status;
|
||||
}
|
||||
+316
-333
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -17,41 +17,14 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR :=../..
|
||||
L_TARGET := libunarchive.a
|
||||
|
||||
obj-y := unarchive.o seek_sub_file.o
|
||||
obj-n :=
|
||||
obj- :=
|
||||
|
||||
ifeq ($(CONFIG_DPKG),y)
|
||||
obj-y += deb_extract.o get_header_ar.o get_header_tar.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DPKG_DEB),y)
|
||||
obj-y += deb_extract.o get_header_ar.o get_header_tar.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_AR),y)
|
||||
obj-y += get_header_ar.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CPIO),y)
|
||||
obj-y += get_header_cpio.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RPM2CPIO),y)
|
||||
obj-y += get_header_cpio.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TAR),y)
|
||||
obj-y += get_header_tar.o
|
||||
endif
|
||||
|
||||
|
||||
# Hand off to toplevel Rules.mak
|
||||
include $(TOPDIR)/Rules.mak
|
||||
TOPDIR:= ../../
|
||||
LIBUNARCHIVE_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
|
||||
clean:
|
||||
rm -f $(L_TARGET) *.o core
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
LIBUNARCHIVE_AR:=libunarchive.a
|
||||
ifndef $(LIBUNARCHIVE_DIR)
|
||||
LIBUNARCHIVE_DIR:=$(TOPDIR)archival/libunarchive/
|
||||
endif
|
||||
|
||||
LIBUNARCHIVE-y:= \
|
||||
\
|
||||
data_skip.o \
|
||||
data_extract_all.o \
|
||||
data_extract_to_stdout.o \
|
||||
data_extract_to_buffer.o \
|
||||
\
|
||||
filter_accept_all.o \
|
||||
filter_accept_list.o \
|
||||
filter_accept_list_reassign.o \
|
||||
filter_accept_reject_list.o \
|
||||
\
|
||||
get_header_ar.o \
|
||||
get_header_cpio.o \
|
||||
get_header_tar.o \
|
||||
get_header_tar_bz2.o \
|
||||
get_header_tar_gz.o \
|
||||
\
|
||||
header_skip.o \
|
||||
header_list.o \
|
||||
header_verbose_list.o \
|
||||
\
|
||||
archive_xread.o \
|
||||
archive_xread_all.o \
|
||||
archive_xread_all_eof.o \
|
||||
archive_xread_char.o \
|
||||
\
|
||||
seek_by_char.o \
|
||||
seek_by_jump.o \
|
||||
\
|
||||
archive_copy_file.o \
|
||||
\
|
||||
check_header_gzip.o \
|
||||
data_align.o \
|
||||
decompress_bunzip2.o \
|
||||
find_list_entry.o \
|
||||
init_handle.o \
|
||||
uncompress.o \
|
||||
unpack_ar_archive.o \
|
||||
unzip.o
|
||||
|
||||
LIBUNARCHIVE-$(CONFIG_DPKG) +=
|
||||
LIBUNARCHIVE-$(CONFIG_DPKG_DEB) +=
|
||||
LIBUNARCHIVE-$(CONFIG_AR) +=
|
||||
LIBUNARCHIVE-$(CONFIG_CPIO) +=
|
||||
LIBUNARCHIVE-$(CONFIG_GUNZIP) +=
|
||||
LIBUNARCHIVE-$(CONFIG_RPM2CPIO) +=
|
||||
LIBUNARCHIVE-$(CONFIG_TAR) +=
|
||||
LIBUNARCHIVE-$(CONFIG_UNZIP) +=
|
||||
|
||||
libraries-y+=$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR)
|
||||
|
||||
$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
|
||||
$(AR) -ro $@ $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd)
|
||||
{
|
||||
char buffer[512];
|
||||
off_t chunksize = archive_handle->file_header->size;
|
||||
|
||||
while (chunksize != 0) {
|
||||
size_t size;
|
||||
if (chunksize > 512) {
|
||||
size = 512;
|
||||
} else {
|
||||
size = chunksize;
|
||||
}
|
||||
// archive_xread_all(archive_handle, buffer, size);
|
||||
size = archive_xread(archive_handle, buffer, size);
|
||||
|
||||
if (write(dst_fd, buffer, size) != size) {
|
||||
bb_error_msg_and_die ("Short write");
|
||||
}
|
||||
chunksize -= size;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern ssize_t archive_xread(const archive_handle_t *archive_handle, unsigned char *buf, const size_t count)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
size = archive_handle->read(archive_handle->src_fd, buf, count);
|
||||
if (size < 0) {
|
||||
bb_perror_msg_and_die("Read error");
|
||||
}
|
||||
|
||||
return(size);
|
||||
}
|
||||
@@ -15,21 +15,18 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
off_t archive_offset;
|
||||
|
||||
void seek_sub_file(FILE *src_stream, const int count)
|
||||
extern void archive_xread_all(const archive_handle_t *archive_handle, void *buf, const size_t count)
|
||||
{
|
||||
/* Try to fseek as faster */
|
||||
archive_offset += count;
|
||||
if (fseek(src_stream, count, SEEK_CUR) != 0 && errno == ESPIPE) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
fgetc(src_stream);
|
||||
}
|
||||
ssize_t size;
|
||||
|
||||
size = archive_xread(archive_handle, buf, count);
|
||||
if (size != count) {
|
||||
bb_error_msg_and_die("Short read");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *buf, size_t count)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
size = archive_xread(archive_handle, buf, count);
|
||||
if ((size != 0) && (size != count)) {
|
||||
bb_perror_msg_and_die("Short read, read %d of %d", size, count);
|
||||
}
|
||||
return(size);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern unsigned char archive_xread_char(const archive_handle_t *archive_handle)
|
||||
{
|
||||
unsigned char tmp;
|
||||
|
||||
archive_xread(archive_handle, &tmp, 1);
|
||||
|
||||
return(tmp);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
|
||||
extern void check_header_gzip(int src_fd)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[8];
|
||||
struct {
|
||||
unsigned char method;
|
||||
unsigned char flags;
|
||||
unsigned int mtime;
|
||||
unsigned char xtra_flags;
|
||||
unsigned char os_flags;
|
||||
} formated;
|
||||
} header;
|
||||
|
||||
bb_xread_all(src_fd, header.raw, 8);
|
||||
|
||||
/* Check the compression method */
|
||||
if (header.formated.method != 8) {
|
||||
bb_error_msg_and_die("Unknown compression method %d",
|
||||
header.formated.method);
|
||||
}
|
||||
|
||||
if (header.formated.flags & 0x04) {
|
||||
/* bit 2 set: extra field present */
|
||||
unsigned char extra_short;
|
||||
|
||||
extra_short = bb_xread_char(src_fd) + (bb_xread_char(src_fd) << 8);
|
||||
while (extra_short > 0) {
|
||||
/* Ignore extra field */
|
||||
bb_xread_char(src_fd);
|
||||
extra_short--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Discard original name if any */
|
||||
if (header.formated.flags & 0x08) {
|
||||
/* bit 3 set: original file name present */
|
||||
while(bb_xread_char(src_fd) != 0);
|
||||
}
|
||||
|
||||
/* Discard file comment if any */
|
||||
if (header.formated.flags & 0x10) {
|
||||
/* bit 4 set: file comment present */
|
||||
while(bb_xread_char(src_fd) != 0);
|
||||
}
|
||||
|
||||
/* Read the header checksum */
|
||||
if (header.formated.flags & 0x02) {
|
||||
bb_xread_char(src_fd);
|
||||
bb_xread_char(src_fd);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
|
||||
{
|
||||
const unsigned short skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
|
||||
|
||||
archive_handle->seek(archive_handle, skip_amount);
|
||||
|
||||
archive_handle->offset += skip_amount;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void data_extract_all(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
int dst_fd;
|
||||
int res;
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
|
||||
char *name = bb_xstrdup(file_header->name);
|
||||
bb_make_directory (dirname(name), 0777, FILEUTILS_RECUR);
|
||||
free(name);
|
||||
}
|
||||
|
||||
/* Create the filesystem entry */
|
||||
switch(file_header->mode & S_IFMT) {
|
||||
case S_IFREG: {
|
||||
#ifdef CONFIG_CPIO
|
||||
if (file_header->link_name && file_header->size == 0) {
|
||||
/* hard link */
|
||||
res = link(file_header->link_name, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Couldnt create hard link");
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* Regular file */
|
||||
unlink(file_header->name);
|
||||
dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL);
|
||||
archive_copy_file(archive_handle, dst_fd);
|
||||
close(dst_fd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case S_IFDIR:
|
||||
unlink(file_header->name);
|
||||
res = mkdir(file_header->name, file_header->mode);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("extract_archive: %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
/* Symlink */
|
||||
unlink(file_header->name);
|
||||
res = symlink(file_header->link_name, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
|
||||
}
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
case S_IFIFO:
|
||||
unlink(file_header->name);
|
||||
res = mknod(file_header->name, file_header->mode, file_header->device);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Cannot create node %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bb_error_msg_and_die("Unrecognised file type");
|
||||
}
|
||||
|
||||
chmod(file_header->name, file_header->mode);
|
||||
chown(file_header->name, file_header->uid, file_header->gid);
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
|
||||
struct utimbuf t;
|
||||
t.actime = t.modtime = file_header->mtime;
|
||||
utime(file_header->name, &t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void data_extract_to_buffer(archive_handle_t *archive_handle)
|
||||
{
|
||||
const unsigned int size = archive_handle->file_header->size;
|
||||
|
||||
archive_handle->buffer = xmalloc(size + 1);
|
||||
|
||||
archive_xread_all(archive_handle, archive_handle->buffer, size);
|
||||
archive_handle->buffer[size] = '\0';
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void data_extract_to_stdout(archive_handle_t *archive_handle)
|
||||
{
|
||||
archive_copy_file(archive_handle, fileno(stdout));
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern void data_skip(archive_handle_t *archive_handle)
|
||||
{
|
||||
archive_handle->seek(archive_handle, archive_handle->file_header->size);
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
char *deb_extract(const char *package_filename, FILE *out_stream,
|
||||
const int extract_function, const char *prefix, const char *filename)
|
||||
{
|
||||
FILE *deb_stream;
|
||||
FILE *uncompressed_stream = NULL;
|
||||
file_header_t *ar_header = NULL;
|
||||
char **file_list = NULL;
|
||||
char *output_buffer = NULL;
|
||||
char *ared_file = NULL;
|
||||
char ar_magic[8];
|
||||
int gunzip_pid;
|
||||
|
||||
if (filename != NULL) {
|
||||
file_list = xmalloc(sizeof(char *) * 2);
|
||||
file_list[0] = xstrdup(filename);
|
||||
file_list[1] = NULL;
|
||||
}
|
||||
|
||||
if (extract_function & extract_control_tar_gz) {
|
||||
ared_file = xstrdup("control.tar.gz");
|
||||
}
|
||||
else if (extract_function & extract_data_tar_gz) {
|
||||
ared_file = xstrdup("data.tar.gz");
|
||||
}
|
||||
|
||||
/* open the debian package to be worked on */
|
||||
deb_stream = wfopen(package_filename, "r");
|
||||
if (deb_stream == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
/* set the buffer size */
|
||||
setvbuf(deb_stream, NULL, _IOFBF, 0x8000);
|
||||
|
||||
/* check ar magic */
|
||||
fread(ar_magic, 1, 8, deb_stream);
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
archive_offset = 8;
|
||||
|
||||
while ((ar_header = get_header_ar(deb_stream)) != NULL) {
|
||||
if (strcmp(ared_file, ar_header->name) == 0) {
|
||||
/* open a stream of decompressed data */
|
||||
uncompressed_stream = gz_open(deb_stream, &gunzip_pid);
|
||||
archive_offset = 0;
|
||||
output_buffer = unarchive(uncompressed_stream, out_stream, get_header_tar, extract_function, prefix, file_list, NULL);
|
||||
}
|
||||
seek_sub_file(deb_stream, ar_header->size);
|
||||
free(ar_header->name);
|
||||
free(ar_header);
|
||||
}
|
||||
gz_close(gunzip_pid);
|
||||
fclose(deb_stream);
|
||||
fclose(uncompressed_stream);
|
||||
free(ared_file);
|
||||
if (filename != NULL) {
|
||||
free(file_list[0]);
|
||||
free(file_list);
|
||||
}
|
||||
return(output_buffer);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,298 @@
|
||||
#include "config.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#if defined CONFIG_UNCOMPRESS || defined CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
|
||||
/* uncompress for busybox -- (c) 2002 Robert Griebl
|
||||
*
|
||||
* based on the original compress42.c source
|
||||
* (see disclaimer below)
|
||||
*/
|
||||
|
||||
|
||||
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
|
||||
*
|
||||
* Authors:
|
||||
* Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
|
||||
* Jim McKie (decvax!mcvax!jim)
|
||||
* Steve Davies (decvax!vax135!petsd!peora!srd)
|
||||
* Ken Turkowski (decvax!decwrl!turtlevax!ken)
|
||||
* James A. Woods (decvax!ihnp4!ames!jaw)
|
||||
* Joe Orost (decvax!vax135!petsd!joe)
|
||||
* Dave Mack (csu@alembic.acs.com)
|
||||
* Peter Jannesen, Network Communication Systems
|
||||
* (peter@ncs.nl)
|
||||
*
|
||||
* marc@suse.de : a small security fix for a buffer overflow
|
||||
*
|
||||
* [... History snipped ...]
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Defailt input buffer size */
|
||||
#define IBUFSIZ 2048
|
||||
|
||||
/* Default output buffer size */
|
||||
#define OBUFSIZ 2048
|
||||
|
||||
/* Defines for third byte of header */
|
||||
#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */
|
||||
#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */
|
||||
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
|
||||
/* Masks 0x20 and 0x40 are free. */
|
||||
/* I think 0x20 should mean that there is */
|
||||
/* a fourth header byte (for expansion). */
|
||||
#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */
|
||||
/* compression rate is dropping flush tables */
|
||||
/* the next two codes should not be changed lightly, as they must not */
|
||||
/* lie within the contiguous general code space. */
|
||||
#define FIRST 257 /* first free entry */
|
||||
#define CLEAR 256 /* table clear output code */
|
||||
|
||||
#define INIT_BITS 9 /* initial number of bits/code */
|
||||
|
||||
|
||||
/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */
|
||||
#define FAST
|
||||
|
||||
#define HBITS 17 /* 50% occupancy */
|
||||
#define HSIZE (1<<HBITS)
|
||||
#define HMASK (HSIZE-1)
|
||||
#define HPRIME 9941
|
||||
#define BITS 16
|
||||
#undef MAXSEG_64K
|
||||
#define MAXCODE(n) (1L << (n))
|
||||
|
||||
/* Block compress mode -C compatible with 2.0 */
|
||||
int block_mode = BLOCK_MODE;
|
||||
|
||||
/* user settable max # bits/code */
|
||||
int maxbits = BITS;
|
||||
|
||||
/* Exitcode of compress (-1 no file compressed) */
|
||||
int exit_code = -1;
|
||||
|
||||
/* Input buffer */
|
||||
unsigned char inbuf[IBUFSIZ + 64];
|
||||
|
||||
/* Output buffer */
|
||||
unsigned char outbuf[OBUFSIZ + 2048];
|
||||
|
||||
|
||||
long int htab[HSIZE];
|
||||
unsigned short codetab[HSIZE];
|
||||
|
||||
#define htabof(i) htab[i]
|
||||
#define codetabof(i) codetab[i]
|
||||
#define tab_prefixof(i) codetabof(i)
|
||||
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
|
||||
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
|
||||
#define clear_htab() memset(htab, -1, sizeof(htab))
|
||||
#define clear_tab_prefixof() memset(codetab, 0, 256);
|
||||
|
||||
|
||||
/*
|
||||
* Decompress stdin to stdout. This routine adapts to the codes in the
|
||||
* file building the "string" table on-the-fly; requiring no table to
|
||||
* be stored in the compressed file. The tables used herein are shared
|
||||
* with those of the compress() routine. See the definitions above.
|
||||
*/
|
||||
|
||||
extern int uncompress(int fd_in, int fd_out)
|
||||
{
|
||||
unsigned char *stackp;
|
||||
long int code;
|
||||
int finchar;
|
||||
long int oldcode;
|
||||
long int incode;
|
||||
int inbits;
|
||||
int posbits;
|
||||
int outpos;
|
||||
int insize;
|
||||
int bitmask;
|
||||
long int free_ent;
|
||||
long int maxcode;
|
||||
long int maxmaxcode;
|
||||
int n_bits;
|
||||
int rsize = 0;
|
||||
|
||||
insize = 0;
|
||||
|
||||
inbuf[0] = bb_xread_char(fd_in);
|
||||
|
||||
maxbits = inbuf[0] & BIT_MASK;
|
||||
block_mode = inbuf[0] & BLOCK_MODE;
|
||||
maxmaxcode = MAXCODE(maxbits);
|
||||
|
||||
if (maxbits > BITS) {
|
||||
bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
|
||||
BITS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
oldcode = -1;
|
||||
finchar = 0;
|
||||
outpos = 0;
|
||||
posbits = 0 << 3;
|
||||
|
||||
free_ent = ((block_mode) ? FIRST : 256);
|
||||
|
||||
/* As above, initialize the first 256 entries in the table. */
|
||||
clear_tab_prefixof();
|
||||
|
||||
for (code = 255; code >= 0; --code) {
|
||||
tab_suffixof(code) = (unsigned char) code;
|
||||
}
|
||||
|
||||
do {
|
||||
resetbuf:;
|
||||
{
|
||||
int i;
|
||||
int e;
|
||||
int o;
|
||||
|
||||
e = insize - (o = (posbits >> 3));
|
||||
|
||||
for (i = 0; i < e; ++i)
|
||||
inbuf[i] = inbuf[i + o];
|
||||
|
||||
insize = e;
|
||||
posbits = 0;
|
||||
}
|
||||
|
||||
if (insize < (int) sizeof(inbuf) - IBUFSIZ) {
|
||||
rsize = read(fd_in, inbuf + insize, IBUFSIZ);
|
||||
insize += rsize;
|
||||
}
|
||||
|
||||
inbits = ((rsize > 0) ? (insize - insize % n_bits) << 3 :
|
||||
(insize << 3) - (n_bits - 1));
|
||||
|
||||
while (inbits > posbits) {
|
||||
if (free_ent > maxcode) {
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
++n_bits;
|
||||
if (n_bits == maxbits) {
|
||||
maxcode = maxmaxcode;
|
||||
} else {
|
||||
maxcode = MAXCODE(n_bits) - 1;
|
||||
}
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
{
|
||||
unsigned char *p = &inbuf[posbits >> 3];
|
||||
|
||||
code =
|
||||
((((long) (p[0])) | ((long) (p[1]) << 8) |
|
||||
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
|
||||
}
|
||||
posbits += n_bits;
|
||||
|
||||
|
||||
if (oldcode == -1) {
|
||||
outbuf[outpos++] = (unsigned char) (finchar =
|
||||
(int) (oldcode = code));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code == CLEAR && block_mode) {
|
||||
clear_tab_prefixof();
|
||||
free_ent = FIRST - 1;
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
|
||||
incode = code;
|
||||
stackp = de_stack;
|
||||
|
||||
/* Special case for KwKwK string. */
|
||||
if (code >= free_ent) {
|
||||
if (code > free_ent) {
|
||||
unsigned char *p;
|
||||
|
||||
posbits -= n_bits;
|
||||
p = &inbuf[posbits >> 3];
|
||||
|
||||
bb_error_msg
|
||||
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
|
||||
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
||||
(posbits & 07));
|
||||
bb_error_msg("uncompress: corrupt input");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) finchar;
|
||||
code = oldcode;
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while ((long int) code >= (long int) 256) {
|
||||
*--stackp = tab_suffixof(code);
|
||||
code = tab_prefixof(code);
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) (finchar = tab_suffixof(code));
|
||||
|
||||
/* And put them out in forward order */
|
||||
{
|
||||
int i;
|
||||
|
||||
if (outpos + (i = (de_stack - stackp)) >= OBUFSIZ) {
|
||||
do {
|
||||
if (i > OBUFSIZ - outpos) {
|
||||
i = OBUFSIZ - outpos;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
}
|
||||
|
||||
if (outpos >= OBUFSIZ) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
outpos = 0;
|
||||
}
|
||||
stackp += i;
|
||||
} while ((i = (de_stack - stackp)) > 0);
|
||||
} else {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate the new entry. */
|
||||
if ((code = free_ent) < maxmaxcode) {
|
||||
tab_prefixof(code) = (unsigned short) oldcode;
|
||||
tab_suffixof(code) = (unsigned char) finchar;
|
||||
free_ent = code + 1;
|
||||
}
|
||||
|
||||
/* Remember previous code. */
|
||||
oldcode = incode;
|
||||
}
|
||||
|
||||
} while (rsize > 0);
|
||||
|
||||
if (outpos > 0) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2002 by Glenn McGrath
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Accept any non-null name, its not really a filter at all */
|
||||
extern char filter_accept_all(archive_handle_t *archive_handle)
|
||||
{
|
||||
if (archive_handle->file_header->name) {
|
||||
return(EXIT_SUCCESS);
|
||||
} else {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2002 by Glenn McGrath
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
* Accept names that are in the accept list, ignoring reject list.
|
||||
*/
|
||||
extern char filter_accept_list(archive_handle_t *archive_handle)
|
||||
{
|
||||
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
|
||||
return(EXIT_SUCCESS);
|
||||
} else {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2002 by Glenn McGrath
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
* Reassign the subarchive metadata parser based on the filename extension
|
||||
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
|
||||
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
|
||||
*/
|
||||
extern char filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
{
|
||||
/* Check the file entry is in the accept list */
|
||||
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
|
||||
const char *name_ptr;
|
||||
|
||||
/* Extract the last 2 extensions */
|
||||
name_ptr = strrchr(archive_handle->file_header->name, '.');
|
||||
|
||||
/* Modify the subarchive handler based on the extension */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
if (strcmp(name_ptr, ".gz") == 0) {
|
||||
archive_handle->sub_archive->read = read;
|
||||
archive_handle->action_data_subarchive = get_header_tar_gz;
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
if (strcmp(name_ptr, ".bz2") == 0) {
|
||||
archive_handle->sub_archive->read = read_bz2;
|
||||
BZ2_bzReadOpen(archive_handle->src_fd, NULL, 0);
|
||||
archive_handle->action_data_subarchive = get_header_tar;
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2002 by Glenn McGrath
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
* Accept names that are in the accept list and not in the reject list
|
||||
*/
|
||||
extern char filter_accept_reject_list(archive_handle_t *archive_handle)
|
||||
{
|
||||
const char *key = archive_handle->file_header->name;
|
||||
const llist_t *accept_entry = find_list_entry(archive_handle->accept, key);
|
||||
const llist_t *reject_entry = find_list_entry(archive_handle->reject, key);
|
||||
|
||||
/* If the key is in a reject list fail */
|
||||
if (reject_entry) {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Fail if an accept list was specified and the key wasnt in there */
|
||||
if (archive_handle->accept && (accept_entry == NULL)) {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Accepted */
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
extern const llist_t *find_list_entry(const llist_t *list, const char *filename)
|
||||
{
|
||||
while (list) {
|
||||
if (fnmatch(list->data, filename, 0) == 0) {
|
||||
return(list);
|
||||
}
|
||||
list = list->link;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
@@ -17,12 +17,13 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
file_header_t *get_header_ar(FILE *src_stream)
|
||||
extern char get_header_ar(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *typed;
|
||||
file_header_t *typed = archive_handle->file_header;
|
||||
union {
|
||||
char raw[60];
|
||||
struct {
|
||||
@@ -35,72 +36,87 @@ file_header_t *get_header_ar(FILE *src_stream)
|
||||
char magic[2];
|
||||
} formated;
|
||||
} ar;
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
static char *ar_long_names;
|
||||
static unsigned int ar_long_name_size;
|
||||
#endif
|
||||
|
||||
if (fread(ar.raw, 1, 60, src_stream) != 60) {
|
||||
return(NULL);
|
||||
/* dont use bb_xread as we want to handle the error ourself */
|
||||
if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
|
||||
/* End Of File */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Some ar entries have a trailing '\n' after the previous data entry */
|
||||
if (ar.raw[0] == '\n') {
|
||||
/* fix up the header, we started reading 1 byte too early */
|
||||
memmove(ar.raw, &ar.raw[1], 59);
|
||||
ar.raw[59] = bb_xread_char(archive_handle->src_fd);
|
||||
archive_handle->offset++;
|
||||
}
|
||||
archive_offset += 60;
|
||||
archive_handle->offset += 60;
|
||||
|
||||
/* align the headers based on the header magic */
|
||||
if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) {
|
||||
/* some version of ar, have an extra '\n' after each data entry,
|
||||
* this puts the next header out by 1 */
|
||||
if (ar.formated.magic[1] != '`') {
|
||||
error_msg("Invalid magic");
|
||||
return(NULL);
|
||||
}
|
||||
/* read the next char out of what would be the data section,
|
||||
* if its a '\n' then it is a valid header offset by 1*/
|
||||
archive_offset++;
|
||||
if (fgetc(src_stream) != '\n') {
|
||||
error_msg("Invalid magic");
|
||||
return(NULL);
|
||||
}
|
||||
/* fix up the header, we started reading 1 byte too early */
|
||||
/* raw_header[60] wont be '\n' as it should, but it doesnt matter */
|
||||
memmove(ar.raw, &ar.raw[1], 59);
|
||||
bb_error_msg_and_die("Invalid ar header");
|
||||
}
|
||||
|
||||
typed = (file_header_t *) xcalloc(1, sizeof(file_header_t));
|
||||
|
||||
typed->size = (size_t) atoi(ar.formated.size);
|
||||
typed->mode = strtol(ar.formated.mode, NULL, 8);
|
||||
typed->mtime = atoi(ar.formated.date);
|
||||
typed->uid = atoi(ar.formated.uid);
|
||||
typed->gid = atoi(ar.formated.gid);
|
||||
typed->size = atoi(ar.formated.size);
|
||||
|
||||
/* long filenames have '/' as the first character */
|
||||
if (ar.formated.name[0] == '/') {
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
if (ar.formated.name[1] == '/') {
|
||||
/* If the second char is a '/' then this entries data section
|
||||
* stores long filename for multiple entries, they are stored
|
||||
* in static variable long_names for use in future entries */
|
||||
ar_long_names = (char *) xrealloc(ar_long_names, typed->size);
|
||||
fread(ar_long_names, 1, typed->size, src_stream);
|
||||
archive_offset += typed->size;
|
||||
ar_long_name_size = typed->size;
|
||||
ar_long_names = xmalloc(ar_long_name_size);
|
||||
bb_xread_all(archive_handle->src_fd, ar_long_names, ar_long_name_size);
|
||||
archive_handle->offset += ar_long_name_size;
|
||||
/* This ar entries data section only contained filenames for other records
|
||||
* they are stored in the static ar_long_names for future reference */
|
||||
return (get_header_ar(src_stream)); /* Return next header */
|
||||
return (get_header_ar(archive_handle)); /* Return next header */
|
||||
} else if (ar.formated.name[1] == ' ') {
|
||||
/* This is the index of symbols in the file for compilers */
|
||||
seek_sub_file(src_stream, typed->size);
|
||||
return (get_header_ar(src_stream)); /* Return next header */
|
||||
data_skip(archive_handle);
|
||||
return (get_header_ar(archive_handle)); /* Return next header */
|
||||
} else {
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
if (!ar_long_names) {
|
||||
error_msg("Cannot resolve long file name");
|
||||
return (NULL);
|
||||
const unsigned int long_offset = atoi(&ar.formated.name[1]);
|
||||
if (long_offset >= ar_long_name_size) {
|
||||
bb_error_msg_and_die("Cant resolve long filename");
|
||||
}
|
||||
typed->name = xstrdup(ar_long_names + atoi(&ar.formated.name[1]));
|
||||
typed->name = bb_xstrdup(ar_long_names + long_offset);
|
||||
}
|
||||
#else
|
||||
bb_error_msg_and_die("long filenames not supported");
|
||||
#endif
|
||||
} else {
|
||||
/* short filenames */
|
||||
typed->name = xcalloc(1, 16);
|
||||
strncpy(typed->name, ar.formated.name, 16);
|
||||
typed->name = bb_xstrndup(ar.formated.name, 16);
|
||||
}
|
||||
typed->name[strcspn(typed->name, " /")]='\0';
|
||||
|
||||
/* convert the rest of the now valid char header to its typed struct */
|
||||
parse_mode(ar.formated.mode, &typed->mode);
|
||||
typed->mtime = atoi(ar.formated.date);
|
||||
typed->uid = atoi(ar.formated.uid);
|
||||
typed->gid = atoi(ar.formated.gid);
|
||||
typed->name[strcspn(typed->name, " /")] = '\0';
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_header(typed);
|
||||
if (archive_handle->sub_archive) {
|
||||
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS);
|
||||
} else {
|
||||
archive_handle->action_data(archive_handle);
|
||||
}
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
|
||||
archive_handle->offset += typed->size + 1;
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
return(typed);
|
||||
}
|
||||
@@ -17,120 +17,173 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
struct hardlinks {
|
||||
typedef struct hardlinks_s {
|
||||
file_header_t *entry;
|
||||
int inode;
|
||||
struct hardlinks *next;
|
||||
};
|
||||
struct hardlinks_s *next;
|
||||
} hardlinks_t;
|
||||
|
||||
file_header_t *get_header_cpio(FILE *src_stream)
|
||||
extern char get_header_cpio(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *cpio_entry = NULL;
|
||||
static hardlinks_t *saved_hardlinks = NULL;
|
||||
static unsigned short pending_hardlinks = 0;
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
char cpio_header[110];
|
||||
int namesize;
|
||||
char dummy[16];
|
||||
int major, minor, nlink, inode;
|
||||
static struct hardlinks *saved_hardlinks = NULL;
|
||||
static int pending_hardlinks = 0;
|
||||
|
||||
char dummy[16];
|
||||
int major, minor, nlink, inode;
|
||||
char extract_flag;
|
||||
|
||||
if (pending_hardlinks) { /* Deal with any pending hardlinks */
|
||||
struct hardlinks *tmp = saved_hardlinks, *oldtmp = NULL;
|
||||
hardlinks_t *tmp;
|
||||
hardlinks_t *oldtmp;
|
||||
|
||||
tmp = saved_hardlinks;
|
||||
oldtmp = NULL;
|
||||
|
||||
while (tmp) {
|
||||
bb_error_msg_and_die("need to fix this\n");
|
||||
if (tmp->entry->link_name) { /* Found a hardlink ready to be extracted */
|
||||
cpio_entry = tmp->entry;
|
||||
if (oldtmp) oldtmp->next = tmp->next; /* Remove item from linked list */
|
||||
else saved_hardlinks = tmp->next;
|
||||
file_header = tmp->entry;
|
||||
if (oldtmp) {
|
||||
oldtmp->next = tmp->next; /* Remove item from linked list */
|
||||
} else {
|
||||
saved_hardlinks = tmp->next;
|
||||
}
|
||||
free(tmp);
|
||||
return (cpio_entry);
|
||||
continue;
|
||||
}
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
pending_hardlinks = 0; /* No more pending hardlinks, read next file entry */
|
||||
}
|
||||
|
||||
|
||||
/* There can be padding before archive header */
|
||||
seek_sub_file(src_stream, (4 - (archive_offset % 4)) % 4);
|
||||
if (fread(cpio_header, 1, 110, src_stream) == 110) {
|
||||
archive_offset += 110;
|
||||
if (strncmp(cpio_header, "07070", 5) != 0) {
|
||||
error_msg("Unsupported format or invalid magic");
|
||||
return(NULL);
|
||||
}
|
||||
switch (cpio_header[5]) {
|
||||
case '2': /* "crc" header format */
|
||||
/* Doesnt do the crc check yet */
|
||||
case '1': /* "newc" header format */
|
||||
cpio_entry = (file_header_t *) xcalloc(1, sizeof(file_header_t));
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
dummy, &inode, (unsigned int*)&cpio_entry->mode,
|
||||
(unsigned int*)&cpio_entry->uid, (unsigned int*)&cpio_entry->gid,
|
||||
&nlink, &cpio_entry->mtime, &cpio_entry->size,
|
||||
dummy, &major, &minor, &namesize, dummy);
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
cpio_entry->name = (char *) xcalloc(1, namesize);
|
||||
fread(cpio_entry->name, 1, namesize, src_stream); /* Read in filename */
|
||||
archive_offset += namesize;
|
||||
/* Skip padding before file contents */
|
||||
seek_sub_file(src_stream, (4 - (archive_offset % 4)) % 4);
|
||||
if (strcmp(cpio_entry->name, "TRAILER!!!") == 0) {
|
||||
printf("%d blocks\n", (int) (archive_offset % 512 ? (archive_offset / 512) + 1 : archive_offset / 512)); /* Always round up */
|
||||
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
|
||||
struct hardlinks *tmp = saved_hardlinks, *oldtmp = NULL;
|
||||
while (tmp) {
|
||||
error_msg("%s not created: cannot resolve hardlink", tmp->entry->name);
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free (oldtmp->entry->name);
|
||||
free (oldtmp->entry);
|
||||
free (oldtmp);
|
||||
}
|
||||
saved_hardlinks = NULL;
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
if (archive_xread_all_eof(archive_handle, cpio_header, 110) == 0) {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
archive_handle->offset += 110;
|
||||
|
||||
if (S_ISLNK(cpio_entry->mode)) {
|
||||
cpio_entry->link_name = (char *) xcalloc(1, cpio_entry->size + 1);
|
||||
fread(cpio_entry->link_name, 1, cpio_entry->size, src_stream);
|
||||
archive_offset += cpio_entry->size;
|
||||
cpio_entry->size = 0; /* Stop possiable seeks in future */
|
||||
}
|
||||
if (nlink > 1 && !S_ISDIR(cpio_entry->mode)) {
|
||||
if (cpio_entry->size == 0) { /* Put file on a linked list for later */
|
||||
struct hardlinks *new = xmalloc(sizeof(struct hardlinks));
|
||||
new->next = saved_hardlinks;
|
||||
new->inode = inode;
|
||||
new->entry = cpio_entry;
|
||||
saved_hardlinks = new;
|
||||
return(get_header_cpio(src_stream)); /* Recurse to next file */
|
||||
} else { /* Found the file with data in */
|
||||
struct hardlinks *tmp = saved_hardlinks;
|
||||
pending_hardlinks = 1;
|
||||
while (tmp) {
|
||||
if (tmp->inode == inode) {
|
||||
tmp->entry->link_name = xstrdup(cpio_entry->name);
|
||||
nlink--;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (nlink > 1) error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?");
|
||||
}
|
||||
}
|
||||
cpio_entry->device = (major << 8) | minor;
|
||||
break;
|
||||
default:
|
||||
error_msg("Unsupported format");
|
||||
return(NULL);
|
||||
if (strncmp(&cpio_header[0], "07070", 5) != 0) {
|
||||
printf("cpio header is %x-%x-%x-%x-%x\n",
|
||||
cpio_header[0],
|
||||
cpio_header[1],
|
||||
cpio_header[2],
|
||||
cpio_header[3],
|
||||
cpio_header[4]);
|
||||
bb_error_msg_and_die("Unsupported cpio format");
|
||||
}
|
||||
|
||||
if ((cpio_header[5] != '1') && (cpio_header[5] != '2')) {
|
||||
bb_error_msg_and_die("Unsupported cpio format, use newc or crc");
|
||||
}
|
||||
|
||||
{
|
||||
unsigned long tmpsize;
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
dummy, &inode, (unsigned int*)&file_header->mode,
|
||||
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
|
||||
&nlink, &file_header->mtime, &tmpsize,
|
||||
dummy, &major, &minor, &namesize, dummy);
|
||||
file_header->size = tmpsize;
|
||||
}
|
||||
|
||||
file_header->name = (char *) xmalloc(namesize + 1);
|
||||
archive_xread_all(archive_handle, file_header->name, namesize); /* Read in filename */
|
||||
file_header->name[namesize] = '\0';
|
||||
archive_handle->offset += namesize;
|
||||
|
||||
/* Update offset amount and skip padding before file contents */
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
|
||||
printf("%d blocks\n", (int) (archive_handle->offset % 512 ? (archive_handle->offset / 512) + 1 : archive_handle->offset / 512)); /* Always round up */
|
||||
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
|
||||
hardlinks_t *tmp = saved_hardlinks;
|
||||
hardlinks_t *oldtmp = NULL;
|
||||
while (tmp) {
|
||||
bb_error_msg("%s not created: cannot resolve hardlink", tmp->entry->name);
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free (oldtmp->entry->name);
|
||||
free (oldtmp->entry);
|
||||
free (oldtmp);
|
||||
}
|
||||
saved_hardlinks = NULL;
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
if (ferror(src_stream) || feof(src_stream)) {
|
||||
perror_msg("Stream error");
|
||||
return(NULL);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (S_ISLNK(file_header->mode)) {
|
||||
file_header->link_name = (char *) xmalloc(file_header->size + 1);
|
||||
archive_xread_all(archive_handle, file_header->link_name, file_header->size);
|
||||
file_header->link_name[file_header->size] = '\0';
|
||||
archive_handle->offset += file_header->size;
|
||||
file_header->size = 0; /* Stop possible seeks in future */
|
||||
}
|
||||
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
|
||||
if (file_header->size == 0) { /* Put file on a linked list for later */
|
||||
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
|
||||
new->next = saved_hardlinks;
|
||||
new->inode = inode;
|
||||
new->entry = file_header;
|
||||
saved_hardlinks = new;
|
||||
return(EXIT_SUCCESS); // Skip this one
|
||||
} else { /* Found the file with data in */
|
||||
hardlinks_t *tmp = saved_hardlinks;
|
||||
pending_hardlinks = 1;
|
||||
while (tmp) {
|
||||
if (tmp->inode == inode) {
|
||||
tmp->entry->link_name = bb_xstrdup(file_header->name);
|
||||
nlink--;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (nlink > 1) {
|
||||
bb_error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?");
|
||||
}
|
||||
}
|
||||
}
|
||||
return(cpio_entry);
|
||||
}
|
||||
file_header->device = (major << 8) | minor;
|
||||
|
||||
extract_flag = FALSE;
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
struct stat statbuf;
|
||||
|
||||
extract_flag = TRUE;
|
||||
|
||||
/* Check if the file already exists */
|
||||
if (lstat (file_header->name, &statbuf) == 0) {
|
||||
if ((archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) || (statbuf.st_mtime < file_header->mtime)) {
|
||||
/* Remove file if flag set or its older than the file to be extracted */
|
||||
if (unlink(file_header->name) == -1) {
|
||||
bb_perror_msg_and_die("Couldnt remove old file");
|
||||
}
|
||||
} else {
|
||||
if (! archive_handle->flags & ARCHIVE_EXTRACT_QUIET) {
|
||||
bb_error_msg("%s not created: newer or same age file exists", file_header->name);
|
||||
}
|
||||
extract_flag = FALSE;
|
||||
}
|
||||
}
|
||||
archive_handle->action_header(file_header);
|
||||
}
|
||||
|
||||
archive_handle->action_header(file_header);
|
||||
if (extract_flag) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
archive_handle->offset += file_header->size;
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -20,54 +20,63 @@
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
file_header_t *get_header_tar(FILE *tar_stream)
|
||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
static char *longname = NULL;
|
||||
static char *linkname = NULL;
|
||||
#endif
|
||||
|
||||
extern char get_header_tar(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
union {
|
||||
unsigned char raw[512];
|
||||
struct {
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 */
|
||||
} formated;
|
||||
} tar;
|
||||
file_header_t *tar_entry = NULL;
|
||||
long sum = 0;
|
||||
long i;
|
||||
char *tmp;
|
||||
|
||||
if (archive_offset % 512 != 0) {
|
||||
seek_sub_file(tar_stream, 512 - (archive_offset % 512));
|
||||
/* Align header */
|
||||
data_align(archive_handle, 512);
|
||||
|
||||
if (archive_xread(archive_handle, tar.raw, 512) != 512) {
|
||||
/* Assume end of file */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
archive_handle->offset += 512;
|
||||
|
||||
/* If there is no filename its an empty header */
|
||||
if (tar.formated.name[0] == 0) {
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (fread(tar.raw, 1, 512, tar_stream) != 512) {
|
||||
/* Unfortunatly its common for tar files to have all sorts of
|
||||
* trailing garbage, fail silently */
|
||||
// error_msg("Couldnt read header");
|
||||
return(NULL);
|
||||
}
|
||||
archive_offset += 512;
|
||||
|
||||
/* Check header has valid magic, unfortunately some tar files
|
||||
* have empty (0'ed) tar entries at the end, which will
|
||||
* cause this to fail, so fail silently for now
|
||||
/* Check header has valid magic, "ustar" is for the proper tar
|
||||
* 0's are for the old tar format
|
||||
*/
|
||||
if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
|
||||
return(NULL);
|
||||
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
|
||||
if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
|
||||
#endif
|
||||
bb_error_msg_and_die("Invalid tar magic");
|
||||
}
|
||||
|
||||
/* Do checksum on headers */
|
||||
for (i = 0; i < 148 ; i++) {
|
||||
sum += tar.raw[i];
|
||||
@@ -77,23 +86,103 @@ file_header_t *get_header_tar(FILE *tar_stream)
|
||||
sum += tar.raw[i];
|
||||
}
|
||||
if (sum != strtol(tar.formated.chksum, NULL, 8)) {
|
||||
error_msg("Invalid tar header checksum");
|
||||
return(NULL);
|
||||
bb_error_msg("Invalid tar header checksum");
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* convert to type'ed variables */
|
||||
tar_entry = xcalloc(1, sizeof(file_header_t));
|
||||
tar_entry->name = xstrdup(tar.formated.name);
|
||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (longname) {
|
||||
file_header->name = longname;
|
||||
longname = NULL;
|
||||
}
|
||||
else if (linkname) {
|
||||
file_header->name = linkname;
|
||||
linkname = NULL;
|
||||
} else
|
||||
#endif
|
||||
if (tar.formated.prefix[0] == 0) {
|
||||
file_header->name = strdup(tar.formated.name);
|
||||
} else {
|
||||
file_header->name = concat_path_file(tar.formated.prefix, tar.formated.name);
|
||||
}
|
||||
tmp = last_char_is(archive_handle->file_header->name, '/');
|
||||
if (tmp) {
|
||||
*tmp = '\0';
|
||||
}
|
||||
|
||||
parse_mode(tar.formated.mode, &tar_entry->mode);
|
||||
tar_entry->uid = strtol(tar.formated.uid, NULL, 8);
|
||||
tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
|
||||
tar_entry->size = strtol(tar.formated.size, NULL, 8);
|
||||
tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8);
|
||||
tar_entry->link_name = strlen(tar.formated.linkname) ?
|
||||
xstrdup(tar.formated.linkname) : NULL;
|
||||
tar_entry->device = (strtol(tar.formated.devmajor, NULL, 8) << 8) +
|
||||
strtol(tar.formated.devminor, NULL, 8);
|
||||
file_header->mode = strtol(tar.formated.mode, NULL, 8);
|
||||
file_header->uid = strtol(tar.formated.uid, NULL, 8);
|
||||
file_header->gid = strtol(tar.formated.gid, NULL, 8);
|
||||
file_header->size = strtol(tar.formated.size, NULL, 8);
|
||||
file_header->mtime = strtol(tar.formated.mtime, NULL, 8);
|
||||
file_header->link_name = (tar.formated.linkname[0] != '\0') ?
|
||||
bb_xstrdup(tar.formated.linkname) : NULL;
|
||||
file_header->device = (dev_t) ((strtol(tar.formated.devmajor, NULL, 8) << 8) +
|
||||
strtol(tar.formated.devminor, NULL, 8));
|
||||
|
||||
#if defined CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY || defined CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
/* Fix mode, used by the old format */
|
||||
switch (tar.formated.typeflag) {
|
||||
# ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
|
||||
case 0:
|
||||
case '0':
|
||||
file_header->mode |= S_IFREG;
|
||||
break;
|
||||
case '1':
|
||||
bb_error_msg("WARNING: Converting hard link to symlink");
|
||||
case '2':
|
||||
file_header->mode |= S_IFLNK;
|
||||
break;
|
||||
case '3':
|
||||
file_header->mode |= S_IFCHR;
|
||||
break;
|
||||
case '4':
|
||||
file_header->mode |= S_IFBLK;
|
||||
break;
|
||||
case '5':
|
||||
file_header->mode |= S_IFDIR;
|
||||
break;
|
||||
case '6':
|
||||
file_header->mode |= S_IFIFO;
|
||||
break;
|
||||
# endif
|
||||
# ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
case 'L': {
|
||||
longname = xmalloc(file_header->size + 1);
|
||||
archive_xread_all(archive_handle, longname, file_header->size);
|
||||
longname[file_header->size] = '\0';
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
return(get_header_tar(archive_handle));
|
||||
}
|
||||
case 'K': {
|
||||
linkname = xmalloc(file_header->size + 1);
|
||||
archive_xread_all(archive_handle, linkname, file_header->size);
|
||||
linkname[file_header->size] = '\0';
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
file_header->name = linkname;
|
||||
return(get_header_tar(archive_handle));
|
||||
}
|
||||
case 'D':
|
||||
case 'M':
|
||||
case 'N':
|
||||
case 'S':
|
||||
case 'V':
|
||||
bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->passed = llist_add_to(archive_handle->passed, archive_handle->file_header->name);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
return(tar_entry);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern char get_header_tar_bz2(archive_handle_t *archive_handle)
|
||||
{
|
||||
BZ2_bzReadOpen(archive_handle->src_fd, NULL, 0);
|
||||
|
||||
archive_handle->read = read_bz2;
|
||||
archive_handle->seek = seek_by_char;
|
||||
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
/* Cleanup */
|
||||
BZ2_bzReadClose();
|
||||
|
||||
/* Can only do one tar.bz2 per archive */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern char get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
{
|
||||
unsigned char magic[2];
|
||||
|
||||
archive_xread_all(archive_handle, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
}
|
||||
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
|
||||
GZ_gzReadOpen(archive_handle->src_fd, 0, 0);
|
||||
|
||||
archive_handle->read = read_gz;
|
||||
archive_handle->seek = seek_by_char;
|
||||
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
/* Cleanup */
|
||||
GZ_gzReadClose();
|
||||
|
||||
check_trailer_gzip(archive_handle->src_fd);
|
||||
|
||||
/* Can only do one tar.bz2 per archive */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void header_list(const file_header_t *file_header)
|
||||
{
|
||||
puts(file_header->name);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void header_skip(const file_header_t *file_header)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void header_verbose_list(const file_header_t *file_header)
|
||||
{
|
||||
struct tm *mtime = localtime(&file_header->mtime);
|
||||
|
||||
printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||
bb_mode_string(file_header->mode),
|
||||
file_header->uid,
|
||||
file_header->gid,
|
||||
(unsigned int) file_header->size,
|
||||
1900 + mtime->tm_year,
|
||||
1 + mtime->tm_mon,
|
||||
mtime->tm_mday,
|
||||
mtime->tm_hour,
|
||||
mtime->tm_min,
|
||||
mtime->tm_sec,
|
||||
file_header->name);
|
||||
|
||||
if (file_header->link_name) {
|
||||
printf(" -> %s", file_header->link_name);
|
||||
}
|
||||
/* putchar isnt used anywhere else i dont think */
|
||||
puts("");
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
archive_handle_t *init_handle(void)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
|
||||
/* Initialise default values */
|
||||
archive_handle = xmalloc(sizeof(archive_handle_t));
|
||||
memset(archive_handle, 0, sizeof(archive_handle_t));
|
||||
archive_handle->file_header = xmalloc(sizeof(file_header_t));
|
||||
archive_handle->action_header = header_skip;
|
||||
archive_handle->action_data = data_skip;
|
||||
archive_handle->filter = filter_accept_all;
|
||||
archive_handle->read = bb_full_read;
|
||||
archive_handle->seek = seek_by_jump;
|
||||
|
||||
return(archive_handle);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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 "unarchive.h"
|
||||
|
||||
extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int amount)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < amount; i++) {
|
||||
archive_xread_char(archive_handle);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
|
||||
{
|
||||
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
|
||||
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
|
||||
if (errno == ESPIPE) {
|
||||
seek_by_char(archive_handle, amount);
|
||||
} else
|
||||
#endif
|
||||
bb_perror_msg_and_die("Seek failure");
|
||||
}
|
||||
}
|
||||
@@ -1,241 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <fnmatch.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* Extract the data postioned at src_stream to either filesystem, stdout or
|
||||
* buffer depending on the value of 'function' which is defined in libbb.h
|
||||
*
|
||||
* prefix doesnt have to be just a directory, it may prefix the filename as well.
|
||||
*
|
||||
* e.g. '/var/lib/dpkg/info/dpkg.' will extract all files to the base bath
|
||||
* '/var/lib/dpkg/info/' and all files/dirs created in that dir will have
|
||||
* 'dpkg.' as their prefix
|
||||
*
|
||||
* For this reason if prefix does point to a dir then it must end with a
|
||||
* trailing '/' or else the last dir will be assumed to be the file prefix
|
||||
*/
|
||||
char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry,
|
||||
const int function, const char *prefix)
|
||||
{
|
||||
FILE *dst_stream = NULL;
|
||||
char *full_name = NULL;
|
||||
char *buffer = NULL;
|
||||
struct utimbuf t;
|
||||
|
||||
/* prefix doesnt have to be a proper path it may prepend
|
||||
* the filename as well */
|
||||
if (prefix != NULL) {
|
||||
/* strip leading '/' in filename to extract as prefix may not be dir */
|
||||
/* Cant use concat_path_file here as prefix might not be a directory */
|
||||
char *path = file_entry->name;
|
||||
if (strncmp("./", path, 2) == 0) {
|
||||
path += 2;
|
||||
if (strlen(path) == 0) {
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
full_name = xmalloc(strlen(prefix) + strlen(path) + 1);
|
||||
strcpy(full_name, prefix);
|
||||
strcat(full_name, path);
|
||||
} else {
|
||||
full_name = file_entry->name;
|
||||
}
|
||||
if (function & extract_to_stdout) {
|
||||
if (S_ISREG(file_entry->mode)) {
|
||||
copy_file_chunk(src_stream, out_stream, file_entry->size);
|
||||
archive_offset += file_entry->size;
|
||||
}
|
||||
}
|
||||
else if (function & extract_one_to_buffer) {
|
||||
if (S_ISREG(file_entry->mode)) {
|
||||
buffer = (char *) xmalloc(file_entry->size + 1);
|
||||
fread(buffer, 1, file_entry->size, src_stream);
|
||||
buffer[file_entry->size] = '\0';
|
||||
archive_offset += file_entry->size;
|
||||
return(buffer);
|
||||
}
|
||||
}
|
||||
else if (function & extract_all_to_fs) {
|
||||
struct stat oldfile;
|
||||
int stat_res;
|
||||
stat_res = lstat (full_name, &oldfile);
|
||||
if (stat_res == 0) { /* The file already exists */
|
||||
if ((function & extract_unconditional) || (oldfile.st_mtime < file_entry->mtime)) {
|
||||
if (!S_ISDIR(oldfile.st_mode)) {
|
||||
unlink(full_name); /* Directories might not be empty etc */
|
||||
}
|
||||
} else {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
error_msg("%s not created: newer or same age file exists", file_entry->name);
|
||||
}
|
||||
seek_sub_file(src_stream, file_entry->size);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
if (function & extract_create_leading_dirs) { /* Create leading directories with default umask */
|
||||
char *buf, *parent;
|
||||
buf = xstrdup(full_name);
|
||||
parent = dirname(buf);
|
||||
if (make_directory (parent, -1, FILEUTILS_RECUR) != 0) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
error_msg("couldn't create leading directories");
|
||||
}
|
||||
}
|
||||
free (buf);
|
||||
}
|
||||
switch(file_entry->mode & S_IFMT) {
|
||||
case S_IFREG:
|
||||
if (file_entry->link_name) { /* Found a cpio hard link */
|
||||
if (link(file_entry->link_name, full_name) != 0) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
perror_msg("Cannot link from %s to '%s'",
|
||||
file_entry->name, file_entry->link_name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((dst_stream = wfopen(full_name, "w")) == NULL) {
|
||||
seek_sub_file(src_stream, file_entry->size);
|
||||
return NULL;
|
||||
}
|
||||
archive_offset += file_entry->size;
|
||||
copy_file_chunk(src_stream, dst_stream, file_entry->size);
|
||||
fclose(dst_stream);
|
||||
}
|
||||
break;
|
||||
case S_IFDIR:
|
||||
if (stat_res != 0) {
|
||||
if (mkdir(full_name, file_entry->mode) < 0) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
perror_msg("extract_archive: %s", full_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
if (symlink(file_entry->link_name, full_name) < 0) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
case S_IFIFO:
|
||||
if (mknod(full_name, file_entry->mode, file_entry->device) == -1) {
|
||||
if ((function & extract_quiet) != extract_quiet) {
|
||||
perror_msg("Cannot create node %s", file_entry->name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Changing a symlink's properties normally changes the properties of the
|
||||
* file pointed to, so dont try and change the date or mode, lchown does
|
||||
* does the right thing, but isnt available in older versions of libc */
|
||||
if (S_ISLNK(file_entry->mode)) {
|
||||
#if (__GLIBC__ > 2) && (__GLIBC_MINOR__ > 1)
|
||||
lchown(full_name, file_entry->uid, file_entry->gid);
|
||||
#endif
|
||||
} else {
|
||||
if (function & extract_preserve_date) {
|
||||
t.actime = file_entry->mtime;
|
||||
t.modtime = file_entry->mtime;
|
||||
utime(full_name, &t);
|
||||
}
|
||||
chmod(full_name, file_entry->mode);
|
||||
chown(full_name, file_entry->uid, file_entry->gid);
|
||||
}
|
||||
} else {
|
||||
/* If we arent extracting data we have to skip it,
|
||||
* if data size is 0 then then just do it anyway
|
||||
* (saves testing for it) */
|
||||
seek_sub_file(src_stream, file_entry->size);
|
||||
}
|
||||
|
||||
/* extract_list and extract_verbose_list can be used in conjunction
|
||||
* with one of the above four extraction functions, so do this seperately */
|
||||
if (function & extract_verbose_list) {
|
||||
fprintf(out_stream, "%s %d/%d %8d %s ", mode_string(file_entry->mode),
|
||||
file_entry->uid, file_entry->gid,
|
||||
(int) file_entry->size, time_string(file_entry->mtime));
|
||||
}
|
||||
if ((function & extract_list) || (function & extract_verbose_list)){
|
||||
/* fputs doesnt add a trailing \n, so use fprintf */
|
||||
fprintf(out_stream, "%s\n", full_name);
|
||||
}
|
||||
|
||||
free(full_name);
|
||||
|
||||
return(NULL); /* Maybe we should say if failed */
|
||||
}
|
||||
|
||||
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *),
|
||||
const int extract_function, const char *prefix, char **include_name, char **exclude_name)
|
||||
{
|
||||
file_header_t *file_entry;
|
||||
int extract_flag = TRUE;
|
||||
int i;
|
||||
char *buffer = NULL;
|
||||
|
||||
archive_offset = 0;
|
||||
while ((file_entry = get_headers(src_stream)) != NULL) {
|
||||
|
||||
if (include_name != NULL) {
|
||||
extract_flag = FALSE;
|
||||
for(i = 0; include_name[i] != 0; i++) {
|
||||
if (fnmatch(include_name[i], file_entry->name, FNM_LEADING_DIR) == 0) {
|
||||
extract_flag = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
extract_flag = TRUE;
|
||||
}
|
||||
|
||||
/* If the file entry is in the exclude list dont extract it */
|
||||
if (exclude_name != NULL) {
|
||||
for(i = 0; exclude_name[i] != 0; i++) {
|
||||
if (fnmatch(exclude_name[i], file_entry->name, FNM_LEADING_DIR) == 0) {
|
||||
extract_flag = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (extract_flag == TRUE) {
|
||||
buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
|
||||
} else {
|
||||
/* seek past the data entry */
|
||||
seek_sub_file(src_stream, file_entry->size);
|
||||
}
|
||||
free(file_entry->name);
|
||||
free(file_entry->link_name);
|
||||
free(file_entry);
|
||||
}
|
||||
return(buffer);
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
#include "config.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#if defined CONFIG_UNCOMPRESS || defined CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
|
||||
/* uncompress for busybox -- (c) 2002 Robert Griebl
|
||||
*
|
||||
* based on the original compress42.c source
|
||||
* (see disclaimer below)
|
||||
*/
|
||||
|
||||
|
||||
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
|
||||
*
|
||||
* Authors:
|
||||
* Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
|
||||
* Jim McKie (decvax!mcvax!jim)
|
||||
* Steve Davies (decvax!vax135!petsd!peora!srd)
|
||||
* Ken Turkowski (decvax!decwrl!turtlevax!ken)
|
||||
* James A. Woods (decvax!ihnp4!ames!jaw)
|
||||
* Joe Orost (decvax!vax135!petsd!joe)
|
||||
* Dave Mack (csu@alembic.acs.com)
|
||||
* Peter Jannesen, Network Communication Systems
|
||||
* (peter@ncs.nl)
|
||||
*
|
||||
* marc@suse.de : a small security fix for a buffer overflow
|
||||
*
|
||||
* [... History snipped ...]
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Defailt input buffer size */
|
||||
#define IBUFSIZ 2048
|
||||
|
||||
/* Default output buffer size */
|
||||
#define OBUFSIZ 2048
|
||||
|
||||
/* Defines for third byte of header */
|
||||
#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */
|
||||
#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */
|
||||
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
|
||||
/* Masks 0x20 and 0x40 are free. */
|
||||
/* I think 0x20 should mean that there is */
|
||||
/* a fourth header byte (for expansion). */
|
||||
#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */
|
||||
/* compression rate is dropping flush tables */
|
||||
/* the next two codes should not be changed lightly, as they must not */
|
||||
/* lie within the contiguous general code space. */
|
||||
#define FIRST 257 /* first free entry */
|
||||
#define CLEAR 256 /* table clear output code */
|
||||
|
||||
#define INIT_BITS 9 /* initial number of bits/code */
|
||||
|
||||
|
||||
/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */
|
||||
#define FAST
|
||||
|
||||
#define HBITS 17 /* 50% occupancy */
|
||||
#define HSIZE (1<<HBITS)
|
||||
#define HMASK (HSIZE-1)
|
||||
#define HPRIME 9941
|
||||
#define BITS 16
|
||||
#undef MAXSEG_64K
|
||||
#define MAXCODE(n) (1L << (n))
|
||||
|
||||
/* Block compress mode -C compatible with 2.0 */
|
||||
int block_mode = BLOCK_MODE;
|
||||
|
||||
/* user settable max # bits/code */
|
||||
int maxbits = BITS;
|
||||
|
||||
/* Exitcode of compress (-1 no file compressed) */
|
||||
int exit_code = -1;
|
||||
|
||||
/* Input buffer */
|
||||
unsigned char inbuf[IBUFSIZ + 64];
|
||||
|
||||
/* Output buffer */
|
||||
unsigned char outbuf[OBUFSIZ + 2048];
|
||||
|
||||
|
||||
long int htab[HSIZE];
|
||||
unsigned short codetab[HSIZE];
|
||||
|
||||
#define htabof(i) htab[i]
|
||||
#define codetabof(i) codetab[i]
|
||||
#define tab_prefixof(i) codetabof(i)
|
||||
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
|
||||
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
|
||||
#define clear_htab() memset(htab, -1, sizeof(htab))
|
||||
#define clear_tab_prefixof() memset(codetab, 0, 256);
|
||||
|
||||
|
||||
/*
|
||||
* Decompress stdin to stdout. This routine adapts to the codes in the
|
||||
* file building the "string" table on-the-fly; requiring no table to
|
||||
* be stored in the compressed file. The tables used herein are shared
|
||||
* with those of the compress() routine. See the definitions above.
|
||||
*/
|
||||
|
||||
extern int uncompress(int fd_in, int fd_out)
|
||||
{
|
||||
unsigned char *stackp;
|
||||
long int code;
|
||||
int finchar;
|
||||
long int oldcode;
|
||||
long int incode;
|
||||
int inbits;
|
||||
int posbits;
|
||||
int outpos;
|
||||
int insize;
|
||||
int bitmask;
|
||||
long int free_ent;
|
||||
long int maxcode;
|
||||
long int maxmaxcode;
|
||||
int n_bits;
|
||||
int rsize = 0;
|
||||
|
||||
insize = 0;
|
||||
|
||||
inbuf[0] = bb_xread_char(fd_in);
|
||||
|
||||
maxbits = inbuf[0] & BIT_MASK;
|
||||
block_mode = inbuf[0] & BLOCK_MODE;
|
||||
maxmaxcode = MAXCODE(maxbits);
|
||||
|
||||
if (maxbits > BITS) {
|
||||
bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
|
||||
BITS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
oldcode = -1;
|
||||
finchar = 0;
|
||||
outpos = 0;
|
||||
posbits = 0 << 3;
|
||||
|
||||
free_ent = ((block_mode) ? FIRST : 256);
|
||||
|
||||
/* As above, initialize the first 256 entries in the table. */
|
||||
clear_tab_prefixof();
|
||||
|
||||
for (code = 255; code >= 0; --code) {
|
||||
tab_suffixof(code) = (unsigned char) code;
|
||||
}
|
||||
|
||||
do {
|
||||
resetbuf:;
|
||||
{
|
||||
int i;
|
||||
int e;
|
||||
int o;
|
||||
|
||||
e = insize - (o = (posbits >> 3));
|
||||
|
||||
for (i = 0; i < e; ++i)
|
||||
inbuf[i] = inbuf[i + o];
|
||||
|
||||
insize = e;
|
||||
posbits = 0;
|
||||
}
|
||||
|
||||
if (insize < (int) sizeof(inbuf) - IBUFSIZ) {
|
||||
rsize = read(fd_in, inbuf + insize, IBUFSIZ);
|
||||
insize += rsize;
|
||||
}
|
||||
|
||||
inbits = ((rsize > 0) ? (insize - insize % n_bits) << 3 :
|
||||
(insize << 3) - (n_bits - 1));
|
||||
|
||||
while (inbits > posbits) {
|
||||
if (free_ent > maxcode) {
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
++n_bits;
|
||||
if (n_bits == maxbits) {
|
||||
maxcode = maxmaxcode;
|
||||
} else {
|
||||
maxcode = MAXCODE(n_bits) - 1;
|
||||
}
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
{
|
||||
unsigned char *p = &inbuf[posbits >> 3];
|
||||
|
||||
code =
|
||||
((((long) (p[0])) | ((long) (p[1]) << 8) |
|
||||
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
|
||||
}
|
||||
posbits += n_bits;
|
||||
|
||||
|
||||
if (oldcode == -1) {
|
||||
outbuf[outpos++] = (unsigned char) (finchar =
|
||||
(int) (oldcode = code));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code == CLEAR && block_mode) {
|
||||
clear_tab_prefixof();
|
||||
free_ent = FIRST - 1;
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
|
||||
incode = code;
|
||||
stackp = de_stack;
|
||||
|
||||
/* Special case for KwKwK string. */
|
||||
if (code >= free_ent) {
|
||||
if (code > free_ent) {
|
||||
unsigned char *p;
|
||||
|
||||
posbits -= n_bits;
|
||||
p = &inbuf[posbits >> 3];
|
||||
|
||||
bb_error_msg
|
||||
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
|
||||
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
||||
(posbits & 07));
|
||||
bb_error_msg("uncompress: corrupt input");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) finchar;
|
||||
code = oldcode;
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while ((long int) code >= (long int) 256) {
|
||||
*--stackp = tab_suffixof(code);
|
||||
code = tab_prefixof(code);
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) (finchar = tab_suffixof(code));
|
||||
|
||||
/* And put them out in forward order */
|
||||
{
|
||||
int i;
|
||||
|
||||
if (outpos + (i = (de_stack - stackp)) >= OBUFSIZ) {
|
||||
do {
|
||||
if (i > OBUFSIZ - outpos) {
|
||||
i = OBUFSIZ - outpos;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
}
|
||||
|
||||
if (outpos >= OBUFSIZ) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
outpos = 0;
|
||||
}
|
||||
stackp += i;
|
||||
} while ((i = (de_stack - stackp)) > 0);
|
||||
} else {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate the new entry. */
|
||||
if ((code = free_ent) < maxmaxcode) {
|
||||
tab_prefixof(code) = (unsigned short) oldcode;
|
||||
tab_suffixof(code) = (unsigned char) finchar;
|
||||
free_ent = code + 1;
|
||||
}
|
||||
|
||||
/* Remember previous code. */
|
||||
oldcode = incode;
|
||||
}
|
||||
|
||||
} while (rsize > 0);
|
||||
|
||||
if (outpos > 0) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
extern void unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
{
|
||||
char magic[7];
|
||||
|
||||
archive_xread_all(ar_archive, magic, 7);
|
||||
if (strncmp(magic, "!<arch>", 7) != 0) {
|
||||
bb_error_msg_and_die("Invalid ar magic");
|
||||
}
|
||||
ar_archive->offset += 7;
|
||||
|
||||
while (get_header_ar(ar_archive) == EXIT_SUCCESS);
|
||||
}
|
||||
+685
-671
File diff suppressed because it is too large.
Load diff
+352
@@ -0,0 +1,352 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini rpm applet for busybox
|
||||
*
|
||||
* Copyright (C) 2001,2002 by Laurence Anderson
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h> /* For ntohl & htonl function */
|
||||
#include <string.h> /* For strncmp */
|
||||
#include <sys/mman.h> /* For mmap */
|
||||
#include <time.h> /* For ctime */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
#define RPM_CHAR_TYPE 1
|
||||
#define RPM_INT8_TYPE 2
|
||||
#define RPM_INT16_TYPE 3
|
||||
#define RPM_INT32_TYPE 4
|
||||
/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */
|
||||
#define RPM_STRING_TYPE 6
|
||||
#define RPM_BIN_TYPE 7
|
||||
#define RPM_STRING_ARRAY_TYPE 8
|
||||
#define RPM_I18NSTRING_TYPE 9
|
||||
|
||||
#define RPMTAG_NAME 1000
|
||||
#define RPMTAG_VERSION 1001
|
||||
#define RPMTAG_RELEASE 1002
|
||||
#define RPMTAG_SUMMARY 1004
|
||||
#define RPMTAG_DESCRIPTION 1005
|
||||
#define RPMTAG_BUILDTIME 1006
|
||||
#define RPMTAG_BUILDHOST 1007
|
||||
#define RPMTAG_SIZE 1009
|
||||
#define RPMTAG_VENDOR 1011
|
||||
#define RPMTAG_LICENSE 1014
|
||||
#define RPMTAG_PACKAGER 1015
|
||||
#define RPMTAG_GROUP 1016
|
||||
#define RPMTAG_URL 1020
|
||||
#define RPMTAG_PREIN 1023
|
||||
#define RPMTAG_POSTIN 1024
|
||||
#define RPMTAG_FILEFLAGS 1037
|
||||
#define RPMTAG_FILEUSERNAME 1039
|
||||
#define RPMTAG_FILEGROUPNAME 1040
|
||||
#define RPMTAG_SOURCERPM 1044
|
||||
#define RPMTAG_PREINPROG 1085
|
||||
#define RPMTAG_POSTINPROG 1086
|
||||
#define RPMTAG_PREFIXS 1098
|
||||
#define RPMTAG_DIRINDEXES 1116
|
||||
#define RPMTAG_BASENAMES 1117
|
||||
#define RPMTAG_DIRNAMES 1118
|
||||
#define RPMFILE_CONFIG (1 << 0)
|
||||
#define RPMFILE_DOC (1 << 1)
|
||||
|
||||
enum rpm_functions_e {
|
||||
rpm_query = 1,
|
||||
rpm_install = 2,
|
||||
rpm_query_info = 4,
|
||||
rpm_query_package = 8,
|
||||
rpm_query_list = 16,
|
||||
rpm_query_list_doc = 32,
|
||||
rpm_query_list_config = 64
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u_int32_t tag; /* 4 byte tag */
|
||||
u_int32_t type; /* 4 byte type */
|
||||
u_int32_t offset; /* 4 byte offset */
|
||||
u_int32_t count; /* 4 byte count */
|
||||
} rpm_index;
|
||||
|
||||
static void *map;
|
||||
static rpm_index **mytags;
|
||||
static int tagcount;
|
||||
|
||||
void extract_cpio_gz(int fd);
|
||||
rpm_index **rpm_gettags(int fd, int *num_tags);
|
||||
int bsearch_rpmtag(const void *key, const void *item);
|
||||
char *rpm_getstring(int tag, int itemindex);
|
||||
int rpm_getint(int tag, int itemindex);
|
||||
int rpm_getcount(int tag);
|
||||
void exec_script(int progtag, int datatag, char *prefix);
|
||||
void fileaction_dobackup(char *filename, int fileref);
|
||||
void fileaction_setowngrp(char *filename, int fileref);
|
||||
void fileaction_list(char *filename, int itemno);
|
||||
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
|
||||
|
||||
int rpm_main(int argc, char **argv)
|
||||
{
|
||||
int opt = 0, func = 0, rpm_fd, offset;
|
||||
|
||||
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i': // First arg: Install mode, with q: Information
|
||||
if (!func) func |= rpm_install;
|
||||
else func |= rpm_query_info;
|
||||
break;
|
||||
case 'q': // First arg: Query mode
|
||||
if (!func) func |= rpm_query;
|
||||
else bb_show_usage();
|
||||
break;
|
||||
case 'p': // Query a package
|
||||
func |= rpm_query_package;
|
||||
break;
|
||||
case 'l': // List files in a package
|
||||
func |= rpm_query_list;
|
||||
break;
|
||||
case 'd': // List doc files in a package (implies list)
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_doc;
|
||||
break;
|
||||
case 'c': // List config files in a package (implies list)
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_config;
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc) bb_show_usage();
|
||||
while (optind < argc) {
|
||||
rpm_fd = bb_xopen(argv[optind], O_RDONLY);
|
||||
mytags = rpm_gettags(rpm_fd, (int *) &tagcount);
|
||||
offset = lseek(rpm_fd, 0, SEEK_CUR);
|
||||
if (!mytags) { printf("Error reading rpm header\n"); exit(-1); }
|
||||
map = mmap(0, offset > getpagesize() ? (offset + offset % getpagesize()) : getpagesize(), PROT_READ, MAP_SHARED, rpm_fd, 0); // Mimimum is one page
|
||||
if (func & rpm_install) {
|
||||
loop_through_files(RPMTAG_BASENAMES, fileaction_dobackup); /* Backup any config files */
|
||||
extract_cpio_gz(rpm_fd); // Extact the archive
|
||||
loop_through_files(RPMTAG_BASENAMES, fileaction_setowngrp); /* Set the correct file uid/gid's */
|
||||
} else if (func & rpm_query && func & rpm_query_package) {
|
||||
if (!((func & rpm_query_info) || (func & rpm_query_list))) { // If just a straight query, just give package name
|
||||
printf("%s-%s-%s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_RELEASE, 0));
|
||||
}
|
||||
if (func & rpm_query_info) {
|
||||
/* Do the nice printout */
|
||||
time_t bdate_time;
|
||||
struct tm *bdate;
|
||||
char bdatestring[50];
|
||||
printf("Name : %-29sRelocations: %s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_PREFIXS, 0) ? rpm_getstring(RPMTAG_PREFIXS, 0) : "(not relocateable)");
|
||||
printf("Version : %-34sVendor: %s\n", rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_VENDOR, 0) ? rpm_getstring(RPMTAG_VENDOR, 0) : "(none)");
|
||||
bdate_time = rpm_getint(RPMTAG_BUILDTIME, 0);
|
||||
bdate = localtime((time_t *) &bdate_time);
|
||||
strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate);
|
||||
printf("Release : %-30sBuild Date: %s\n", rpm_getstring(RPMTAG_RELEASE, 0), bdatestring);
|
||||
printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstring(RPMTAG_BUILDHOST, 0));
|
||||
printf("Group : %-30sSource RPM: %s\n", rpm_getstring(RPMTAG_GROUP, 0), rpm_getstring(RPMTAG_SOURCERPM, 0));
|
||||
printf("Size : %-33dLicense: %s\n", rpm_getint(RPMTAG_SIZE, 0), rpm_getstring(RPMTAG_LICENSE, 0));
|
||||
printf("URL : %s\n", rpm_getstring(RPMTAG_URL, 0));
|
||||
printf("Summary : %s\n", rpm_getstring(RPMTAG_SUMMARY, 0));
|
||||
printf("Description :\n%s\n", rpm_getstring(RPMTAG_DESCRIPTION, 0));
|
||||
}
|
||||
if (func & rpm_query_list) {
|
||||
int count, it, flags;
|
||||
count = rpm_getcount(RPMTAG_BASENAMES);
|
||||
for (it = 0; it < count; it++) {
|
||||
flags = rpm_getint(RPMTAG_FILEFLAGS, it);
|
||||
switch ((func & rpm_query_list_doc) + (func & rpm_query_list_config))
|
||||
{
|
||||
case rpm_query_list_doc: if (!(flags & RPMFILE_DOC)) continue; break;
|
||||
case rpm_query_list_config: if (!(flags & RPMFILE_CONFIG)) continue; break;
|
||||
case rpm_query_list_doc + rpm_query_list_config: if (!((flags & RPMFILE_CONFIG) || (flags & RPMFILE_DOC))) continue; break;
|
||||
}
|
||||
printf("%s%s\n", rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, it)), rpm_getstring(RPMTAG_BASENAMES, it));
|
||||
}
|
||||
}
|
||||
}
|
||||
optind++;
|
||||
free (mytags);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extract_cpio_gz(int fd) {
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned char magic[2];
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->read = read_gz;
|
||||
archive_handle->seek = seek_by_char;
|
||||
//archive_handle->action_header = header_list;
|
||||
archive_handle->action_data = data_extract_all;
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
archive_handle->src_fd = fd;
|
||||
archive_handle->offset = 0;
|
||||
|
||||
bb_xread_all(archive_handle->src_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
}
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
chdir("/"); // Install RPM's to root
|
||||
|
||||
GZ_gzReadOpen(archive_handle->src_fd, 0, 0);
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
|
||||
GZ_gzReadClose();
|
||||
|
||||
check_trailer_gzip(archive_handle->src_fd);
|
||||
}
|
||||
|
||||
|
||||
rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
{
|
||||
rpm_index **tags = calloc(200, sizeof(struct rpmtag *)); /* We should never need mode than 200, and realloc later */
|
||||
int pass, tagindex = 0;
|
||||
lseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
|
||||
|
||||
for (pass = 0; pass < 2; pass++) { /* 1st pass is the signature headers, 2nd is the main stuff */
|
||||
struct {
|
||||
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
|
||||
u_int8_t version; /* 1 byte version number */
|
||||
u_int32_t reserved; /* 4 bytes reserved */
|
||||
u_int32_t entries; /* Number of entries in header (4 bytes) */
|
||||
u_int32_t size; /* Size of store (4 bytes) */
|
||||
} header;
|
||||
rpm_index *tmpindex;
|
||||
int storepos;
|
||||
|
||||
read(fd, &header, sizeof(header));
|
||||
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) return NULL; /* Invalid magic */
|
||||
if (header.version != 1) return NULL; /* This program only supports v1 headers */
|
||||
header.size = ntohl(header.size);
|
||||
header.entries = ntohl(header.entries);
|
||||
storepos = lseek(fd,0,SEEK_CUR) + header.entries * 16;
|
||||
|
||||
while (header.entries--) {
|
||||
tmpindex = tags[tagindex++] = malloc(sizeof(rpm_index));
|
||||
read(fd, tmpindex, sizeof(rpm_index));
|
||||
tmpindex->tag = ntohl(tmpindex->tag); tmpindex->type = ntohl(tmpindex->type); tmpindex->count = ntohl(tmpindex->count);
|
||||
tmpindex->offset = storepos + ntohl(tmpindex->offset);
|
||||
if (pass==0) tmpindex->tag -= 743;
|
||||
}
|
||||
lseek(fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
if (pass==0) lseek(fd, (8 - (lseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); /* Skip padding to 8 byte boundary after reading signature headers */
|
||||
}
|
||||
tags = realloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
|
||||
*num_tags = tagindex;
|
||||
return tags; /* All done, leave the file at the start of the gzipped cpio archive */
|
||||
}
|
||||
|
||||
int bsearch_rpmtag(const void *key, const void *item)
|
||||
{
|
||||
rpm_index **tmp = (rpm_index **) item;
|
||||
return ((int) key - tmp[0]->tag);
|
||||
}
|
||||
|
||||
int rpm_getcount(int tag)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found) return 0;
|
||||
else return found[0]->count;
|
||||
}
|
||||
|
||||
char *rpm_getstring(int tag, int itemindex)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count) return NULL;
|
||||
if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) {
|
||||
int n;
|
||||
char *tmpstr = (char *) (map + found[0]->offset);
|
||||
for (n=0; n < itemindex; n++) tmpstr = tmpstr + strlen(tmpstr) + 1;
|
||||
return tmpstr;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
int rpm_getint(int tag, int itemindex)
|
||||
{
|
||||
rpm_index **found;
|
||||
int n, *tmpint;
|
||||
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count) return -1;
|
||||
tmpint = (int *) (map + found[0]->offset);
|
||||
if (found[0]->type == RPM_INT32_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 4);
|
||||
return ntohl(*tmpint);
|
||||
} else if (found[0]->type == RPM_INT16_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 2);
|
||||
return ntohs(*tmpint);
|
||||
} else if (found[0]->type == RPM_INT8_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 1);
|
||||
return ntohs(*tmpint);
|
||||
} else return -1;
|
||||
}
|
||||
|
||||
void fileaction_dobackup(char *filename, int fileref)
|
||||
{
|
||||
struct stat oldfile;
|
||||
int stat_res;
|
||||
char *newname;
|
||||
if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
|
||||
stat_res = lstat (filename, &oldfile);
|
||||
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
|
||||
newname = bb_xstrdup(filename);
|
||||
newname = strcat(newname, ".rpmorig");
|
||||
copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
|
||||
remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
|
||||
free(newname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fileaction_setowngrp(char *filename, int fileref)
|
||||
{
|
||||
int uid, gid;
|
||||
uid = my_getpwnam(rpm_getstring(RPMTAG_FILEUSERNAME, fileref));
|
||||
gid = my_getgrnam(rpm_getstring(RPMTAG_FILEGROUPNAME, fileref));
|
||||
chown (filename, uid, gid);
|
||||
}
|
||||
|
||||
void fileaction_list(char *filename, int fileref)
|
||||
{
|
||||
printf("%s\n", filename);
|
||||
}
|
||||
|
||||
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref))
|
||||
{
|
||||
int count = 0;
|
||||
char *filename, *tmp_dirname, *tmp_basename;
|
||||
while (rpm_getstring(filetag, count)) {
|
||||
tmp_dirname = rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, count)); /* 1st put on the directory */
|
||||
tmp_basename = rpm_getstring(RPMTAG_BASENAMES, count);
|
||||
filename = xmalloc(strlen(tmp_basename) + strlen(tmp_dirname) + 1);
|
||||
strcpy(filename, tmp_dirname); /* First the directory name */
|
||||
strcat(filename, tmp_basename); /* then the filename */
|
||||
fileaction(filename, count++);
|
||||
free(filename);
|
||||
}
|
||||
}
|
||||
+40
-23
@@ -18,10 +18,13 @@
|
||||
* 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 <sys/types.h>
|
||||
#include <netinet/in.h> /* For ntohl & htonl function */
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_MAGIC "\355\253\356\333"
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
@@ -45,46 +48,60 @@ struct rpm_header {
|
||||
u_int32_t size; /* Size of store (4 bytes) */
|
||||
};
|
||||
|
||||
void skip_header(FILE *rpmfile)
|
||||
void skip_header(int rpm_fd)
|
||||
{
|
||||
struct rpm_header header;
|
||||
|
||||
fread(&header, sizeof(struct rpm_header), 1, rpmfile);
|
||||
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
|
||||
if (header.version != 1) error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */
|
||||
bb_xread_all(rpm_fd, &header, sizeof(struct rpm_header));
|
||||
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) {
|
||||
bb_error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
|
||||
}
|
||||
if (header.version != 1) {
|
||||
bb_error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */
|
||||
}
|
||||
header.entries = ntohl(header.entries);
|
||||
header.size = ntohl(header.size);
|
||||
fseek (rpmfile, 16 * header.entries, SEEK_CUR); /* Seek past index entries */
|
||||
fseek (rpmfile, header.size, SEEK_CUR); /* Seek past store */
|
||||
lseek (rpm_fd, 16 * header.entries, SEEK_CUR); /* Seek past index entries */
|
||||
lseek (rpm_fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
}
|
||||
|
||||
/* No getopt required */
|
||||
extern int rpm2cpio_main(int argc, char **argv)
|
||||
{
|
||||
struct rpm_lead lead;
|
||||
int gunzip_pid;
|
||||
FILE *rpmfile, *cpiofile;
|
||||
int rpm_fd;
|
||||
unsigned char magic[2];
|
||||
|
||||
if (argc == 1) {
|
||||
rpmfile = stdin;
|
||||
rpm_fd = fileno(stdin);
|
||||
} else {
|
||||
rpmfile = xfopen(argv[1], "r");
|
||||
/* set the buffer size */
|
||||
setvbuf(rpmfile, NULL, _IOFBF, 0x8000);
|
||||
rpm_fd = bb_xopen(argv[1], O_RDONLY);
|
||||
}
|
||||
|
||||
bb_xread_all(rpm_fd, &lead, sizeof(struct rpm_lead));
|
||||
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) {
|
||||
bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
|
||||
}
|
||||
|
||||
fread (&lead, sizeof(struct rpm_lead), 1, rpmfile);
|
||||
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
|
||||
/* Skip the signature header */
|
||||
skip_header(rpmfile);
|
||||
fseek(rpmfile, (8 - (ftell(rpmfile) % 8)) % 8, SEEK_CUR); /* Pad to 8 byte boundary */
|
||||
skip_header(rpm_fd);
|
||||
lseek(rpm_fd, (8 - (lseek(rpm_fd, 0, SEEK_CUR) % 8)) % 8, SEEK_CUR);
|
||||
|
||||
/* Skip the main header */
|
||||
skip_header(rpmfile);
|
||||
skip_header(rpm_fd);
|
||||
|
||||
bb_xread_all(rpm_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
}
|
||||
|
||||
cpiofile = gz_open(rpmfile, &gunzip_pid);
|
||||
check_header_gzip(rpm_fd);
|
||||
if (inflate(rpm_fd, fileno(stdout)) != 0) {
|
||||
bb_error_msg("Error inflating");
|
||||
}
|
||||
check_trailer_gzip(rpm_fd);
|
||||
|
||||
close(rpm_fd);
|
||||
|
||||
copyfd(fileno(cpiofile), fileno(stdout));
|
||||
gz_close(gunzip_pid);
|
||||
fclose(rpmfile);
|
||||
return 0;
|
||||
}
|
||||
+425
-404
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,115 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Uncompress applet for busybox (c) 2002 Glenn McGrath
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define GUNZIP_TO_STDOUT 1
|
||||
#define GUNZIP_FORCE 2
|
||||
|
||||
extern int uncompress_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
unsigned long flags;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "cf");
|
||||
|
||||
while (optind < argc) {
|
||||
const char *compressed_file = argv[optind++];
|
||||
const char *delete_path = NULL;
|
||||
char *uncompressed_file = NULL;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
if (strcmp(compressed_file, "-") == 0) {
|
||||
src_fd = fileno(stdin);
|
||||
flags |= GUNZIP_TO_STDOUT;
|
||||
} else {
|
||||
src_fd = bb_xopen(compressed_file, O_RDONLY);
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && ((flags & GUNZIP_FORCE) == 0)) {
|
||||
bb_error_msg_and_die
|
||||
("compressed data not read from terminal. Use -f to force it.");
|
||||
}
|
||||
|
||||
/* Set output filename and number */
|
||||
if (flags & GUNZIP_TO_STDOUT) {
|
||||
dst_fd = fileno(stdout);
|
||||
} else {
|
||||
struct stat stat_buf;
|
||||
char *extension;
|
||||
|
||||
uncompressed_file = bb_xstrdup(compressed_file);
|
||||
|
||||
extension = strrchr(uncompressed_file, '.');
|
||||
if (!extension || (strcmp(extension, ".Z") != 0)) {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
*extension = '\0';
|
||||
|
||||
/* Open output file */
|
||||
dst_fd = bb_xopen(uncompressed_file, O_WRONLY | O_CREAT);
|
||||
|
||||
/* Set permissions on the file */
|
||||
stat(compressed_file, &stat_buf);
|
||||
chmod(uncompressed_file, stat_buf.st_mode);
|
||||
|
||||
/* If unzip succeeds remove the old file */
|
||||
delete_path = compressed_file;
|
||||
}
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if ((bb_xread_char(src_fd) != 0x1f) || (bb_xread_char(src_fd) != 0x9d)) {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
|
||||
status = uncompress(src_fd, dst_fd);
|
||||
|
||||
if ((status != EXIT_SUCCESS) && (uncompressed_file)) {
|
||||
/* Unzip failed, remove the uncomressed file instead of compressed file */
|
||||
delete_path = uncompressed_file;
|
||||
}
|
||||
|
||||
if (dst_fd != fileno(stdout)) {
|
||||
close(dst_fd);
|
||||
}
|
||||
if (src_fd != fileno(stdin)) {
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
/* delete_path will be NULL if in test mode or from stdin */
|
||||
if (delete_path && (unlink(delete_path) == -1)) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", delete_path);
|
||||
}
|
||||
|
||||
free(uncompressed_file);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini unzip implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2001 by Laurence Anderson
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* For reference to format see http://www.pkware.com/support/appnote.html */
|
||||
|
||||
/* TODO Endian issues, exclude, should we accept input from stdin ? */
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#define ZIP_FILEHEADER_MAGIC 0x04034b50
|
||||
#define ZIP_CDS_MAGIC 0x02014b50
|
||||
#define ZIP_CDS_END_MAGIC 0x06054b50
|
||||
#define ZIP_DD_MAGIC 0x08074b50
|
||||
|
||||
extern unsigned int gunzip_crc;
|
||||
extern unsigned int gunzip_bytes_out;
|
||||
|
||||
static void header_list_unzip(const file_header_t *file_header)
|
||||
{
|
||||
printf(" inflating: %s\n", file_header->name);
|
||||
}
|
||||
|
||||
static void header_verbose_list_unzip(const file_header_t *file_header)
|
||||
{
|
||||
unsigned int dostime = (unsigned int) file_header->mtime;
|
||||
|
||||
/* can printf arguments cut of the decade component ? */
|
||||
unsigned short year = 1980 + ((dostime & 0xfe000000) >> 25);
|
||||
while (year >= 100) {
|
||||
year -= 100;
|
||||
}
|
||||
|
||||
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
|
||||
(unsigned int) file_header->size,
|
||||
(dostime & 0x01e00000) >> 21,
|
||||
(dostime & 0x001f0000) >> 16,
|
||||
year,
|
||||
(dostime & 0x0000f800) >> 11,
|
||||
(dostime & 0x000007e0) >> 5,
|
||||
file_header->name);
|
||||
}
|
||||
|
||||
extern int unzip_main(int argc, char **argv)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[26];
|
||||
struct {
|
||||
unsigned short version; /* 0-1 */
|
||||
unsigned short flags; /* 2-3 */
|
||||
unsigned short method; /* 4-5 */
|
||||
unsigned short modtime; /* 6-7 */
|
||||
unsigned short moddate; /* 8-9 */
|
||||
unsigned int crc32 __attribute__ ((packed)); /* 10-13 */
|
||||
unsigned int cmpsize __attribute__ ((packed));; /* 14-17 */
|
||||
unsigned int ucmpsize __attribute__ ((packed));; /* 18-21 */
|
||||
unsigned short filename_len; /* 22-23 */
|
||||
unsigned short extra_len; /* 24-25 */
|
||||
} formated __attribute__ ((packed));
|
||||
} zip_header;
|
||||
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned int total_size = 0;
|
||||
unsigned int total_entries = 0;
|
||||
char *base_dir = NULL;
|
||||
int opt = 0;
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->action_data = NULL;
|
||||
archive_handle->action_header = header_list_unzip;
|
||||
|
||||
while ((opt = getopt(argc, argv, "lnopqd:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'l': /* list */
|
||||
archive_handle->action_header = header_verbose_list_unzip;
|
||||
archive_handle->action_data = data_skip;
|
||||
break;
|
||||
case 'n': /* never overwright existing files */
|
||||
break;
|
||||
case 'o':
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
break;
|
||||
case 'p': /* extract files to stdout */
|
||||
archive_handle->action_data = data_extract_to_stdout;
|
||||
break;
|
||||
case 'q': /* Extract files quietly */
|
||||
archive_handle->action_header = header_skip;
|
||||
break;
|
||||
case 'd': /* Extract files to specified base directory*/
|
||||
base_dir = optarg;
|
||||
break;
|
||||
#if 0
|
||||
case 'x': /* Exclude the specified files */
|
||||
archive_handle->filter = filter_accept_reject_list;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argc == optind) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
printf("Archive: %s\n", argv[optind]);
|
||||
if (archive_handle->action_header == header_verbose_list_unzip) {
|
||||
printf(" Length Date Time Name\n");
|
||||
printf(" -------- ---- ---- ----\n");
|
||||
}
|
||||
|
||||
if (*argv[optind] == '-') {
|
||||
archive_handle->src_fd = fileno(stdin);
|
||||
archive_handle->seek = seek_by_char;
|
||||
} else {
|
||||
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
}
|
||||
|
||||
if ((base_dir) && (chdir(base_dir))) {
|
||||
bb_perror_msg_and_die("Couldnt chdir");
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
archive_handle->filter = filter_accept_list;
|
||||
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
unsigned int magic;
|
||||
int dst_fd;
|
||||
|
||||
/* TODO Endian issues */
|
||||
archive_xread_all(archive_handle, &magic, 4);
|
||||
archive_handle->offset += 4;
|
||||
|
||||
if (magic == ZIP_CDS_MAGIC) {
|
||||
break;
|
||||
}
|
||||
else if (magic != ZIP_FILEHEADER_MAGIC) {
|
||||
bb_error_msg_and_die("Invlaide zip magic");
|
||||
}
|
||||
|
||||
/* Read the file header */
|
||||
archive_xread_all(archive_handle, zip_header.raw, 26);
|
||||
archive_handle->offset += 26;
|
||||
archive_handle->file_header->mode = S_IFREG | 0777;
|
||||
|
||||
if (zip_header.formated.method != 8) {
|
||||
bb_error_msg_and_die("Unsupported compression method %d\n", zip_header.formated.method);
|
||||
}
|
||||
|
||||
/* Read filename */
|
||||
archive_handle->file_header->name = xmalloc(zip_header.formated.filename_len + 1);
|
||||
archive_xread_all(archive_handle, archive_handle->file_header->name, zip_header.formated.filename_len);
|
||||
archive_handle->offset += zip_header.formated.filename_len;
|
||||
archive_handle->file_header->name[zip_header.formated.filename_len] = '\0';
|
||||
|
||||
/* Skip extra header bits */
|
||||
archive_handle->file_header->size = zip_header.formated.extra_len;
|
||||
data_skip(archive_handle);
|
||||
archive_handle->offset += zip_header.formated.extra_len;
|
||||
|
||||
/* Handle directories */
|
||||
archive_handle->file_header->mode = S_IFREG | 0777;
|
||||
if (last_char_is(archive_handle->file_header->name, '/')) {
|
||||
archive_handle->file_header->mode ^= S_IFREG;
|
||||
archive_handle->file_header->mode |= S_IFDIR;
|
||||
}
|
||||
|
||||
/* Data section */
|
||||
archive_handle->file_header->size = zip_header.formated.cmpsize;
|
||||
if (archive_handle->action_data) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
} else {
|
||||
dst_fd = bb_xopen(archive_handle->file_header->name, O_WRONLY | O_CREAT);
|
||||
inflate(archive_handle->src_fd, dst_fd);
|
||||
close(dst_fd);
|
||||
chmod(archive_handle->file_header->name, archive_handle->file_header->mode);
|
||||
|
||||
/* Validate decompression - crc */
|
||||
if (zip_header.formated.crc32 != (gunzip_crc ^ 0xffffffffL)) {
|
||||
bb_error_msg("Invalid compressed data--crc error");
|
||||
}
|
||||
|
||||
/* Validate decompression - size */
|
||||
if (gunzip_bytes_out != zip_header.formated.ucmpsize) {
|
||||
bb_error_msg("Invalid compressed data--length error");
|
||||
}
|
||||
}
|
||||
|
||||
/* local file descriptor section */
|
||||
archive_handle->offset += zip_header.formated.cmpsize;
|
||||
/* This ISNT unix time */
|
||||
archive_handle->file_header->mtime = zip_header.formated.modtime | (zip_header.formated.moddate << 16);
|
||||
archive_handle->file_header->size = zip_header.formated.ucmpsize;
|
||||
total_size += archive_handle->file_header->size;
|
||||
total_entries++;
|
||||
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
|
||||
/* Data descriptor section */
|
||||
if (zip_header.formated.flags & 4) {
|
||||
/* skip over duplicate crc, compressed size and uncompressed size */
|
||||
unsigned short i;
|
||||
for (i = 0; i != 12; i++) {
|
||||
archive_xread_char(archive_handle);
|
||||
}
|
||||
archive_handle->offset += 12;
|
||||
}
|
||||
}
|
||||
/* Central directory section */
|
||||
|
||||
if (archive_handle->action_header == header_verbose_list_unzip) {
|
||||
printf(" -------- -------\n");
|
||||
printf("%9d %d files\n", total_size, total_entries);
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
menu "Console Utilities"
|
||||
|
||||
config CONFIG_CHVT
|
||||
bool "chvt"
|
||||
default n
|
||||
help
|
||||
This program is used to change to another terminal.
|
||||
Example: chvt 4 (change to terminal /dev/tty4)
|
||||
|
||||
config CONFIG_CLEAR
|
||||
bool "clear"
|
||||
default n
|
||||
help
|
||||
This program clears the terminal screen.
|
||||
|
||||
config CONFIG_DEALLOCVT
|
||||
bool "deallocvt"
|
||||
default n
|
||||
help
|
||||
This program deallocates unused virtual consoles.
|
||||
|
||||
config CONFIG_DUMPKMAP
|
||||
bool "dumpkmap"
|
||||
default n
|
||||
help
|
||||
This program dumps the kernel's keyboard translation table to
|
||||
stdout, in binary format. You can then use loadkmap to load it.
|
||||
|
||||
config CONFIG_LOADACM
|
||||
bool "loadacm"
|
||||
default n
|
||||
help
|
||||
This program loads an acm from standard input.
|
||||
|
||||
config CONFIG_LOADFONT
|
||||
bool "loadfont"
|
||||
default n
|
||||
help
|
||||
This program loads a console font from standard input.
|
||||
|
||||
config CONFIG_LOADKMAP
|
||||
bool "loadkmap"
|
||||
default n
|
||||
help
|
||||
This program loads a keyboard translation table from
|
||||
standard input.
|
||||
|
||||
config CONFIG_OPENVT
|
||||
bool "openvt"
|
||||
default n
|
||||
help
|
||||
This program is used to start a command on an unused
|
||||
virtual terminal.
|
||||
|
||||
config CONFIG_RESET
|
||||
bool "reset"
|
||||
default n
|
||||
help
|
||||
This program is used to reset the terminal screen, if it
|
||||
gets messed up.
|
||||
|
||||
config CONFIG_SETKEYCODES
|
||||
bool "setkeycodes"
|
||||
default n
|
||||
help
|
||||
This program loads entries into the kernel's scancode-to-keycode
|
||||
map, allowing unusual keyboards to generate usable keycodes.
|
||||
|
||||
endmenu
|
||||
+9
-22
@@ -1,6 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -17,27 +17,14 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR :=..
|
||||
L_TARGET := console-tools.a
|
||||
|
||||
obj-y :=
|
||||
obj-n :=
|
||||
obj- :=
|
||||
|
||||
obj-$(CONFIG_CHVT) += chvt.o
|
||||
obj-$(CONFIG_CLEAR) += clear.o
|
||||
obj-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
obj-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
obj-$(CONFIG_LOADACM) += loadacm.o
|
||||
obj-$(CONFIG_LOADFONT) += loadfont.o
|
||||
obj-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
obj-$(CONFIG_RESET) += reset.o
|
||||
obj-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
|
||||
|
||||
# Hand off to toplevel Rules.mak
|
||||
include $(TOPDIR)/Rules.mak
|
||||
TOPDIR:= ../
|
||||
CONSOLETOOLS_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
|
||||
clean:
|
||||
rm -f $(L_TARGET) *.o core
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
CONSOLETOOLS_AR:=console-tools.a
|
||||
ifndef $(CONSOLETOOLS_DIR)
|
||||
CONSOLETOOLS_DIR:=$(TOPDIR)console-tools/
|
||||
endif
|
||||
|
||||
CONSOLETOOLS_DIR-y:=
|
||||
CONSOLETOOLS_DIR-$(CONFIG_CHVT) += chvt.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_CLEAR) += clear.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_LOADACM) += loadacm.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_LOADFONT) += loadfont.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_OPENVT) += openvt.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_RESET) += reset.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
|
||||
libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
|
||||
|
||||
$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
|
||||
$(AR) -ro $@ $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
|
||||
|
||||
@@ -23,13 +23,13 @@ int chvt_main(int argc, char **argv)
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
bb_show_usage();
|
||||
fd = get_console_fd();
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
bb_perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
bb_perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
mainmenu_option next_comment
|
||||
comment 'Console Utilities'
|
||||
bool 'chvt' CONFIG_CHVT
|
||||
bool 'clear' CONFIG_CLEAR
|
||||
bool 'deallocvt' CONFIG_DEALLOCVT
|
||||
bool 'dumpkmap' CONFIG_DUMPKMAP
|
||||
bool 'loadacm' CONFIG_LOADACM
|
||||
bool 'loadfont' CONFIG_LOADFONT
|
||||
bool 'loadkmap' CONFIG_LOADKMAP
|
||||
bool 'reset' CONFIG_RESET
|
||||
bool 'setkeycodes' CONFIG_SETKEYCODES
|
||||
|
||||
endmenu
|
||||
+23
-20
@@ -15,29 +15,32 @@ static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
int fd, num, i;
|
||||
int fd, num=0;
|
||||
|
||||
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
|
||||
if (argc > 2)
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
fd = get_console_fd();
|
||||
|
||||
/* num=0 deallocate all unused consoles */
|
||||
if (argc == 1)
|
||||
goto disallocate_all;
|
||||
|
||||
if (argc == 1) {
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
error_msg("0: illegal VT number");
|
||||
else if (num == 1)
|
||||
error_msg("VT 1 cannot be deallocated");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
num=bb_xgetlarg(argv[1], 10, 0, INT_MAX);
|
||||
|
||||
switch(num)
|
||||
{
|
||||
case 0:
|
||||
bb_error_msg("0: illegal VT number");
|
||||
break;
|
||||
case 1:
|
||||
bb_error_msg("VT 1 cannot be deallocated");
|
||||
break;
|
||||
default:
|
||||
disallocate_all:
|
||||
if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
bb_perror_msg_and_die("VT_DISALLOCATE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -48,12 +48,12 @@ int dumpkmap_main(int argc, char **argv)
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd = open(CURRENT_VC, O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg("Error opening " CURRENT_VC);
|
||||
bb_perror_msg("Error opening " CURRENT_VC);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ int dumpkmap_main(int argc, char **argv)
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
|
||||
error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
bb_error_msg("ioctl returned: %m, %s, %s, %xqq", (char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
}
|
||||
else {
|
||||
write(1,(void*)&ke.kb_value,2);
|
||||
|
||||
+18
-18
@@ -34,16 +34,16 @@ int loadacm_main(int argc, char **argv)
|
||||
int fd;
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd = open(CURRENT_VC, O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
bb_perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
}
|
||||
|
||||
if (screen_map_load(fd, stdin)) {
|
||||
perror_msg_and_die("Error loading acm");
|
||||
bb_perror_msg_and_die("Error loading acm");
|
||||
}
|
||||
|
||||
write(fd, "\033(K", 3);
|
||||
@@ -60,7 +60,7 @@ static int screen_map_load(int fd, FILE * fp)
|
||||
int is_unicode;
|
||||
|
||||
if (fstat(fileno(fp), &stbuf))
|
||||
perror_msg_and_die("Cannot stat map file");
|
||||
bb_perror_msg_and_die("Cannot stat map file");
|
||||
|
||||
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
|
||||
if (!
|
||||
@@ -70,16 +70,16 @@ static int screen_map_load(int fd, FILE * fp)
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg_and_die("16bit screen-map MUST be a regular file.");
|
||||
bb_error_msg_and_die("16bit screen-map MUST be a regular file.");
|
||||
else
|
||||
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
|
||||
bb_perror_msg_and_die("fseek failed reading binary 16bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Cannot read [new] map from file");
|
||||
bb_perror_msg_and_die("Cannot read [new] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.");
|
||||
bb_error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ static 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_msg_and_die("PIO_UNISCRNMAP ioctl");
|
||||
bb_perror_msg_and_die("PIO_UNISCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -96,10 +96,10 @@ static int screen_map_load(int fd, FILE * fp)
|
||||
/* rewind... */
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file."),
|
||||
bb_error_msg("Assuming 8bit screen-map - MUST be a regular file."),
|
||||
exit(1);
|
||||
else
|
||||
perror_msg_and_die("fseek failed assuming 8bit screen-map");
|
||||
bb_perror_msg_and_die("fseek failed assuming 8bit screen-map");
|
||||
}
|
||||
|
||||
/* ... and try an old 8-bit screen-map */
|
||||
@@ -109,25 +109,25 @@ static int screen_map_load(int fd, FILE * fp)
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
/* should not - it succedeed above */
|
||||
error_msg_and_die("fseek() returned ESPIPE !");
|
||||
bb_error_msg_and_die("fseek() returned ESPIPE !");
|
||||
else
|
||||
perror_msg_and_die("fseek for binary 8bit screen-map");
|
||||
bb_perror_msg_and_die("fseek for binary 8bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Cannot read [old] map from file");
|
||||
bb_perror_msg_and_die("Cannot read [old] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.");
|
||||
bb_error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ioctl(fd, PIO_SCRNMAP, buf))
|
||||
perror_msg_and_die("PIO_SCRNMAP ioctl");
|
||||
bb_perror_msg_and_die("PIO_SCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
error_msg("Error parsing symbolic map");
|
||||
bb_error_msg("Error parsing symbolic map");
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ static int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
if (feof(fp))
|
||||
break;
|
||||
else
|
||||
perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
|
||||
bb_perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
|
||||
}
|
||||
|
||||
/* get "charset-relative charcode", stripping leading spaces */
|
||||
|
||||
+15
-15
@@ -44,11 +44,11 @@ extern int loadfont_main(int argc, char **argv)
|
||||
int fd;
|
||||
|
||||
if (argc != 1)
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
|
||||
fd = open(CURRENT_VC, O_RDWR);
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
bb_perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
loadnewfont(fd);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
@@ -62,7 +62,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32)
|
||||
error_msg_and_die("Bad character size %d", unit);
|
||||
bb_error_msg_and_die("Bad character size %d", unit);
|
||||
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
@@ -77,11 +77,11 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
|
||||
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
|
||||
return; /* success */
|
||||
perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
bb_perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
}
|
||||
#endif
|
||||
if (ioctl(fd, PIO_FONT, buf))
|
||||
perror_msg_and_die("PIO_FONT ioctl error");
|
||||
bb_perror_msg_and_die("PIO_FONT ioctl error");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -119,11 +119,11 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
#ifdef ENOIOCTLCMD
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
error_msg("It seems this kernel is older than 1.1.92");
|
||||
error_msg_and_die("No Unicode mapping table loaded.");
|
||||
bb_error_msg("It seems this kernel is older than 1.1.92");
|
||||
bb_error_msg_and_die("No Unicode mapping table loaded.");
|
||||
} else
|
||||
#endif
|
||||
perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
bb_perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
}
|
||||
ud.entry_ct = ct;
|
||||
ud.entries = up;
|
||||
@@ -133,7 +133,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
/* change advice parameters */
|
||||
}
|
||||
#endif
|
||||
perror_msg_and_die("PIO_UNIMAP");
|
||||
bb_perror_msg_and_die("PIO_UNIMAP");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,13 +150,13 @@ static void loadnewfont(int fd)
|
||||
*/
|
||||
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
|
||||
if (ferror(stdin))
|
||||
perror_msg_and_die("Error reading input font");
|
||||
bb_perror_msg_and_die("Error reading input font");
|
||||
/* use malloc/realloc in case of giant files;
|
||||
maybe these do not occur: 16kB for the font,
|
||||
and 16kB for the map leaves 32 unicode values
|
||||
for each font position */
|
||||
if (!feof(stdin))
|
||||
perror_msg_and_die("Font too large");
|
||||
bb_perror_msg_and_die("Font too large");
|
||||
|
||||
/* test for psf first */
|
||||
{
|
||||
@@ -174,11 +174,11 @@ static void loadnewfont(int fd)
|
||||
goto no_psf;
|
||||
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
error_msg_and_die("Unsupported psf file mode");
|
||||
bb_error_msg_and_die("Unsupported psf file mode");
|
||||
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
|
||||
#if !defined( PIO_FONTX ) || defined( __sparc__ )
|
||||
if (fontsize != 256)
|
||||
error_msg_and_die("Only fontsize 256 supported");
|
||||
bb_error_msg_and_die("Only fontsize 256 supported");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
@@ -186,7 +186,7 @@ static void loadnewfont(int fd)
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
error_msg_and_die("Input file: bad length");
|
||||
bb_error_msg_and_die("Input file: bad length");
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
@@ -201,7 +201,7 @@ static void loadnewfont(int fd)
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377)
|
||||
error_msg_and_die("Bad input file size");
|
||||
bb_error_msg_and_die("Bad input file size");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
|
||||
@@ -51,18 +51,18 @@ int loadkmap_main(int argc, char **argv)
|
||||
char flags[MAX_NR_KEYMAPS], buff[7];
|
||||
|
||||
if (argc != 1)
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
|
||||
fd = open(CURRENT_VC, O_RDWR);
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
bb_perror_msg_and_die("Error opening " CURRENT_VC);
|
||||
|
||||
read(0, buff, 7);
|
||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
error_msg_and_die("This is not a valid binary keymap.");
|
||||
bb_error_msg_and_die("This is not a valid binary keymap.");
|
||||
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
|
||||
perror_msg_and_die("Error reading keymap flags");
|
||||
bb_perror_msg_and_die("Error reading keymap flags");
|
||||
|
||||
ibuff = (u_short *) xmalloc(ibuffsz);
|
||||
|
||||
@@ -71,7 +71,7 @@ int loadkmap_main(int argc, char **argv)
|
||||
pos = 0;
|
||||
while (pos < ibuffsz) {
|
||||
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
|
||||
perror_msg_and_die("Error reading keymap");
|
||||
bb_perror_msg_and_die("Error reading keymap");
|
||||
pos += readsz;
|
||||
}
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* openvt.c - open a vt to run a command.
|
||||
*
|
||||
* busyboxed by Quy Tonthat <quy@signal3.com>
|
||||
* hacked by Tito <farmatito@tiscali.it>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#define VTNAME "/dev/tty%d"
|
||||
|
||||
int openvt_main(int argc, char **argv)
|
||||
{
|
||||
int pid;
|
||||
int fd;
|
||||
int vtno;
|
||||
char vtname[sizeof VTNAME + 2];
|
||||
|
||||
|
||||
if (argc < 3)
|
||||
bb_show_usage();
|
||||
|
||||
if (!isdigit(argv[1][0]))
|
||||
bb_show_usage();
|
||||
|
||||
vtno = (int) atol(argv[1]);
|
||||
|
||||
/* if (vtno <= 0 || vtno > 63) */
|
||||
if (vtno <= 0 || vtno > 12)
|
||||
bb_error_msg_and_die("Illegal vt number (%d)", vtno);
|
||||
|
||||
sprintf(vtname, VTNAME, vtno);
|
||||
|
||||
argv+=2;
|
||||
argc-=2;
|
||||
|
||||
if((pid = fork()) == 0) {
|
||||
/* leave current vt */
|
||||
|
||||
#ifdef ESIX_5_3_2_D
|
||||
if (setpgrp() < 0) {
|
||||
#else
|
||||
if (setsid() < 0) {
|
||||
#endif
|
||||
|
||||
bb_perror_msg_and_die("Unable to set new session");
|
||||
}
|
||||
close(0); /* so that new vt becomes stdin */
|
||||
|
||||
/* and grab new one */
|
||||
if ((fd = open(vtname, O_RDWR)) == -1)
|
||||
bb_perror_msg_and_die("could not open %s", vtname);
|
||||
|
||||
/* Reassign stdout and sterr */
|
||||
close(1);
|
||||
close(2);
|
||||
dup(fd);
|
||||
dup(fd);
|
||||
|
||||
execvp(argv[0], argv);
|
||||
_exit(1);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -28,7 +27,7 @@
|
||||
|
||||
extern int reset_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033c");
|
||||
printf("\033[?25h\033c\033[J");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 1994-1998 Andries E. Brouwer <aeb@cwi.nl>
|
||||
*
|
||||
* Adjusted for BusyBox by Erik Andersen <andersee@debian.org>
|
||||
* Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -43,27 +43,27 @@ setkeycodes_main(int argc, char** argv)
|
||||
struct kbkeycode a;
|
||||
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
fd = get_console_fd();
|
||||
|
||||
while (argc > 2) {
|
||||
a.keycode = atoi(argv[2]);
|
||||
a.scancode = sc = strtol(argv[1], &ep, 16);
|
||||
if (*ep) {
|
||||
error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
|
||||
bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
|
||||
}
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
}
|
||||
if (a.scancode > 255 || a.keycode > 127) {
|
||||
error_msg_and_die("SCANCODE or KEYCODE outside bounds");
|
||||
bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds");
|
||||
}
|
||||
if (ioctl(fd,KDSETKEYCODE,&a)) {
|
||||
perror("KDSETKEYCODE");
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
|
||||
bb_error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
@@ -0,0 +1,602 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
menu "Coreutils"
|
||||
|
||||
config CONFIG_BASENAME
|
||||
bool "basename"
|
||||
default n
|
||||
help
|
||||
basename is used to strip the directory and suffix from filenames,
|
||||
leaving just the filename itself. Enable this option if you wish
|
||||
to enable the 'basename' utility.
|
||||
|
||||
config CONFIG_CAL
|
||||
bool "cal"
|
||||
default n
|
||||
help
|
||||
cal is used to display a montly calender.
|
||||
|
||||
config CONFIG_CAT
|
||||
bool "cat"
|
||||
default n
|
||||
help
|
||||
cat is used to concatenate files and print them to the standard
|
||||
output. Enable this option if you wish to enable the 'cat' utility.
|
||||
|
||||
config CONFIG_CHGRP
|
||||
bool "chgrp"
|
||||
default n
|
||||
help
|
||||
chgrp is used to change the group owership of files.
|
||||
|
||||
config CONFIG_CHMOD
|
||||
bool "chmod"
|
||||
default n
|
||||
help
|
||||
chmod is used to change the access permission of files.
|
||||
|
||||
config CONFIG_CHOWN
|
||||
bool "chown"
|
||||
default n
|
||||
help
|
||||
chown is used too change the user and/or group ownership
|
||||
of files.
|
||||
|
||||
config CONFIG_CHROOT
|
||||
bool "chroot"
|
||||
default n
|
||||
help
|
||||
chroot is used to change the root directory and run a command.
|
||||
The default command is `/bin/sh'.
|
||||
|
||||
config CONFIG_CMP
|
||||
bool "cmp"
|
||||
default n
|
||||
help
|
||||
cmp is used to compare two files and returns the result
|
||||
to standard output.
|
||||
|
||||
config CONFIG_CP
|
||||
bool "cp"
|
||||
default n
|
||||
help
|
||||
cp is used to copy files and directories.
|
||||
|
||||
config CONFIG_CUT
|
||||
bool "cut"
|
||||
default n
|
||||
help
|
||||
cut is used to print selected parts of lines from
|
||||
each file to stdout.
|
||||
|
||||
if CONFIG_WATCH
|
||||
config CONFIG_DATE
|
||||
default y
|
||||
comment "date (forced enabled for use with watch)"
|
||||
endif
|
||||
|
||||
if !CONFIG_WATCH
|
||||
config CONFIG_DATE
|
||||
bool "date"
|
||||
default n
|
||||
help
|
||||
date is used to set the system date or display the
|
||||
current time in the given format.
|
||||
endif
|
||||
|
||||
config CONFIG_FEATURE_DATE_ISOFMT
|
||||
bool " Enable ISO date format output (-I)"
|
||||
default y
|
||||
depends on CONFIG_DATE
|
||||
help
|
||||
Enable option (-I) to output an ISO-8601 compliant
|
||||
date/time string.
|
||||
|
||||
config CONFIG_DD
|
||||
bool "dd"
|
||||
default n
|
||||
help
|
||||
dd copies a file (from standard input to standard output,
|
||||
by default) using specific input and output blocksizes,
|
||||
while optionally performing conversions on it.
|
||||
|
||||
config CONFIG_DF
|
||||
bool "df"
|
||||
default n
|
||||
help
|
||||
df reports the amount of disk space used and available
|
||||
on filesystems.
|
||||
|
||||
config CONFIG_DIRNAME
|
||||
bool "dirname"
|
||||
default n
|
||||
help
|
||||
dirname is used to strip a non directory suffix from
|
||||
a file name.
|
||||
|
||||
config CONFIG_DOS2UNIX
|
||||
bool "dos2unix/unix2dos"
|
||||
default n
|
||||
help
|
||||
dos2unix is uses to convert a text file from DOS format to
|
||||
UNIX format, and vice versa.
|
||||
|
||||
config CONFIG_UNIX2DOS
|
||||
bool
|
||||
default y
|
||||
depends on CONFIG_DOS2UNIX
|
||||
|
||||
config CONFIG_DU
|
||||
bool "du (default blocksize of 512 bytes)"
|
||||
default n
|
||||
help
|
||||
du is used to report the amount of disk space used
|
||||
for specified files.
|
||||
|
||||
config CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
|
||||
bool " Use a default blocksize of 1024 bytes (1K)"
|
||||
default y
|
||||
depends on CONFIG_DU
|
||||
help
|
||||
Use a blocksize of (1K) instead of the default 512b.
|
||||
|
||||
config CONFIG_ECHO
|
||||
bool "echo (basic SUSv3 version taking no options"
|
||||
default n
|
||||
help
|
||||
echo is used to print a specified string to stdout.
|
||||
|
||||
config CONFIG_FEATURE_FANCY_ECHO
|
||||
bool " Enable echo options (-n and -e)"
|
||||
default y
|
||||
depends on CONFIG_ECHO
|
||||
help
|
||||
This adds options (-n and -e) to echo.
|
||||
|
||||
config CONFIG_ENV
|
||||
bool "env"
|
||||
default n
|
||||
help
|
||||
env is used to set an environment variable and run
|
||||
a command, without options it displays the current
|
||||
environment.
|
||||
|
||||
config CONFIG_EXPR
|
||||
bool "expr"
|
||||
default n
|
||||
help
|
||||
expr is used to calculate numbers and print the result
|
||||
to standard output.
|
||||
|
||||
if CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
|
||||
config CONFIG_FALSE
|
||||
default y
|
||||
comment "false (forced enabled for use with shell)"
|
||||
endif
|
||||
|
||||
if !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
|
||||
config CONFIG_FALSE
|
||||
bool "false"
|
||||
default n
|
||||
help
|
||||
false returns an exit code of FALSE (1).
|
||||
endif
|
||||
|
||||
config CONFIG_FOLD
|
||||
bool "fold"
|
||||
default n
|
||||
help
|
||||
Wrap text to fit a specific width.
|
||||
|
||||
config CONFIG_HEAD
|
||||
bool "head"
|
||||
default n
|
||||
help
|
||||
head is used to print the first specified number of lines
|
||||
from files.
|
||||
|
||||
config CONFIG_FEATURE_FANCY_HEAD
|
||||
bool " Enable head options (-c, -q, and -v)"
|
||||
default n
|
||||
depends on CONFIG_HEAD
|
||||
help
|
||||
This enables the head options (-c, -q, and -v).
|
||||
|
||||
config CONFIG_HOSTID
|
||||
bool "hostid"
|
||||
default n
|
||||
help
|
||||
hostid prints the numeric identifier (in hexadecimal) for
|
||||
the current host.
|
||||
|
||||
config CONFIG_ID
|
||||
bool "id"
|
||||
default n
|
||||
help
|
||||
id displays the current user and group ID names.
|
||||
|
||||
config CONFIG_LENGTH
|
||||
bool "length"
|
||||
default n
|
||||
help
|
||||
length is used to print out the length of a specified string.
|
||||
|
||||
config CONFIG_LN
|
||||
bool "ln"
|
||||
default n
|
||||
help
|
||||
ln is used to create hard or soft links between files.
|
||||
|
||||
config CONFIG_LOGNAME
|
||||
bool "logname"
|
||||
default n
|
||||
help
|
||||
logname is used to print the current user's login name.
|
||||
|
||||
config CONFIG_LS
|
||||
bool "ls"
|
||||
default n
|
||||
help
|
||||
ls is used to list the contents of directories.
|
||||
|
||||
config CONFIG_FEATURE_LS_FILETYPES
|
||||
bool " Enable filetyping options (-p and -F)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Enable the ls options (-p and -F).
|
||||
|
||||
config CONFIG_FEATURE_LS_FOLLOWLINKS
|
||||
bool " Enable symlinks dereferencing (-L)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Enable the ls option (-L).
|
||||
|
||||
config CONFIG_FEATURE_LS_RECURSIVE
|
||||
bool " Enable recursion (-R)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Enable the ls option (-R).
|
||||
|
||||
config CONFIG_FEATURE_LS_SORTFILES
|
||||
bool " Sort the file names"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Allow ls to sort file names alphabetically.
|
||||
|
||||
config CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
bool " Show file timestamps"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Allow ls to display timestamps for files.
|
||||
|
||||
config CONFIG_FEATURE_LS_USERNAME
|
||||
bool " Show username/groupnames"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Allow ls to display username/groupname for files.
|
||||
|
||||
config CONFIG_FEATURE_LS_COLOR
|
||||
bool " Use color to identify file types"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Allow ls to use color when displaying files.
|
||||
|
||||
config CONFIG_MD5SUM
|
||||
bool "md5sum"
|
||||
default n
|
||||
help
|
||||
md5sum is used to print or check MD5 checksums.
|
||||
|
||||
config CONFIG_MKDIR
|
||||
bool "mkdir"
|
||||
default n
|
||||
help
|
||||
mkdir is used to create directories with the specified names.
|
||||
|
||||
config CONFIG_MKFIFO
|
||||
bool "mkfifo"
|
||||
default n
|
||||
help
|
||||
mkfifo is used to create FIFOs (named pipes).
|
||||
The `mknod' program can also create FIFOs.
|
||||
|
||||
config CONFIG_MKNOD
|
||||
bool "mknod"
|
||||
default n
|
||||
help
|
||||
mknod is used to create FIFOs or block/character special
|
||||
files with the specified names.
|
||||
|
||||
config CONFIG_MV
|
||||
bool "mv"
|
||||
default n
|
||||
help
|
||||
mv is used to move or rename files or directories.
|
||||
|
||||
config CONFIG_OD
|
||||
bool "od"
|
||||
default n
|
||||
help
|
||||
od is used to dump binary files in octal and other formats.
|
||||
|
||||
config CONFIG_PRINTF
|
||||
bool "printf"
|
||||
default n
|
||||
help
|
||||
printf is used to format and print specified strings.
|
||||
It's similar to `echo' except it has more options.
|
||||
|
||||
config CONFIG_PWD
|
||||
bool "pwd"
|
||||
default n
|
||||
help
|
||||
pwd is used to print the current directory.
|
||||
|
||||
config CONFIG_REALPATH
|
||||
bool "realpath"
|
||||
default n
|
||||
help
|
||||
Return the canonicalized absolute pathname.
|
||||
This isnt provided by GNU shellutils, but where else does it belong.
|
||||
|
||||
config CONFIG_RM
|
||||
bool "rm"
|
||||
default n
|
||||
help
|
||||
rm is used to remove files or directories.
|
||||
|
||||
config CONFIG_RMDIR
|
||||
bool "rmdir"
|
||||
default n
|
||||
help
|
||||
rmdir is used to remove empty directories.
|
||||
|
||||
config CONFIG_SHA1SUM
|
||||
bool "sha1sum"
|
||||
default n
|
||||
help
|
||||
Compute and check SHA1 message digest
|
||||
|
||||
config CONFIG_FEATURE_SHA1SUM_CHECK
|
||||
bool " Enale -c and -w options"
|
||||
default n
|
||||
help
|
||||
Enabling the -c and -w options allow files to be checked
|
||||
against pre-calculated hash values.
|
||||
|
||||
config CONFIG_SLEEP
|
||||
bool "sleep (single integer arg with no suffix)"
|
||||
default n
|
||||
help
|
||||
sleep is used to pause for a specified number of seconds,
|
||||
|
||||
config CONFIG_FEATURE_FANCY_SLEEP
|
||||
bool " Enable multiple integer args and optional time suffixes"
|
||||
default n
|
||||
depends on CONFIG_SLEEP
|
||||
help
|
||||
Allow sleep to pause for specified minutes, hours, and days.
|
||||
|
||||
config CONFIG_SORT
|
||||
bool "sort"
|
||||
default n
|
||||
help
|
||||
sort is used to sort lines of text in specified files.
|
||||
|
||||
config CONFIG_FEATURE_SORT_REVERSE
|
||||
bool " Enable reverse sort"
|
||||
default y
|
||||
depends on CONFIG_SORT
|
||||
help
|
||||
Enable the `-r' option that allows sort to sort lines of
|
||||
text in reverse.
|
||||
|
||||
config CONFIG_FEATURE_SORT_UNIQUE
|
||||
bool " Enable unique sort"
|
||||
default y
|
||||
depends on CONFIG_SORT
|
||||
help
|
||||
Enable the `-u' option that allows sort to only sort lines
|
||||
that are uniq.
|
||||
|
||||
config CONFIG_STTY
|
||||
bool "stty"
|
||||
default n
|
||||
help
|
||||
stty is used to change and print terminal line settings.
|
||||
|
||||
config CONFIG_SYNC
|
||||
bool "sync"
|
||||
default n
|
||||
help
|
||||
sync is used to flush filesystem buffers.
|
||||
|
||||
config CONFIG_TAIL
|
||||
bool "tail"
|
||||
default n
|
||||
help
|
||||
tail is used to print the last specified number of lines
|
||||
from files.
|
||||
|
||||
config CONFIG_FEATURE_FANCY_TAIL
|
||||
bool " Enable extra tail options (-c, -q, -s, and -v)"
|
||||
default y
|
||||
depends on CONFIG_TAIL
|
||||
help
|
||||
Enable tail options (-c, -q, -s, and -v).
|
||||
|
||||
config CONFIG_TEE
|
||||
bool "tee"
|
||||
default n
|
||||
help
|
||||
tee is used to read from standard input and write
|
||||
to standard output and files.
|
||||
|
||||
config CONFIG_FEATURE_TEE_USE_BLOCK_IO
|
||||
bool " Enable block i/o (larger/faster) instead of byte i/o."
|
||||
default n
|
||||
depends on CONFIG_TEE
|
||||
help
|
||||
Enable this option for a faster tee, at expense of size.
|
||||
|
||||
if CONFIG_ASH || CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
|
||||
config CONFIG_TEST
|
||||
default y
|
||||
comment "test (forced enabled for use with shell)"
|
||||
endif
|
||||
|
||||
if !CONFIG_ASH && !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
|
||||
config CONFIG_TEST
|
||||
bool "test"
|
||||
default n
|
||||
help
|
||||
test is used to check file types and compare values,
|
||||
returning an appropriate exit code. The shells (ash
|
||||
and bash have test builtin).
|
||||
endif
|
||||
|
||||
config CONFIG_TOUCH
|
||||
bool "touch"
|
||||
default n
|
||||
help
|
||||
touch is used to create or change the access and/or
|
||||
modification timestamp of specified files.
|
||||
|
||||
config CONFIG_TR
|
||||
bool "tr"
|
||||
default n
|
||||
help
|
||||
tr is used to squeeze, and/or delete characters from standard
|
||||
input, writing to standard output.
|
||||
|
||||
if CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
|
||||
config CONFIG_TRUE
|
||||
default y
|
||||
comment "true (forced enabled for use with shell)"
|
||||
endif
|
||||
|
||||
if !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
|
||||
config CONFIG_TRUE
|
||||
bool "true"
|
||||
default n
|
||||
help
|
||||
true returns an exit code of TRUE (0).
|
||||
|
||||
endif
|
||||
|
||||
config CONFIG_TTY
|
||||
bool "tty"
|
||||
default n
|
||||
help
|
||||
tty is used to print the name of the current terminal to
|
||||
standard output.
|
||||
|
||||
config CONFIG_UNAME
|
||||
bool "uname"
|
||||
default n
|
||||
help
|
||||
uname is used to print system information.
|
||||
|
||||
config CONFIG_UNIQ
|
||||
bool "uniq"
|
||||
default n
|
||||
help
|
||||
uniq is used to remove duplicate lines from a sorted file.
|
||||
|
||||
config CONFIG_USLEEP
|
||||
bool "usleep"
|
||||
default n
|
||||
help
|
||||
usleep is used to pause for a specified number of microseconds.
|
||||
|
||||
config CONFIG_UUDECODE
|
||||
bool "uudecode"
|
||||
default n
|
||||
help
|
||||
uudecode is used to decode a uuencoded file.
|
||||
|
||||
config CONFIG_UUENCODE
|
||||
bool "uuencode"
|
||||
default n
|
||||
help
|
||||
uuencode is used to uuencode a file.
|
||||
|
||||
config CONFIG_WATCH
|
||||
bool "watch"
|
||||
default n
|
||||
help
|
||||
watch is used to execute a program periodically, showing
|
||||
output to the screen.
|
||||
|
||||
config CONFIG_WC
|
||||
bool "wc"
|
||||
default n
|
||||
help
|
||||
wc is used to print the number of bytes, words, and lines,
|
||||
in specified files.
|
||||
|
||||
config CONFIG_WHO
|
||||
bool "who"
|
||||
default n
|
||||
help
|
||||
who is used to show who is logged on.
|
||||
|
||||
config CONFIG_WHOAMI
|
||||
bool "whoami"
|
||||
default n
|
||||
help
|
||||
whoami is used to print the username of the current
|
||||
user id (same as id -un).
|
||||
|
||||
config CONFIG_YES
|
||||
bool "yes"
|
||||
default n
|
||||
help
|
||||
yes is used to repeatedly output a specific string, or
|
||||
the default string `y'.
|
||||
|
||||
comment "Common options for cp and mv"
|
||||
depends on CONFIG_CP || CONFIG_MV
|
||||
|
||||
config CONFIG_FEATURE_PRESERVE_HARDLINKS
|
||||
bool " Preserve hard links"
|
||||
default n
|
||||
depends on CONFIG_CP || CONFIG_MV
|
||||
help
|
||||
Allow cp and mv to preserve hard links.
|
||||
|
||||
comment "Common options for ls and more"
|
||||
depends on CONFIG_LS || CONFIG_MORE
|
||||
|
||||
config CONFIG_FEATURE_AUTOWIDTH
|
||||
bool " Calculate terminal & column widths"
|
||||
default y
|
||||
depends on CONFIG_LS || CONFIG_MORE
|
||||
help
|
||||
This option allows utilities such as 'ls' and 'more' to determine the
|
||||
width of the screen, which can allow them to display additional text
|
||||
or avoid wrapping text onto the next line. If you leave this
|
||||
disabled, your utilities will be especially primitive and will be
|
||||
unable to determine the current screen width.
|
||||
|
||||
comment "Common options for df, du, ls"
|
||||
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
|
||||
|
||||
config CONFIG_FEATURE_HUMAN_READABLE
|
||||
bool " Support for human readable output (example 13k, 23M, 235G)"
|
||||
default n
|
||||
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
|
||||
help
|
||||
Allow df, du, and ls to have human readable output.
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,30 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
TOPDIR:= ../
|
||||
SHELLUTILS_DIR:=./
|
||||
include $(TOPDIR).config
|
||||
include $(TOPDIR)Rules.mak
|
||||
include Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(TOPDIR).depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
COREUTILS_AR:=coreutils.a
|
||||
ifndef $(COREUTILS_DIR)
|
||||
COREUTILS_DIR:=$(TOPDIR)coreutils/
|
||||
endif
|
||||
|
||||
COREUTILS-y:=
|
||||
COREUTILS-$(CONFIG_BASENAME) += basename.o
|
||||
COREUTILS-$(CONFIG_CAL) += cal.o
|
||||
COREUTILS-$(CONFIG_CAT) += cat.o
|
||||
COREUTILS-$(CONFIG_CHGRP) += chgrp.o
|
||||
COREUTILS-$(CONFIG_CHMOD) += chmod.o
|
||||
COREUTILS-$(CONFIG_CHOWN) += chown.o
|
||||
COREUTILS-$(CONFIG_CHROOT) += chroot.o
|
||||
COREUTILS-$(CONFIG_CMP) += cmp.o
|
||||
COREUTILS-$(CONFIG_CP) += cp.o
|
||||
COREUTILS-$(CONFIG_CUT) += cut.o
|
||||
COREUTILS-$(CONFIG_DATE) += date.o
|
||||
COREUTILS-$(CONFIG_DD) += dd.o
|
||||
COREUTILS-$(CONFIG_DF) += df.o
|
||||
COREUTILS-$(CONFIG_DIRNAME) += dirname.o
|
||||
COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
|
||||
COREUTILS-$(CONFIG_DU) += du.o
|
||||
COREUTILS-$(CONFIG_ECHO) += echo.o
|
||||
COREUTILS-$(CONFIG_ENV) += env.o
|
||||
COREUTILS-$(CONFIG_EXPR) += expr.o
|
||||
COREUTILS-$(CONFIG_FALSE) += false.o
|
||||
COREUTILS-$(CONFIG_FOLD) += fold.o
|
||||
COREUTILS-$(CONFIG_HEAD) += head.o
|
||||
COREUTILS-$(CONFIG_HOSTID) += hostid.o
|
||||
COREUTILS-$(CONFIG_ID) += id.o
|
||||
COREUTILS-$(CONFIG_LENGTH) += length.o
|
||||
COREUTILS-$(CONFIG_LN) += ln.o
|
||||
COREUTILS-$(CONFIG_LOGNAME) += logname.o
|
||||
COREUTILS-$(CONFIG_LS) += ls.o
|
||||
COREUTILS-$(CONFIG_MD5SUM) += md5sum.o
|
||||
COREUTILS-$(CONFIG_MKDIR) += mkdir.o
|
||||
COREUTILS-$(CONFIG_MKFIFO) += mkfifo.o
|
||||
COREUTILS-$(CONFIG_MKNOD) += mknod.o
|
||||
COREUTILS-$(CONFIG_MV) += mv.o
|
||||
COREUTILS-$(CONFIG_OD) += od.o
|
||||
COREUTILS-$(CONFIG_PRINTF) += printf.o
|
||||
COREUTILS-$(CONFIG_PWD) += pwd.o
|
||||
COREUTILS-$(CONFIG_REALPATH) += realpath.o
|
||||
COREUTILS-$(CONFIG_RM) += rm.o
|
||||
COREUTILS-$(CONFIG_RMDIR) += rmdir.o
|
||||
COREUTILS-$(CONFIG_SHA1SUM) += sha1sum.o
|
||||
COREUTILS-$(CONFIG_SLEEP) += sleep.o
|
||||
COREUTILS-$(CONFIG_SORT) += sort.o
|
||||
COREUTILS-$(CONFIG_STTY) += stty.o
|
||||
COREUTILS-$(CONFIG_SYNC) += sync.o
|
||||
COREUTILS-$(CONFIG_TAIL) += tail.o
|
||||
COREUTILS-$(CONFIG_TEE) += tee.o
|
||||
COREUTILS-$(CONFIG_TEST) += test.o
|
||||
COREUTILS-$(CONFIG_TOUCH) += touch.o
|
||||
COREUTILS-$(CONFIG_TR) += tr.o
|
||||
COREUTILS-$(CONFIG_TRUE) += true.o
|
||||
COREUTILS-$(CONFIG_TTY) += tty.o
|
||||
COREUTILS-$(CONFIG_UNAME) += uname.o
|
||||
COREUTILS-$(CONFIG_UNIQ) += uniq.o
|
||||
COREUTILS-$(CONFIG_USLEEP) += usleep.o
|
||||
COREUTILS-$(CONFIG_UUDECODE) += uudecode.o
|
||||
COREUTILS-$(CONFIG_UUENCODE) += uuencode.o
|
||||
COREUTILS-$(CONFIG_WATCH) += watch.o
|
||||
COREUTILS-$(CONFIG_WC) += wc.o
|
||||
COREUTILS-$(CONFIG_WHO) += who.o
|
||||
COREUTILS-$(CONFIG_WHOAMI) += whoami.o
|
||||
COREUTILS-$(CONFIG_YES) += yes.o
|
||||
|
||||
libraries-y+=$(COREUTILS_DIR)$(COREUTILS_AR)
|
||||
|
||||
$(COREUTILS_DIR)$(COREUTILS_AR): $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
|
||||
$(AR) -ro $@ $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
|
||||
|
||||
+24
-14
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,32 +20,43 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */
|
||||
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Changes:
|
||||
* 1) Now checks for too many args. Need at least one and at most two.
|
||||
* 2) Don't check for options, as per SUSv3.
|
||||
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
int m, n;
|
||||
size_t m, n;
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
if (((unsigned int)(argc-2)) >= 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
s = bb_get_last_path_component(*++argv);
|
||||
|
||||
s = get_last_path_component(*argv);
|
||||
|
||||
if (argc>2) {
|
||||
argv++;
|
||||
if (*++argv) {
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if (m>n && strncmp(s+m-n, *argv, n)==0)
|
||||
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
puts(s);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
+392
@@ -0,0 +1,392 @@
|
||||
/* NOTE:
|
||||
*
|
||||
* Apparently, all "Steven J. Merrifield" did was grab the util-linux cal applet,
|
||||
* spend maybe 5 minutes integrating it into busybox, slapped a copyright on it,
|
||||
* and submitted it. I certainly saw no evidence of any attempt at size reduction.
|
||||
* Not only do I consider his copyright below meaningless, I also consider his
|
||||
* actions shameful.
|
||||
*
|
||||
* Manuel Novoa III (mjn3@codepoet.org)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Calendar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2001 by Steven J. Merrifield <steve@labyrinth.net.au>
|
||||
*
|
||||
* See original copyright at the end of this file
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant with -j and -y extensions (from util-linux). */
|
||||
/* BB_AUDIT BUG: The output of 'cal -j 1752' is incorrect. The upstream
|
||||
* BB_AUDIT BUG: version in util-linux seems to be broken as well. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cal.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Major size reduction... over 50% (>1.5k) on i386.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#define THURSDAY 4 /* for reformation */
|
||||
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
|
||||
|
||||
#define FIRST_MISSING_DAY 639787 /* 3 Sep 1752 */
|
||||
#define NUMBER_MISSING_DAYS 11 /* 11 day correction */
|
||||
|
||||
#define MAXDAYS 42 /* max slots in a month array */
|
||||
#define SPACE -1 /* used in day array */
|
||||
|
||||
static const char days_in_month[] = {
|
||||
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
|
||||
};
|
||||
|
||||
static const char sep1752[] = {
|
||||
1, 2, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30
|
||||
};
|
||||
|
||||
static int julian;
|
||||
|
||||
/* leap year -- account for gregorian reformation in 1752 */
|
||||
#define leap_year(yr) \
|
||||
((yr) <= 1752 ? !((yr) % 4) : \
|
||||
(!((yr) % 4) && ((yr) % 100)) || !((yr) % 400))
|
||||
|
||||
static int is_leap_year(int year)
|
||||
{
|
||||
return leap_year(year);
|
||||
}
|
||||
#undef leap_year
|
||||
#define leap_year(yr) is_leap_year(yr)
|
||||
|
||||
/* number of centuries since 1700, not inclusive */
|
||||
#define centuries_since_1700(yr) \
|
||||
((yr) > 1700 ? (yr) / 100 - 17 : 0)
|
||||
|
||||
/* number of centuries since 1700 whose modulo of 400 is 0 */
|
||||
#define quad_centuries_since_1700(yr) \
|
||||
((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
|
||||
|
||||
/* number of leap years between year 1 and this year, not inclusive */
|
||||
#define leap_years_since_year_1(yr) \
|
||||
((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
|
||||
|
||||
static void center __P((char *, int, int));
|
||||
static void day_array __P((int, int, int *));
|
||||
static void trim_trailing_spaces_and_print __P((char *));
|
||||
|
||||
static void blank_string(char *buf, size_t buflen);
|
||||
static char *build_row(char *p, int *dp);
|
||||
|
||||
#define DAY_LEN 3 /* 3 spaces per day */
|
||||
#define J_DAY_LEN (DAY_LEN + 1)
|
||||
#define WEEK_LEN 20 /* 7 * 3 - one space at the end */
|
||||
#define J_WEEK_LEN (WEEK_LEN + 7)
|
||||
#define HEAD_SEP 2 /* spaces between day headings */
|
||||
|
||||
int cal_main(int argc, char **argv)
|
||||
{
|
||||
struct tm *local_time;
|
||||
struct tm zero_tm;
|
||||
time_t now;
|
||||
int month, year, flags, i;
|
||||
char *month_names[12];
|
||||
char day_headings[28]; /* 28 for julian, 21 for nonjulian */
|
||||
char buf[40];
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
setlocale(LC_TIME, "");
|
||||
#endif
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "jy");
|
||||
|
||||
julian = flags & 1;
|
||||
|
||||
argv += optind;
|
||||
|
||||
month = 0;
|
||||
|
||||
if ((argc -= optind) > 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (!argc) {
|
||||
time(&now);
|
||||
local_time = localtime(&now);
|
||||
year = local_time->tm_year + 1900;
|
||||
if (!(flags & 2)) {
|
||||
month = local_time->tm_mon + 1;
|
||||
}
|
||||
} else {
|
||||
if (argc == 2) {
|
||||
month = bb_xgetularg10_bnd(*argv++, 1, 12);
|
||||
}
|
||||
year = bb_xgetularg10_bnd(*argv, 1, 9999);
|
||||
}
|
||||
|
||||
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
|
||||
|
||||
i = 0;
|
||||
do {
|
||||
zero_tm.tm_mon = i;
|
||||
strftime(buf, sizeof(buf), "%B", &zero_tm);
|
||||
month_names[i] = bb_xstrdup(buf);
|
||||
|
||||
if (i < 7) {
|
||||
zero_tm.tm_wday = i;
|
||||
strftime(buf, sizeof(buf), "%a", &zero_tm);
|
||||
strncpy(day_headings + i * (3+julian) + julian, buf, 2);
|
||||
}
|
||||
} while (++i < 12);
|
||||
|
||||
if (month) {
|
||||
int row, len, days[MAXDAYS];
|
||||
int *dp = days;
|
||||
char lineout[30];
|
||||
|
||||
day_array(month, year, dp);
|
||||
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
|
||||
bb_printf("%*s%s\n%s\n",
|
||||
((7*julian + WEEK_LEN) - len) / 2, "",
|
||||
lineout, day_headings);
|
||||
for (row = 0; row < 6; row++) {
|
||||
build_row(lineout, dp)[0] = '\0';
|
||||
dp += 7;
|
||||
trim_trailing_spaces_and_print(lineout);
|
||||
}
|
||||
} else {
|
||||
int row, which_cal, week_len, days[12][MAXDAYS];
|
||||
int *dp;
|
||||
char lineout[80];
|
||||
|
||||
sprintf(lineout, "%d", year);
|
||||
center(lineout,
|
||||
(WEEK_LEN * 3 + HEAD_SEP * 2)
|
||||
+ julian * (J_WEEK_LEN * 2 + HEAD_SEP
|
||||
- (WEEK_LEN * 3 + HEAD_SEP * 2)),
|
||||
0);
|
||||
puts("\n"); /* two \n's */
|
||||
for (i = 0; i < 12; i++) {
|
||||
day_array(i + 1, year, days[i]);
|
||||
}
|
||||
blank_string(lineout, sizeof(lineout));
|
||||
week_len = WEEK_LEN + julian * (J_WEEK_LEN - WEEK_LEN);
|
||||
for (month = 0; month < 12; month += 3-julian) {
|
||||
center(month_names[month], week_len, HEAD_SEP);
|
||||
if (!julian) {
|
||||
center(month_names[month + 1], week_len, HEAD_SEP);
|
||||
}
|
||||
center(month_names[month + 2 - julian], week_len, 0);
|
||||
bb_printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
|
||||
if (!julian) {
|
||||
bb_printf("%*s%s", HEAD_SEP, "", day_headings);
|
||||
}
|
||||
putchar('\n');
|
||||
for (row = 0; row < (6*7); row += 7) {
|
||||
for (which_cal = 0; which_cal < 3-julian; which_cal++) {
|
||||
dp = days[month + which_cal] + row;
|
||||
build_row(lineout + which_cal * (week_len + 2), dp);
|
||||
}
|
||||
/* blank_string took care of nul termination. */
|
||||
trim_trailing_spaces_and_print(lineout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bb_fflush_stdout_and_exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* day_array --
|
||||
* Fill in an array of 42 integers with a calendar. Assume for a moment
|
||||
* that you took the (maximum) 6 rows in a calendar and stretched them
|
||||
* out end to end. You would have 42 numbers or spaces. This routine
|
||||
* builds that array for any month from Jan. 1 through Dec. 9999.
|
||||
*/
|
||||
static void day_array(int month, int year, int *days)
|
||||
{
|
||||
long temp;
|
||||
int i;
|
||||
int j_offset;
|
||||
int day, dw, dm;
|
||||
|
||||
memset(days, SPACE, MAXDAYS * sizeof(int));
|
||||
|
||||
if ((month == 9) && (year == 1752)) {
|
||||
j_offset = julian * 244;
|
||||
i = 0;
|
||||
do {
|
||||
days[i+2] = sep1752[i] + j_offset;
|
||||
} while (++i < sizeof(sep1752));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* day_in_year
|
||||
* return the 1 based day number within the year
|
||||
*/
|
||||
day = 1;
|
||||
if ((month > 2) && leap_year(year)) {
|
||||
++day;
|
||||
}
|
||||
|
||||
i = month;
|
||||
while (i) {
|
||||
day += days_in_month[--i];
|
||||
}
|
||||
|
||||
/* day_in_week
|
||||
* return the 0 based day number for any date from 1 Jan. 1 to
|
||||
* 31 Dec. 9999. Assumes the Gregorian reformation eliminates
|
||||
* 3 Sep. 1752 through 13 Sep. 1752. Returns Thursday for all
|
||||
* missing days.
|
||||
*/
|
||||
dw = THURSDAY;
|
||||
temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1)
|
||||
+ day;
|
||||
if (temp < FIRST_MISSING_DAY) {
|
||||
dw = ((temp - 1 + SATURDAY) % 7);
|
||||
} else if (temp >= (FIRST_MISSING_DAY + NUMBER_MISSING_DAYS)) {
|
||||
dw = (((temp - 1 + SATURDAY) - NUMBER_MISSING_DAYS) % 7);
|
||||
}
|
||||
|
||||
if (!julian) {
|
||||
day = 1;
|
||||
}
|
||||
|
||||
dm = days_in_month[month];
|
||||
if ((month == 2) && leap_year(year)) {
|
||||
++dm;
|
||||
}
|
||||
|
||||
while (dm) {
|
||||
days[dw++] = day++;
|
||||
--dm;
|
||||
}
|
||||
}
|
||||
|
||||
static void trim_trailing_spaces_and_print(char *s)
|
||||
{
|
||||
char *p = s;
|
||||
|
||||
while (*p) {
|
||||
++p;
|
||||
}
|
||||
while (p > s) {
|
||||
--p;
|
||||
if (!(isspace)(*p)) { /* We want the function... not the inline. */
|
||||
p[1] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
puts(s);
|
||||
}
|
||||
|
||||
static void center(char *str, int len, int separate)
|
||||
{
|
||||
int n = strlen(str);
|
||||
len -= n;
|
||||
bb_printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
|
||||
}
|
||||
|
||||
static void blank_string(char *buf, size_t buflen)
|
||||
{
|
||||
memset(buf, ' ', buflen);
|
||||
buf[buflen-1] = '\0';
|
||||
}
|
||||
|
||||
static char *build_row(char *p, int *dp)
|
||||
{
|
||||
int col, val, day;
|
||||
|
||||
memset(p, ' ', (julian + DAY_LEN) * 7);
|
||||
|
||||
col = 0;
|
||||
do {
|
||||
if ((day = *dp++) != SPACE) {
|
||||
if (julian) {
|
||||
*++p;
|
||||
if (day >= 100) {
|
||||
*p = '0';
|
||||
p[-1] = (day / 100) + '0';
|
||||
day %= 100;
|
||||
}
|
||||
}
|
||||
if ((val = day / 10) > 0) {
|
||||
*p = val + '0';
|
||||
}
|
||||
*++p = day % 10 + '0';
|
||||
p += 2;
|
||||
} else {
|
||||
p += DAY_LEN + julian;
|
||||
}
|
||||
} while (++col < 7);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Kim Letkeman.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+37
-23
@@ -1,9 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
* cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,33 +20,48 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* This is a new implementation of 'cat' which aims to be SUSv3 compliant.
|
||||
*
|
||||
* Changes from the previous implementation include:
|
||||
* 1) Multiple '-' args are accepted as required by SUSv3. The previous
|
||||
* implementation would close stdin and segfault on a subsequent '-'.
|
||||
* 2) The '-u' options is required by SUSv3. Note that the specified
|
||||
* behavior for '-u' is done by default, so all we need do is accept
|
||||
* the option.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
FILE *f;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
return status;
|
||||
bb_getopt_ulflags(argc, argv, "u");
|
||||
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
*--argv = "-";
|
||||
}
|
||||
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
do {
|
||||
if ((f = bb_wfopen_input(*argv)) != NULL) {
|
||||
int r = bb_copyfd(fileno(f), STDOUT_FILENO, 0);
|
||||
bb_fclose_nonstdin(f);
|
||||
if (r >= 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
retval = EXIT_FAILURE;
|
||||
} while (*++argv);
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
return retval;
|
||||
}
|
||||
+30
-35
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini chgrp implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,64 +20,60 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */
|
||||
/* BB_AUDIT GNU defects - unsupported options -h, -c, -f, -v, and long options. */
|
||||
/* BB_AUDIT Note: gnu chgrp does not support -H, -L, or -P. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
/* Don't use lchown glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
|
||||
static long gid;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (lchown(fileName, statbuf->st_uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
if (lchown(fileName, statbuf->st_uid, *((long *) junk)) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
perror(fileName);
|
||||
bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chgrp_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
char *p=NULL;
|
||||
long gid;
|
||||
int recursiveFlag;
|
||||
int retval = EXIT_SUCCESS;
|
||||
char *p;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
recursiveFlag = bb_getopt_ulflags(argc, argv, "R");
|
||||
|
||||
if (argc - optind < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* Find the selected group */
|
||||
gid = strtoul(argv[optind], &p, 10); /* maybe it's already numeric */
|
||||
if (argv[optind] == p)
|
||||
gid = my_getgrnam(argv[optind]);
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
argv += optind;
|
||||
|
||||
/* Find the selected group */
|
||||
gid = strtoul(*argv, &p, 10); /* maybe it's already numeric */
|
||||
if (*p || (p == *argv)) { /* trailing chars or nonnumeric */
|
||||
gid = my_getgrnam(*argv);
|
||||
}
|
||||
++argv;
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
while (++optind < argc) {
|
||||
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
do {
|
||||
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, &gid)) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+57
-29
@@ -2,8 +2,10 @@
|
||||
/*
|
||||
* Mini chmod implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* Reworked by (C) 2002 Vladimir Oleynik <dzo@simtreas.ru>
|
||||
* to correctly parse '-rwxgoa'
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,58 +23,84 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* BB_AUDIT GNU defects - unsupported options -c, -f, -v, and long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (!parse_mode((char *)junk, &(statbuf->st_mode)))
|
||||
error_msg_and_die("internal error");
|
||||
if (!bb_parse_mode((char *)junk, &(statbuf->st_mode)))
|
||||
bb_error_msg_and_die( "invalid mode: %s", (char *)junk);
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
perror(fileName);
|
||||
bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int opt;
|
||||
int retval = EXIT_SUCCESS;
|
||||
int recursiveFlag = FALSE;
|
||||
int count;
|
||||
char *smode;
|
||||
char **p;
|
||||
char *p0;
|
||||
char opt = '-';
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
++argv;
|
||||
count = 0;
|
||||
|
||||
for (p = argv ; *p ; p++) {
|
||||
p0 = p[0];
|
||||
if (p0[0] == opt) {
|
||||
if ((p0[1] == '-') && !p0[2]) {
|
||||
opt = 0; /* Disable further option processing. */
|
||||
continue;
|
||||
}
|
||||
if (p0[1] == 'R') {
|
||||
char *s = p0 + 2;
|
||||
while (*s == 'R') {
|
||||
++s;
|
||||
}
|
||||
if (*s) {
|
||||
bb_show_usage();
|
||||
}
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
continue;
|
||||
}
|
||||
if (count) {
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
argv[count] = p0;
|
||||
++count;
|
||||
}
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* Parse the specified mode */
|
||||
mode_t mode;
|
||||
if (parse_mode(argv[optind], &mode) == FALSE) {
|
||||
error_msg_and_die( "unknown mode: %s", argv[optind]);
|
||||
}
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
argv[count] = NULL;
|
||||
|
||||
if (count < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
smode = *argv;
|
||||
++argv;
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
for (i = optind + 1; i < argc; i++) {
|
||||
if (recursive_action (argv[i], recursiveFlag, FALSE, FALSE, fileAction,
|
||||
fileAction, argv[optind]) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
do {
|
||||
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, smode)) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+56
-51
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini chown implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,13 +20,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */
|
||||
/* BB_AUDIT GNU defects - unsupported options -h, -c, -f, -v, and long options. */
|
||||
/* BB_AUDIT Note: gnu chown does not support -H, -L, or -P. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
/* Don't use lchown for glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
@@ -35,72 +38,74 @@
|
||||
static long uid;
|
||||
static long gid;
|
||||
|
||||
static int (*chown_func)(const char *, __uid_t, __gid_t) = chown;
|
||||
static int (*chown_func)(const char *, uid_t, gid_t) = chown;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
perror(fileName);
|
||||
bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
#define FLAG_R 1
|
||||
#define FLAG_h 2
|
||||
|
||||
static unsigned long get_ug_id(const char *s, long (*my_getxxnam)(const char *))
|
||||
{
|
||||
unsigned long r;
|
||||
char *p;
|
||||
|
||||
r = strtoul(s, &p, 10);
|
||||
if (*p || (s == p)) {
|
||||
r = my_getxxnam(s);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int chown_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
int recursiveFlag = FALSE,
|
||||
noderefFlag = FALSE;
|
||||
char *groupName=NULL;
|
||||
char *p=NULL;
|
||||
int flags;
|
||||
int retval = EXIT_SUCCESS;
|
||||
char *groupName;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "Rh")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'h':
|
||||
noderefFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
flags = bb_getopt_ulflags(argc, argv, "Rh");
|
||||
|
||||
if (flags & FLAG_h) chown_func = lchown;
|
||||
|
||||
if (argc - optind < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (noderefFlag) chown_func = lchown;
|
||||
argv += optind;
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* First, check if there is a group name here */
|
||||
groupName = strchr(argv[optind], '.');
|
||||
if (groupName == NULL)
|
||||
groupName = strchr(argv[optind], ':');
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = strtoul(groupName, &p, 10);
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
} else {
|
||||
gid = -1;
|
||||
}
|
||||
/* Now check for the username */
|
||||
uid = strtoul(argv[optind], &p, 10); /* Is is numeric? */
|
||||
if (argv[optind] == p) {
|
||||
uid = my_getpwnam(argv[optind]);
|
||||
}
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
/* First, check if there is a group name here */
|
||||
if ((groupName = strchr(*argv, '.')) == NULL) {
|
||||
groupName = strchr(*argv, ':');
|
||||
}
|
||||
|
||||
gid = -1;
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = get_ug_id(groupName, my_getgrnam);
|
||||
}
|
||||
|
||||
/* Now check for the username */
|
||||
uid = get_ug_id(*argv, my_getpwnam);
|
||||
|
||||
++argv;
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
while (++optind < argc) {
|
||||
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
do {
|
||||
if (! recursive_action (*argv, (flags & FLAG_R), FALSE, FALSE,
|
||||
fileAction, fileAction, NULL)) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+16
-37
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,6 +20,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@@ -29,46 +30,24 @@
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
if (argc < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
++argv;
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
bb_perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc >= 1) {
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#if defined shell_main && defined CONFIG_FEATURE_SH_STANDALONE_SHELL
|
||||
char shell[] = "/bin/sh";
|
||||
char *shell_argv[2] = { shell, NULL };
|
||||
applet_name = shell;
|
||||
shell_main(1, shell_argv);
|
||||
return EXIT_SUCCESS;
|
||||
#else
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#endif
|
||||
++argv;
|
||||
if (argc == 2) {
|
||||
argv -= 2;
|
||||
if (!(*argv = getenv("SHELL"))) {
|
||||
*argv = (char *) "/bin/sh";
|
||||
}
|
||||
argv[1] = (char *) "-i";
|
||||
}
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
execvp(*argv, argv);
|
||||
bb_perror_msg_and_die("cannot execute %s", *argv);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+114
-40
@@ -20,59 +20,133 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Original version majorly reworked for SUSv3 compliance, bug fixes, and
|
||||
* size optimizations. Changes include:
|
||||
* 1) Now correctly distingusishes between errors and actual file differences.
|
||||
* 2) Proper handling of '-' args.
|
||||
* 3) Actual error checking of i/o.
|
||||
* 4) Accept SUSv3 -l option. Note that we use the slightly nicer gnu format
|
||||
* in the '-l' case.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static FILE *cmp_xfopen_input(const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = bb_wfopen_input(filename)) != NULL) {
|
||||
return fp;
|
||||
}
|
||||
|
||||
exit(bb_default_error_retval); /* We already output an error message. */
|
||||
}
|
||||
|
||||
static const char fmt_eof[] = "cmp: EOF on %s\n";
|
||||
static const char fmt_differ[] = "%s %s differ: char %d, line %d\n";
|
||||
#if 0
|
||||
static const char fmt_l_opt[] = "%.0s%.0s%d %o %o\n"; /* SUSv3 format */
|
||||
#else
|
||||
static const char fmt_l_opt[] = "%.0s%.0s%d %3o %3o\n"; /* nicer gnu format */
|
||||
#endif
|
||||
|
||||
static const char opt_chars[] = "sl";
|
||||
|
||||
enum {
|
||||
OPT_s = 1,
|
||||
OPT_l = 2
|
||||
};
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1, *filename2 = "-";
|
||||
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
|
||||
FILE *fp1, *fp2, *outfile = stdout;
|
||||
const char *filename1, *filename2;
|
||||
const char *fmt;
|
||||
int c1, c2, char_pos, line_pos;
|
||||
int opt_flags;
|
||||
int exit_val = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "s")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
silent = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
bb_default_error_retval = 2; /* 1 is returned if files are different. */
|
||||
|
||||
opt_flags = bb_getopt_ulflags(argc, argv, opt_chars);
|
||||
|
||||
if ((opt_flags == 3) || (((unsigned int)(--argc - optind)) > 1)) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
filename1 = argv[optind];
|
||||
switch (argc - optind) {
|
||||
case 2:
|
||||
fp2 = xfopen(filename2 = argv[optind + 1], "r");
|
||||
case 1:
|
||||
fp1 = xfopen(filename1, "r");
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
fp1 = cmp_xfopen_input(filename1 = *(argv += optind));
|
||||
|
||||
filename2 = "-";
|
||||
if (*++argv) {
|
||||
filename2 = *argv;
|
||||
}
|
||||
fp2 = cmp_xfopen_input(filename2);
|
||||
|
||||
if (fp1 == fp2) { /* Paranioa check... stdin == stdin? */
|
||||
/* Note that we don't bother reading stdin. Neither does gnu wc.
|
||||
* But perhaps we should, so that other apps down the chain don't
|
||||
* get the input. Consider 'echo hello | (cmp - - && cat -)'.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
fmt = fmt_differ;
|
||||
if (opt_flags == OPT_l) {
|
||||
fmt = fmt_l_opt;
|
||||
}
|
||||
|
||||
char_pos = 0;
|
||||
line_pos = 1;
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (silent)
|
||||
return EXIT_FAILURE;
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
c1 = getc(fp1);
|
||||
c2 = getc(fp2);
|
||||
++char_pos;
|
||||
if (c1 != c2) { /* Remember -- a read error may have occurred. */
|
||||
exit_val = 1; /* But assume the files are different for now. */
|
||||
if (c2 == EOF) {
|
||||
/* We know that fp1 isn't at EOF or in an error state. But to
|
||||
* save space below, things are setup to expect an EOF in fp1
|
||||
* if an EOF occurred. So, swap things around.
|
||||
*/
|
||||
fp1 = fp2;
|
||||
filename1 = filename2;
|
||||
c1 = c2;
|
||||
}
|
||||
if (c1 == EOF) {
|
||||
bb_xferror(fp1, filename1);
|
||||
fmt = fmt_eof; /* Well, no error, so it must really be EOF. */
|
||||
outfile = stderr;
|
||||
/* There may have been output to stdout (option -l), so
|
||||
* make sure we fflush before writing to stderr. */
|
||||
bb_xfflush_stdout();
|
||||
}
|
||||
if (opt_flags != OPT_s) {
|
||||
if (opt_flags == OPT_l) {
|
||||
line_pos = c1; /* line_pos is unused in the -l case. */
|
||||
}
|
||||
bb_fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2);
|
||||
if (opt_flags) { /* This must be -l since not -s. */
|
||||
/* If we encountered and EOF, the while check will catch it. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c1 == '\n') {
|
||||
++line_pos;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
bb_xferror(fp1, filename1);
|
||||
bb_xferror(fp2, filename2);
|
||||
|
||||
bb_fflush_stdout_and_exit(exit_val);
|
||||
}
|
||||
+64
-66
@@ -2,7 +2,6 @@
|
||||
/*
|
||||
* Mini cp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,6 +20,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */
|
||||
/* BB_AUDIT GNU defects - only extension options supported are -a and -d. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cp.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Size reduction.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
@@ -29,86 +37,76 @@
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include "busybox.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
static const char cp_opts[] = "pdRfia"; /* WARNING!! ORDER IS IMPORTANT!! */
|
||||
|
||||
extern int cp_main(int argc, char **argv)
|
||||
{
|
||||
struct stat source_stat;
|
||||
struct stat dest_stat;
|
||||
const char *last;
|
||||
const char *dest;
|
||||
int s_flags;
|
||||
int d_flags;
|
||||
int flags;
|
||||
int status = 0;
|
||||
int opt;
|
||||
int flags = FILEUTILS_DEREFERENCE;
|
||||
int i;
|
||||
|
||||
while ((opt = getopt(argc, argv, "adfipR")) != -1)
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
|
||||
/* fallthrough */
|
||||
case 'd':
|
||||
flags &= ~FILEUTILS_DEREFERENCE;
|
||||
break;
|
||||
case 'f':
|
||||
flags |= FILEUTILS_FORCE;
|
||||
break;
|
||||
case 'i':
|
||||
flags |= FILEUTILS_INTERACTIVE;
|
||||
break;
|
||||
case 'p':
|
||||
flags |= FILEUTILS_PRESERVE_STATUS;
|
||||
break;
|
||||
case 'R':
|
||||
flags |= FILEUTILS_RECUR;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (optind + 2 > argc)
|
||||
show_usage();
|
||||
/* Since these are enums, #if tests will not work. So use assert()s. */
|
||||
assert(FILEUTILS_PRESERVE_STATUS == 1);
|
||||
assert(FILEUTILS_DEREFERENCE == 2);
|
||||
assert(FILEUTILS_RECUR == 4);
|
||||
assert(FILEUTILS_FORCE == 8);
|
||||
assert(FILEUTILS_INTERACTIVE == 16);
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, cp_opts);
|
||||
|
||||
if (flags & 32) {
|
||||
flags |= (FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR | FILEUTILS_DEREFERENCE);
|
||||
}
|
||||
|
||||
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */
|
||||
|
||||
if (optind + 2 > argc) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
last = argv[argc - 1];
|
||||
argv += optind;
|
||||
|
||||
/* If there are only two arguments and... */
|
||||
if (optind + 2 == argc) {
|
||||
struct stat source_stat;
|
||||
struct stat dest_stat;
|
||||
int source_exists = 1;
|
||||
int dest_exists = 1;
|
||||
|
||||
if ((!(flags & FILEUTILS_DEREFERENCE) &&
|
||||
lstat(argv[optind], &source_stat) < 0) ||
|
||||
((flags & FILEUTILS_DEREFERENCE) &&
|
||||
stat(argv[optind], &source_stat))) {
|
||||
if (errno != ENOENT)
|
||||
perror_msg_and_die("unable to stat `%s'", argv[optind]);
|
||||
source_exists = 0;
|
||||
s_flags = cp_mv_stat2(*argv, &source_stat,
|
||||
(flags & FILEUTILS_DEREFERENCE) ? stat : lstat);
|
||||
if ((s_flags < 0) || ((d_flags = cp_mv_stat(last, &dest_stat)) < 0)) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (stat(argv[optind + 1], &dest_stat) < 0) {
|
||||
if (errno != ENOENT)
|
||||
perror_msg_and_die("unable to stat `%s'", argv[optind + 1]);
|
||||
dest_exists = 0;
|
||||
}
|
||||
|
||||
/* ...if neither is a directory or... */
|
||||
if (((!source_exists || !S_ISDIR(source_stat.st_mode)) &&
|
||||
(!dest_exists || !S_ISDIR(dest_stat.st_mode))) ||
|
||||
/* ...recursing, the first is a directory, and the
|
||||
* second doesn't exist, then... */
|
||||
((flags & FILEUTILS_RECUR) && S_ISDIR(source_stat.st_mode) &&
|
||||
!dest_exists)) {
|
||||
if ( !((s_flags | d_flags) & 2) ||
|
||||
/* ...recursing, the 1st is a directory, and the 2nd doesn't exist... */
|
||||
/* ((flags & FILEUTILS_RECUR) && (s_flags & 2) && !d_flags) */
|
||||
/* Simplify the above since FILEUTILS_RECUR >> 1 == 2. */
|
||||
((((flags & FILEUTILS_RECUR) >> 1) & s_flags) && !d_flags)
|
||||
) {
|
||||
/* ...do a simple copy. */
|
||||
if (copy_file(argv[optind], argv[optind + 1], flags) < 0)
|
||||
status = 1;
|
||||
return status;
|
||||
dest = last;
|
||||
goto DO_COPY; /* Note: optind+2==argc implies argv[1]==last below. */
|
||||
}
|
||||
}
|
||||
|
||||
for (i = optind; i < argc - 1; i++) {
|
||||
char *dest = concat_path_file(argv[argc - 1],
|
||||
get_last_path_component(argv[i]));
|
||||
if (copy_file(argv[i], dest, flags) < 0)
|
||||
do {
|
||||
dest = concat_path_file(last, bb_get_last_path_component(*argv));
|
||||
DO_COPY:
|
||||
if (copy_file(*argv, dest, flags) < 0) {
|
||||
status = 1;
|
||||
free(dest);
|
||||
}
|
||||
}
|
||||
if (*++argv == last) {
|
||||
break;
|
||||
}
|
||||
free((void *) dest);
|
||||
} while (1);
|
||||
|
||||
return status;
|
||||
exit(status);
|
||||
}
|
||||
+38
-50
@@ -1,3 +1,4 @@
|
||||
/* vi: set sw=8 ts=8: */
|
||||
/*
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
@@ -22,20 +23,22 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> /* getopt */
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* globals from other files */
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
|
||||
/* option vars */
|
||||
static char part = 0; /* (b)yte, (c)har, (f)ields */
|
||||
static unsigned int supress_non_delimited_lines = 0;
|
||||
static const char optstring[] = "b:c:f:d:sn";
|
||||
#define OPT_BYTE_FLGS 1
|
||||
#define OPT_CHAR_FLGS 2
|
||||
#define OPT_FIELDS_FLGS 4
|
||||
#define OPT_DELIM_FLGS 8
|
||||
#define OPT_SUPRESS_FLGS 16
|
||||
static char part; /* (b)yte, (c)har, (f)ields */
|
||||
static unsigned int supress_non_delimited_lines;
|
||||
static char delim = '\t'; /* delimiter, default is tab */
|
||||
|
||||
struct cut_list {
|
||||
@@ -92,7 +95,7 @@ static void parse_lists(char *lists)
|
||||
} else {
|
||||
s = strtoul(ntok, &junk, 10);
|
||||
if(*junk != '\0' || s < 0)
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
bb_error_msg_and_die("invalid byte or field list");
|
||||
|
||||
/* account for the fact that arrays are zero based, while the user
|
||||
* expects the first char on the line to be char # 1 */
|
||||
@@ -109,7 +112,7 @@ static void parse_lists(char *lists)
|
||||
} else {
|
||||
e = strtoul(ntok, &junk, 10);
|
||||
if(*junk != '\0' || e < 0)
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
bb_error_msg_and_die("invalid byte or field list");
|
||||
/* if the user specified and end position of 0, that means "til the
|
||||
* end of the line */
|
||||
if (e == 0)
|
||||
@@ -121,7 +124,7 @@ static void parse_lists(char *lists)
|
||||
|
||||
/* if there's something left to tokenize, the user past an invalid list */
|
||||
if (ltok)
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
bb_error_msg_and_die("invalid byte or field list");
|
||||
|
||||
/* add the new list */
|
||||
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
|
||||
@@ -131,7 +134,7 @@ static void parse_lists(char *lists)
|
||||
|
||||
/* make sure we got some cut positions out of all that */
|
||||
if (nlists == 0)
|
||||
error_msg_and_die("missing list of positions");
|
||||
bb_error_msg_and_die("missing list of positions");
|
||||
|
||||
/* now that the lists are parsed, we need to sort them to make life easier
|
||||
* on us when it comes time to print the chars / fields / lines */
|
||||
@@ -267,15 +270,14 @@ static void cut_file(FILE *file)
|
||||
unsigned int linenum = 0; /* keep these zero-based to be consistent */
|
||||
|
||||
/* go through every line in the file */
|
||||
while ((line = get_line_from_file(file)) != NULL) {
|
||||
chomp(line);
|
||||
while ((line = bb_get_chomped_line_from_file(file)) != NULL) {
|
||||
|
||||
/* cut based on chars/bytes XXX: only works when sizeof(char) == byte */
|
||||
if (part == 'c' || part == 'b')
|
||||
if ((part & (OPT_CHAR_FLGS | OPT_BYTE_FLGS)))
|
||||
cut_line_by_chars(line);
|
||||
|
||||
/* cut based on fields */
|
||||
else if (part == 'f') {
|
||||
else {
|
||||
if (delim == '\n')
|
||||
cut_file_by_lines(line, linenum);
|
||||
else
|
||||
@@ -290,47 +292,33 @@ static void cut_file(FILE *file)
|
||||
|
||||
extern int cut_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
unsigned long opt;
|
||||
char *sopt, *sdopt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'f':
|
||||
/* make sure they didn't ask for two types of lists */
|
||||
if (part != 0) {
|
||||
error_msg_and_die("only one type of list may be specified");
|
||||
}
|
||||
part = (char)opt;
|
||||
parse_lists(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
case 'n':
|
||||
/* no-op */
|
||||
break;
|
||||
case 's':
|
||||
supress_non_delimited_lines++;
|
||||
break;
|
||||
bb_opt_complementaly = "b~bcf:c~bcf:f~bcf";
|
||||
opt = bb_getopt_ulflags(argc, argv, optstring, &sopt, &sopt, &sopt, &sdopt);
|
||||
part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS);
|
||||
if(part == 0)
|
||||
bb_error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
if(opt & 0x80000000UL)
|
||||
bb_error_msg_and_die("only one type of list may be specified");
|
||||
parse_lists(sopt);
|
||||
if((opt & (OPT_DELIM_FLGS))) {
|
||||
if (strlen(sdopt) > 1) {
|
||||
bb_error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
delim = sdopt[0];
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
}
|
||||
supress_non_delimited_lines = opt & OPT_SUPRESS_FLGS;
|
||||
|
||||
/* non-field (char or byte) cutting has some special handling */
|
||||
if (part != 'f') {
|
||||
if (part != OPT_FIELDS_FLGS) {
|
||||
if (supress_non_delimited_lines) {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense"
|
||||
bb_error_msg_and_die("suppressing non-delimited lines makes sense"
|
||||
" only when operating on fields");
|
||||
}
|
||||
if (delim != '\t' && part != 'f') {
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields");
|
||||
if (delim != '\t') {
|
||||
bb_error_msg_and_die("a delimiter may be specified only when operating on fields");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +332,7 @@ extern int cut_main(int argc, char **argv)
|
||||
int i;
|
||||
FILE *file;
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = wfopen(argv[i], "r");
|
||||
file = bb_wfopen(argv[i], "r");
|
||||
if(file) {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
|
||||
+124
-96
@@ -3,6 +3,8 @@
|
||||
* Mini date implementation for busybox
|
||||
*
|
||||
* by Matthew Grant <grantma@anathoth.gen.nz>
|
||||
*
|
||||
* iso-format handling added by Robert Griebl <griebl@gmx.de>
|
||||
*
|
||||
* 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
|
||||
@@ -46,19 +48,18 @@ static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
int nr;
|
||||
|
||||
nr = sscanf(t_string, "%2d%2d%2d%2d%d",
|
||||
&(tm_time->tm_mon),
|
||||
&(tm_time->tm_mday),
|
||||
&(tm_time->tm_hour),
|
||||
&(tm_time->tm_min), &(tm_time->tm_year));
|
||||
nr = sscanf(t_string, "%2d%2d%2d%2d%d", &(tm_time->tm_mon),
|
||||
&(tm_time->tm_mday), &(tm_time->tm_hour), &(tm_time->tm_min),
|
||||
&(tm_time->tm_year));
|
||||
|
||||
if (nr < 4 || nr > 5) {
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, t_string);
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if (tm_time->tm_year >= 1900)
|
||||
if (tm_time->tm_year >= 1900) {
|
||||
tm_time->tm_year -= 1900;
|
||||
}
|
||||
/* adjust date */
|
||||
tm_time->tm_mon -= 1;
|
||||
|
||||
@@ -75,50 +76,39 @@ static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
|
||||
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
|
||||
&t.tm_hour, &t.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
|
||||
|
||||
} 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) {
|
||||
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} 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) {
|
||||
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 6) {
|
||||
|
||||
if (t =
|
||||
*tm_time, sscanf(t_string, "%d:%d:%d", &t.tm_hour, &t.tm_min,
|
||||
&t.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
} else if (t =
|
||||
*tm_time, sscanf(t_string, "%d:%d", &t.tm_hour,
|
||||
&t.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
} 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) {
|
||||
/* Adjust dates from 1-12 to 0-11 */
|
||||
t.tm_mon -= 1;
|
||||
} 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) {
|
||||
/* Adjust dates from 1-12 to 0-11 */
|
||||
t.tm_mon -= 1;
|
||||
} 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) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 5) {
|
||||
} 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);
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, t_string);
|
||||
}
|
||||
*tm_time = t;
|
||||
return (tm_time);
|
||||
@@ -130,53 +120,72 @@ int date_main(int argc, char **argv)
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *t_buff;
|
||||
int c;
|
||||
int set_time = 0;
|
||||
int rfc822 = 0;
|
||||
int utc = 0;
|
||||
int set_time;
|
||||
int rfc822;
|
||||
int utc;
|
||||
int use_arg = 0;
|
||||
time_t tm;
|
||||
unsigned long opt;
|
||||
struct tm tm_time;
|
||||
|
||||
/* Interpret command line args */
|
||||
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
show_usage();
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
int ifmt = 0;
|
||||
char *isofmt_arg;
|
||||
|
||||
# define GETOPT_ISOFMT "I::"
|
||||
#else
|
||||
# define GETOPT_ISOFMT
|
||||
#endif
|
||||
bb_opt_complementaly = "d~ds:s~ds";
|
||||
opt = bb_getopt_ulflags(argc, argv, "Rs:ud:" GETOPT_ISOFMT,
|
||||
&date_str, &date_str
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
, &isofmt_arg
|
||||
#endif
|
||||
);
|
||||
rfc822 = opt & 1;
|
||||
set_time = opt & 2;
|
||||
utc = opt & 4;
|
||||
if(utc) {
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
}
|
||||
use_arg = opt & 8;
|
||||
if(opt & 0x80000000UL)
|
||||
bb_show_usage();
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
if(opt & 16) {
|
||||
if (!isofmt_arg)
|
||||
ifmt = 1;
|
||||
else {
|
||||
int ifmt_len = bb_strlen(isofmt_arg);
|
||||
|
||||
if ((ifmt_len <= 4)
|
||||
&& (strncmp(isofmt_arg, "date", ifmt_len) == 0)) {
|
||||
ifmt = 1;
|
||||
} else if ((ifmt_len <= 5)
|
||||
&& (strncmp(isofmt_arg, "hours", ifmt_len) == 0)) {
|
||||
ifmt = 2;
|
||||
} else if ((ifmt_len <= 7)
|
||||
&& (strncmp(isofmt_arg, "minutes", ifmt_len) == 0)) {
|
||||
ifmt = 3;
|
||||
} else if ((ifmt_len <= 7)
|
||||
&& (strncmp(isofmt_arg, "seconds", ifmt_len) == 0)) {
|
||||
ifmt = 4;
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
show_usage();
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
if (!ifmt) {
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
|
||||
date_fmt = &argv[optind][1]; /* Skip over the '+' */
|
||||
else if (date_str == NULL) {
|
||||
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+')) {
|
||||
date_fmt = &argv[optind][1]; /* Skip over the '+' */
|
||||
} else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = argv[optind];
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
show_usage();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
@@ -200,19 +209,18 @@ int date_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Correct any day of week and day of year etc. fields */
|
||||
tm_time.tm_isdst = -1; /* Be sure to recheck dst. */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0)
|
||||
error_msg_and_die(invalid_date, date_str);
|
||||
if ( utc ) {
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
if (tm < 0) {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
if (utc && (putenv("TZ=UTC0") != 0)) {
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if (set_time) {
|
||||
if (stime(&tm) < 0) {
|
||||
perror_msg("cannot set date");
|
||||
}
|
||||
if (set_time && (stime(&tm) < 0)) {
|
||||
bb_perror_msg("cannot set date");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,12 +228,32 @@ int date_main(int argc, char **argv)
|
||||
|
||||
/* Deal with format string */
|
||||
if (date_fmt == NULL) {
|
||||
date_fmt = (rfc822
|
||||
? (utc
|
||||
? "%a, %_d %b %Y %H:%M:%S GMT"
|
||||
: "%a, %_d %b %Y %H:%M:%S %z")
|
||||
: "%a %b %e %H:%M:%S %Z %Y");
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
switch (ifmt) {
|
||||
case 4:
|
||||
date_fmt = utc ? "%Y-%m-%dT%H:%M:%SZ" : "%Y-%m-%dT%H:%M:%S%z";
|
||||
break;
|
||||
case 3:
|
||||
date_fmt = utc ? "%Y-%m-%dT%H:%MZ" : "%Y-%m-%dT%H:%M%z";
|
||||
break;
|
||||
case 2:
|
||||
date_fmt = utc ? "%Y-%m-%dT%HZ" : "%Y-%m-%dT%H%z";
|
||||
break;
|
||||
case 1:
|
||||
date_fmt = "%Y-%m-%d";
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
#endif
|
||||
date_fmt =
|
||||
(rfc822
|
||||
? (utc ? "%a, %e %b %Y %H:%M:%S GMT" :
|
||||
"%a, %e %b %Y %H:%M:%S %z") : "%a %b %e %H:%M:%S %Z %Y");
|
||||
|
||||
#ifdef CONFIG_FEATURE_DATE_ISOFMT
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
} else if (*date_fmt == '\0') {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf("\n");
|
||||
|
||||
+86
-37
@@ -3,7 +3,7 @@
|
||||
* Mini dd implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
* Copyright (C) 2000,2001 Matt Kraai
|
||||
*
|
||||
* 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,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@@ -45,22 +46,35 @@ static const struct suffix_mult dd_suffixes[] = {
|
||||
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE;
|
||||
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
|
||||
size_t bs = 512, count = -1;
|
||||
size_t out_full = 0;
|
||||
size_t out_part = 0;
|
||||
size_t in_full = 0;
|
||||
size_t in_part = 0;
|
||||
size_t count = -1;
|
||||
size_t bs = 512;
|
||||
ssize_t n;
|
||||
off_t seek = 0, skip = 0;
|
||||
char *infile = NULL, *outfile = NULL, *buf;
|
||||
off_t seek = 0;
|
||||
off_t skip = 0;
|
||||
int sync_flag = FALSE;
|
||||
int noerror = FALSE;
|
||||
int trunc = TRUE;
|
||||
int oflag;
|
||||
int ifd;
|
||||
int ofd;
|
||||
int i;
|
||||
const char *infile = NULL;
|
||||
const char *outfile = NULL;
|
||||
char *buf;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strncmp("bs=", argv[i], 3) == 0)
|
||||
bs = parse_number(argv[i]+3, dd_suffixes);
|
||||
bs = bb_xparse_number(argv[i]+3, dd_suffixes);
|
||||
else if (strncmp("count=", argv[i], 6) == 0)
|
||||
count = parse_number(argv[i]+6, dd_suffixes);
|
||||
count = bb_xparse_number(argv[i]+6, dd_suffixes);
|
||||
else if (strncmp("seek=", argv[i], 5) == 0)
|
||||
seek = parse_number(argv[i]+5, dd_suffixes);
|
||||
seek = bb_xparse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("skip=", argv[i], 5) == 0)
|
||||
skip = parse_number(argv[i]+5, dd_suffixes);
|
||||
skip = bb_xparse_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)
|
||||
@@ -74,8 +88,11 @@ int dd_main(int argc, char **argv)
|
||||
} else if (strncmp("sync", buf, 4) == 0) {
|
||||
sync_flag = TRUE;
|
||||
buf += 4;
|
||||
} else if (strncmp("noerror", buf, 7) == 0) {
|
||||
noerror = TRUE;
|
||||
buf += 7;
|
||||
} else {
|
||||
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
|
||||
bb_error_msg_and_die("invalid conversion `%s'", argv[i]+5);
|
||||
}
|
||||
if (buf[0] == '\0')
|
||||
break;
|
||||
@@ -83,72 +100,104 @@ int dd_main(int argc, char **argv)
|
||||
buf++;
|
||||
}
|
||||
} else
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
buf = xmalloc(bs);
|
||||
|
||||
if (infile != NULL) {
|
||||
if ((ifd = open(infile, O_RDONLY)) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
ifd = bb_xopen(infile, O_RDONLY);
|
||||
} else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = "standard input";
|
||||
infile = bb_msg_standard_input;
|
||||
}
|
||||
|
||||
if (outfile != NULL) {
|
||||
oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
if (!seek && trunc)
|
||||
if (!seek && trunc) {
|
||||
oflag |= O_TRUNC;
|
||||
}
|
||||
|
||||
if ((ofd = open(outfile, oflag, 0666)) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if ((ofd = open(outfile, oflag, 0666)) < 0) {
|
||||
bb_perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
if (seek && trunc) {
|
||||
if (ftruncate(ofd, seek * bs) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (ftruncate(ofd, seek * bs) < 0) {
|
||||
struct stat st;
|
||||
|
||||
if (fstat (ofd, &st) < 0 || S_ISREG (st.st_mode) ||
|
||||
S_ISDIR (st.st_mode)) {
|
||||
bb_perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
outfile = bb_msg_standard_output;
|
||||
}
|
||||
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0) {
|
||||
bb_perror_msg_and_die("%s", infile);
|
||||
}
|
||||
}
|
||||
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0) {
|
||||
bb_perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
}
|
||||
|
||||
while (in_full + in_part != count) {
|
||||
if (noerror) {
|
||||
/* Pre-zero the buffer when doing the noerror thing */
|
||||
memset(buf, '\0', bs);
|
||||
}
|
||||
n = safe_read(ifd, buf, bs);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
if (n == 0)
|
||||
if (n < 0) {
|
||||
if (noerror) {
|
||||
n = bs;
|
||||
bb_perror_msg("%s", infile);
|
||||
} else {
|
||||
bb_perror_msg_and_die("%s", infile);
|
||||
}
|
||||
}
|
||||
if (n == 0) {
|
||||
break;
|
||||
if (n == bs)
|
||||
}
|
||||
if (n == bs) {
|
||||
in_full++;
|
||||
else
|
||||
} else {
|
||||
in_part++;
|
||||
}
|
||||
if (sync_flag) {
|
||||
memset(buf + n, '\0', bs - n);
|
||||
n = bs;
|
||||
}
|
||||
n = full_write(ofd, buf, n);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (n == bs)
|
||||
n = bb_full_write(ofd, buf, n);
|
||||
if (n < 0) {
|
||||
bb_perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
if (n == bs) {
|
||||
out_full++;
|
||||
else
|
||||
} else {
|
||||
out_part++;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "%ld+%ld records in\n", (long)in_full, (long)in_part);
|
||||
fprintf(stderr, "%ld+%ld records out\n", (long)out_full, (long)out_part);
|
||||
if (close (ifd) < 0) {
|
||||
bb_perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
if (close (ofd) < 0) {
|
||||
bb_perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
fprintf(stderr, "%ld+%ld records in\n%ld+%ld records out\n",
|
||||
(long)in_full, (long)in_part,
|
||||
(long)out_full, (long)out_part);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+116
-104
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini df implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,131 +21,144 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 _NOT_ compliant -- options -P and -t missing. Also blocksize. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/df.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Size reduction. Removed floating point dependency. Added error checking
|
||||
* on output. Output stats on 0-sized filesystems if specificly listed on
|
||||
* the command line. Properly round *-blocks, Used, and Available quantities.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern const char mtab_file[]; /* Defined in utility.c */
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
static unsigned long df_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
static int do_df(char *device, const char *mount_point)
|
||||
#ifndef CONFIG_FEATURE_HUMAN_READABLE
|
||||
static long kscale(long b, long bs)
|
||||
{
|
||||
struct statfs s;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
|
||||
if (statfs(mount_point, &s) != 0) {
|
||||
perror_msg("%s", mount_point);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (s.f_blocks > 0) {
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
if(blocks_used == 0)
|
||||
blocks_percent_used = 0;
|
||||
else {
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
}
|
||||
if (strcmp(device, "/dev/root") == 0) {
|
||||
/* Adjusts device to be the real root device,
|
||||
* or leaves device alone if it can't find it */
|
||||
device = find_real_root_device_name(device);
|
||||
if(device==NULL)
|
||||
return FALSE;
|
||||
}
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
printf("%-20s %9s ", device,
|
||||
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
|
||||
|
||||
printf("%9s ",
|
||||
make_human_readable_str( (s.f_blocks - s.f_bfree), s.f_bsize, df_disp_hr));
|
||||
|
||||
printf("%9s %3ld%% %s\n",
|
||||
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
|
||||
blocks_percent_used, mount_point);
|
||||
#else
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
|
||||
(long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
|
||||
(long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
|
||||
blocks_percent_used, mount_point);
|
||||
#endif
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return ( b * (long long) bs + KILOBYTE/2 ) / KILOBYTE;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
unsigned long df_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
int status = EXIT_SUCCESS;
|
||||
int opt = 0;
|
||||
int i = 0;
|
||||
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
|
||||
unsigned long opt;
|
||||
FILE *mount_table;
|
||||
struct mntent *mount_entry;
|
||||
struct statfs s;
|
||||
static const char hdr_1k[] = "1k-blocks"; /* default display is kilobytes */
|
||||
const char *disp_units_hdr = hdr_1k;
|
||||
|
||||
while ((opt = getopt(argc, argv, "k"
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
)) > 0)
|
||||
{
|
||||
switch (opt) {
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
case 'h':
|
||||
bb_opt_complementaly = "h-km:k-hm:m-hk";
|
||||
opt = bb_getopt_ulflags(argc, argv, "hmk");
|
||||
if(opt & 1) {
|
||||
df_disp_hr = 0;
|
||||
strcpy(disp_units_hdr, " Size");
|
||||
break;
|
||||
case 'm':
|
||||
disp_units_hdr = " Size";
|
||||
}
|
||||
if(opt & 2) {
|
||||
df_disp_hr = MEGABYTE;
|
||||
strcpy(disp_units_hdr, "1M-blocks");
|
||||
break;
|
||||
disp_units_hdr = "1M-blocks";
|
||||
}
|
||||
#else
|
||||
opt = bb_getopt_ulflags(argc, argv, "k");
|
||||
#endif
|
||||
case 'k':
|
||||
/* default display is kilobytes */
|
||||
|
||||
bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
|
||||
"", disp_units_hdr);
|
||||
|
||||
mount_table = NULL;
|
||||
argv += optind;
|
||||
if (optind >= argc) {
|
||||
if (!(mount_table = setmntent(bb_path_mtab_file, "r"))) {
|
||||
bb_perror_msg_and_die(bb_path_mtab_file);
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
const char *device;
|
||||
const char *mount_point;
|
||||
|
||||
if (mount_table) {
|
||||
if (!(mount_entry = getmntent(mount_table))) {
|
||||
endmntent(mount_table);
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem", disp_units_hdr,
|
||||
"Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
if(optind < argc) {
|
||||
struct mntent *mount_entry;
|
||||
for(i = optind; i < argc; i++)
|
||||
{
|
||||
if ((mount_entry = find_mount_point(argv[i], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.", argv[i]);
|
||||
}
|
||||
} else {
|
||||
if (!(mount_point = *argv++)) {
|
||||
break;
|
||||
}
|
||||
if (!(mount_entry = find_mount_point(mount_point, bb_path_mtab_file))) {
|
||||
bb_error_msg("%s: can't find mount point.", mount_point);
|
||||
SET_ERROR:
|
||||
status = EXIT_FAILURE;
|
||||
} else if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
FILE *mount_table;
|
||||
struct mntent *mount_entry;
|
||||
|
||||
mount_table = setmntent(mtab_file, "r");
|
||||
if (mount_table == 0) {
|
||||
perror_msg("%s", mtab_file);
|
||||
return EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
while ((mount_entry = getmntent(mount_table))) {
|
||||
if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
endmntent(mount_table);
|
||||
}
|
||||
device = mount_entry->mnt_fsname;
|
||||
mount_point = mount_entry->mnt_dir;
|
||||
|
||||
return status;
|
||||
if (statfs(mount_point, &s) != 0) {
|
||||
bb_perror_msg("%s", mount_point);
|
||||
goto SET_ERROR;
|
||||
}
|
||||
|
||||
if ((s.f_blocks > 0) || !mount_table){
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = 0;
|
||||
if (blocks_used + s.f_bavail) {
|
||||
blocks_percent_used = (((long long) blocks_used) * 100
|
||||
+ (blocks_used + s.f_bavail)/2
|
||||
) / (blocks_used + s.f_bavail);
|
||||
}
|
||||
|
||||
if (strcmp(device, "rootfs") == 0) {
|
||||
continue;
|
||||
} else if (strcmp(device, "/dev/root") == 0) {
|
||||
/* Adjusts device to be the real root device,
|
||||
* or leaves device alone if it can't find it */
|
||||
if ((device = find_real_root_device_name(device)) == NULL) {
|
||||
goto SET_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
bb_printf("%-21s%9s ", device,
|
||||
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
|
||||
|
||||
bb_printf("%9s ",
|
||||
make_human_readable_str( (s.f_blocks - s.f_bfree),
|
||||
s.f_bsize, df_disp_hr));
|
||||
|
||||
bb_printf("%9s %3ld%% %s\n",
|
||||
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
|
||||
blocks_percent_used, mount_point);
|
||||
#else
|
||||
bb_printf("%-21s%9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
kscale(s.f_blocks, s.f_bsize),
|
||||
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
|
||||
kscale(s.f_bavail, s.f_bsize),
|
||||
blocks_percent_used, mount_point);
|
||||
#endif
|
||||
}
|
||||
|
||||
} while (1);
|
||||
|
||||
bb_fflush_stdout_and_exit(status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+8
-9
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini dirname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
|
||||
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
|
||||
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,20 +20,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dirname_main(int argc, char **argv)
|
||||
{
|
||||
if ((argc < 2) || (**(argv + 1) == '-'))
|
||||
show_usage();
|
||||
argv++;
|
||||
if (argc != 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
puts (dirname (argv[0]));
|
||||
puts(dirname(argv[1]));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
+12
-10
@@ -35,6 +35,10 @@
|
||||
#include <sys/time.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define CT_AUTO 0
|
||||
#define CT_UNIX2DOS 1
|
||||
#define CT_DOS2UNIX 2
|
||||
|
||||
/* We are making a lame pseudo-random string generator here. in
|
||||
* convert(), each pass through the while loop will add more and more
|
||||
* stuff into value, which is _supposed_ to wrap. We don't care about
|
||||
@@ -55,15 +59,13 @@ static int convert(char *fn, int ConvType)
|
||||
FILE *in = stdin, *out = stdout;
|
||||
|
||||
if (fn != NULL) {
|
||||
if ((in = wfopen(fn, "rw")) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
strcpy(tempFn, fn);
|
||||
in = bb_xfopen(fn, "rw");
|
||||
safe_strncpy(tempFn, fn, sizeof(tempFn));
|
||||
c = strlen(tempFn);
|
||||
tempFn[c] = '.';
|
||||
while(1) {
|
||||
if (c >=BUFSIZ)
|
||||
error_msg_and_die("unique name not found");
|
||||
bb_error_msg_and_die("unique name not found");
|
||||
/* Get some semi random stuff to try and make a
|
||||
* random filename based (and in the same dir as)
|
||||
* the input file... */
|
||||
@@ -92,7 +94,7 @@ static int convert(char *fn, int ConvType)
|
||||
// file is alredy in DOS format so it is not necessery to touch it
|
||||
remove(tempFn);
|
||||
if (fclose(in) < 0 || fclose(out) < 0) {
|
||||
perror_msg(NULL);
|
||||
bb_perror_nomsg();
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
@@ -106,7 +108,7 @@ static int convert(char *fn, int ConvType)
|
||||
// file is alredy in UNIX format so it is not necessery to touch it
|
||||
remove(tempFn);
|
||||
if ((fclose(in) < 0) || (fclose(out) < 0)) {
|
||||
perror_msg(NULL);
|
||||
bb_perror_nomsg();
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
@@ -137,7 +139,7 @@ static int convert(char *fn, int ConvType)
|
||||
|
||||
if (fn != NULL) {
|
||||
if (fclose(in) < 0 || fclose(out) < 0) {
|
||||
perror_msg(NULL);
|
||||
bb_perror_nomsg();
|
||||
remove(tempFn);
|
||||
return -2;
|
||||
}
|
||||
@@ -146,7 +148,7 @@ static int convert(char *fn, int ConvType)
|
||||
* should be true since we put them into the same directory
|
||||
* so we _should_ be ok, but you never know... */
|
||||
if (rename(tempFn, fn) < 0) {
|
||||
perror_msg("unable to rename '%s' as '%s'", tempFn, fn);
|
||||
bb_perror_msg("unable to rename '%s' as '%s'", tempFn, fn);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -177,7 +179,7 @@ int dos2unix_main(int argc, char *argv[])
|
||||
ConvType = CT_DOS2UNIX;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+180
-171
@@ -4,6 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc. and John Beppu
|
||||
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
|
||||
* Copyright (C) 2002 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
|
||||
@@ -21,114 +22,63 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
/* BB_AUDIT SUSv3 compliant (unless default blocksize set to 1k) */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/du.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Mostly rewritten for SUSv3 compliance and to fix bugs/defects.
|
||||
* 1) Added support for SUSv3 -a, -H, -L, gnu -c, and (busybox) -d options.
|
||||
* The -d option allows setting of max depth (similar to gnu --max-depth).
|
||||
* 2) Fixed incorrect size calculations for links and directories, especially
|
||||
* when errors occurred. Calculates sizes should now match gnu du output.
|
||||
* 3) Added error checking of output.
|
||||
* 4) Fixed busybox bug #1284 involving long overflow with human_readable.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
# ifdef CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
|
||||
static unsigned long disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
typedef void (Display) (long, char *);
|
||||
|
||||
static int du_depth = 0;
|
||||
static int count_hardlinks = 0;
|
||||
|
||||
static Display *print;
|
||||
|
||||
static void print_normal(long size, char *filename)
|
||||
{
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
printf("%s\t%s\n", make_human_readable_str(size<<10, 1, disp_hr), filename);
|
||||
# else
|
||||
static unsigned long disp_hr = 512;
|
||||
# endif
|
||||
#elif defined CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
|
||||
static unsigned int disp_k = 1;
|
||||
#else
|
||||
printf("%ld\t%s\n", size, filename);
|
||||
static unsigned int disp_k; /* bss inits to 0 */
|
||||
#endif
|
||||
}
|
||||
|
||||
static void print_summary(long size, char *filename)
|
||||
static int max_print_depth = INT_MAX;
|
||||
static int count_hardlinks = INT_MAX;
|
||||
|
||||
static int status
|
||||
#if EXIT_SUCCESS == 0
|
||||
= EXIT_SUCCESS
|
||||
#endif
|
||||
;
|
||||
static int print_files;
|
||||
static int slink_depth;
|
||||
static int du_depth;
|
||||
static int one_file_system;
|
||||
static dev_t dir_dev;
|
||||
|
||||
|
||||
static void print(long size, char *filename)
|
||||
{
|
||||
if (du_depth == 1) {
|
||||
print_normal(size, filename);
|
||||
}
|
||||
}
|
||||
|
||||
#define HASH_SIZE 311 /* Should be prime */
|
||||
#define hash_inode(i) ((i) % HASH_SIZE)
|
||||
|
||||
typedef struct ino_dev_hash_bucket_struct {
|
||||
struct ino_dev_hash_bucket_struct *next;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
char name[1];
|
||||
} ino_dev_hashtable_bucket_t;
|
||||
|
||||
static ino_dev_hashtable_bucket_t *ino_dev_hashtable[HASH_SIZE];
|
||||
|
||||
/*
|
||||
* Return 1 if statbuf->st_ino && statbuf->st_dev are recorded in
|
||||
* `ino_dev_hashtable', else return 0
|
||||
*
|
||||
* If NAME is a non-NULL pointer to a character pointer, and there is
|
||||
* a match, then set *NAME to the value of the name slot in that
|
||||
* bucket.
|
||||
*/
|
||||
static int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name)
|
||||
{
|
||||
ino_dev_hashtable_bucket_t *bucket;
|
||||
|
||||
bucket = ino_dev_hashtable[hash_inode(statbuf->st_ino)];
|
||||
while (bucket != NULL) {
|
||||
if ((bucket->ino == statbuf->st_ino) &&
|
||||
(bucket->dev == statbuf->st_dev))
|
||||
{
|
||||
if (name) *name = bucket->name;
|
||||
return 1;
|
||||
}
|
||||
bucket = bucket->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add statbuf to statbuf hash table */
|
||||
static void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name)
|
||||
{
|
||||
int i;
|
||||
size_t s;
|
||||
ino_dev_hashtable_bucket_t *bucket;
|
||||
|
||||
i = hash_inode(statbuf->st_ino);
|
||||
s = name ? strlen(name) : 0;
|
||||
bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + s);
|
||||
bucket->ino = statbuf->st_ino;
|
||||
bucket->dev = statbuf->st_dev;
|
||||
if (name)
|
||||
strcpy(bucket->name, name);
|
||||
else
|
||||
bucket->name[0] = '\0';
|
||||
bucket->next = ino_dev_hashtable[i];
|
||||
ino_dev_hashtable[i] = bucket;
|
||||
}
|
||||
|
||||
/* Clear statbuf hash table */
|
||||
static void reset_ino_dev_hashtable(void)
|
||||
{
|
||||
int i;
|
||||
ino_dev_hashtable_bucket_t *bucket;
|
||||
|
||||
for (i = 0; i < HASH_SIZE; i++) {
|
||||
while (ino_dev_hashtable[i] != NULL) {
|
||||
bucket = ino_dev_hashtable[i]->next;
|
||||
free(ino_dev_hashtable[i]);
|
||||
ino_dev_hashtable[i] = bucket;
|
||||
}
|
||||
}
|
||||
/* TODO - May not want to defer error checking here. */
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
bb_printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr),
|
||||
filename);
|
||||
#else
|
||||
bb_printf("%ld\t%s\n", size >> disp_k, filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* tiny recursive du */
|
||||
@@ -138,19 +88,43 @@ static long du(char *filename)
|
||||
long sum;
|
||||
|
||||
if ((lstat(filename, &statbuf)) != 0) {
|
||||
perror_msg("%s", filename);
|
||||
bb_perror_msg("%s", filename);
|
||||
status = EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
du_depth++;
|
||||
sum = (statbuf.st_blocks >> 1);
|
||||
|
||||
/* Don't add in stuff pointed to by symbolic links */
|
||||
if (S_ISLNK(statbuf.st_mode)) {
|
||||
sum = 0L;
|
||||
if (du_depth == 1) {
|
||||
if (one_file_system) {
|
||||
if (du_depth == 0) {
|
||||
dir_dev = statbuf.st_dev;
|
||||
} else if (dir_dev != statbuf.st_dev) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
sum = statbuf.st_blocks;
|
||||
|
||||
if (S_ISLNK(statbuf.st_mode)) {
|
||||
if (slink_depth > du_depth) { /* -H or -L */
|
||||
if ((stat(filename, &statbuf)) != 0) {
|
||||
bb_perror_msg("%s", filename);
|
||||
status = EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
sum = statbuf.st_blocks;
|
||||
if (slink_depth == 1) {
|
||||
slink_depth = INT_MAX; /* Convert -H to -L. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (statbuf.st_nlink > count_hardlinks) {
|
||||
/* Add files/directories with links only once */
|
||||
if (is_in_ino_dev_hashtable(&statbuf, NULL)) {
|
||||
return 0;
|
||||
}
|
||||
add_to_ino_dev_hashtable(&statbuf, NULL);
|
||||
}
|
||||
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
@@ -158,8 +132,9 @@ static long du(char *filename)
|
||||
|
||||
dir = opendir(filename);
|
||||
if (!dir) {
|
||||
du_depth--;
|
||||
return 0;
|
||||
bb_perror_msg("%s", filename);
|
||||
status = EXIT_FAILURE;
|
||||
return sum;
|
||||
}
|
||||
|
||||
newfile = last_char_is(filename, '/');
|
||||
@@ -169,88 +144,122 @@ static long du(char *filename)
|
||||
while ((entry = readdir(dir))) {
|
||||
char *name = entry->d_name;
|
||||
|
||||
if ((strcmp(name, "..") == 0)
|
||||
|| (strcmp(name, ".") == 0)) {
|
||||
newfile = concat_subpath_file(filename, name);
|
||||
if(newfile == NULL)
|
||||
continue;
|
||||
}
|
||||
newfile = concat_path_file(filename, name);
|
||||
++du_depth;
|
||||
sum += du(newfile);
|
||||
--du_depth;
|
||||
free(newfile);
|
||||
}
|
||||
closedir(dir);
|
||||
} else if (du_depth > print_files) {
|
||||
return sum;
|
||||
}
|
||||
if (du_depth <= max_print_depth) {
|
||||
print(sum, filename);
|
||||
}
|
||||
else if (statbuf.st_nlink > 1 && !count_hardlinks) {
|
||||
/* Add files with hard links only once */
|
||||
if (is_in_ino_dev_hashtable(&statbuf, NULL)) {
|
||||
sum = 0L;
|
||||
if (du_depth == 1)
|
||||
print(sum, filename);
|
||||
}
|
||||
else {
|
||||
add_to_ino_dev_hashtable(&statbuf, NULL);
|
||||
}
|
||||
}
|
||||
du_depth--;
|
||||
return sum;
|
||||
}
|
||||
|
||||
int du_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int i;
|
||||
int c;
|
||||
long total;
|
||||
int slink_depth_save;
|
||||
int print_final_total;
|
||||
char *smax_print_depth;
|
||||
unsigned long opt;
|
||||
|
||||
/* default behaviour */
|
||||
print = print_normal;
|
||||
#ifdef CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
|
||||
if (getenv("POSIXLY_CORRECT")) { /* TODO - a new libbb function? */
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
disp_hr = 512;
|
||||
#else
|
||||
disp_k = 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/* parse argv[] */
|
||||
while ((c = getopt(argc, argv, "sl"
|
||||
/* Note: SUSv3 specifies that -a and -s options can not be used together
|
||||
* in strictly conforming applications. However, it also says that some
|
||||
* du implementations may produce output when -a and -s are used together.
|
||||
* gnu du exits with an error code in this case. We choose to simply
|
||||
* ignore -a. This is consistent with -s being equivalent to -d 0.
|
||||
*/
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
"k")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
print = print_summary;
|
||||
break;
|
||||
case 'l':
|
||||
count_hardlinks = 1;
|
||||
break;
|
||||
#ifdef CONFIG_FEATURE_HUMAN_READABLE
|
||||
case 'h': disp_hr = 0; break;
|
||||
case 'm': disp_hr = MEGABYTE; break;
|
||||
#endif
|
||||
case 'k': break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
bb_opt_complementaly = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
|
||||
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
|
||||
if((opt & (1 << 9))) {
|
||||
/* -h opt */
|
||||
disp_hr = 0;
|
||||
}
|
||||
if((opt & (1 << 10))) {
|
||||
/* -m opt */
|
||||
disp_hr = MEGABYTE;
|
||||
}
|
||||
if((opt & (1 << 2))) {
|
||||
/* -k opt */
|
||||
disp_hr = KILOBYTE;
|
||||
}
|
||||
#else
|
||||
bb_opt_complementaly = "H-L:L-H:s-d:d-s";
|
||||
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
|
||||
#if !defined CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
|
||||
if((opt & (1 << 2))) {
|
||||
/* -k opt */
|
||||
disp_k = 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if((opt & (1 << 0))) {
|
||||
/* -a opt */
|
||||
print_files = INT_MAX;
|
||||
}
|
||||
if((opt & (1 << 1))) {
|
||||
/* -H opt */
|
||||
slink_depth = 1;
|
||||
}
|
||||
if((opt & (1 << 3))) {
|
||||
/* -L opt */
|
||||
slink_depth = INT_MAX;
|
||||
}
|
||||
if((opt & (1 << 4))) {
|
||||
/* -s opt */
|
||||
max_print_depth = 0;
|
||||
}
|
||||
one_file_system = opt & (1 << 5); /* -x opt */
|
||||
if((opt & (1 << 6))) {
|
||||
/* -d opt */
|
||||
max_print_depth = bb_xgetularg10_bnd(smax_print_depth, 0, INT_MAX);
|
||||
}
|
||||
if((opt & (1 << 7))) {
|
||||
/* -l opt */
|
||||
count_hardlinks = 1;
|
||||
}
|
||||
print_final_total = opt & (1 << 8); /* -c opt */
|
||||
|
||||
/* go through remaining args (if any) */
|
||||
argv += optind;
|
||||
if (optind >= argc) {
|
||||
if (du(".") == 0)
|
||||
status = EXIT_FAILURE;
|
||||
} else {
|
||||
long sum;
|
||||
|
||||
for (i=optind; i < argc; i++) {
|
||||
sum = du(argv[i]);
|
||||
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
print_normal(sum, argv[i]);
|
||||
}
|
||||
reset_ino_dev_hashtable();
|
||||
*--argv = ".";
|
||||
if (slink_depth == 1) {
|
||||
slink_depth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
slink_depth_save = slink_depth;
|
||||
total = 0;
|
||||
do {
|
||||
total += du(*argv);
|
||||
slink_depth = slink_depth_save;
|
||||
} while (*++argv);
|
||||
#ifdef CONFIG_FEATURE_CLEAN_UP
|
||||
reset_ino_dev_hashtable();
|
||||
#endif
|
||||
|
||||
/* $Id: du.c,v 1.51 2001/10/24 04:59:27 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
if (print_final_total) {
|
||||
print(total, "total");
|
||||
}
|
||||
|
||||
bb_fflush_stdout_and_exit(status);
|
||||
}
|
||||
+78
-65
@@ -22,94 +22,107 @@
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant -- unless configured as fancy echo. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/echo.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Because of behavioral differences, implemented configureable SUSv3
|
||||
* or 'fancy' gnu-ish behaviors. Also, reduced size and fixed bugs.
|
||||
* 1) In handling '\c' escape, the previous version only suppressed the
|
||||
* trailing newline. SUSv3 specifies _no_ output after '\c'.
|
||||
* 2) SUSv3 specifies that octal escapes are of the form \0{#{#{#}}}.
|
||||
* The previous version version did not allow 4-digit octals.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
echo_main(int argc, char** argv)
|
||||
extern int echo_main(int argc, char** argv)
|
||||
{
|
||||
int nflag = 0;
|
||||
#ifndef CONFIG_FEATURE_FANCY_ECHO
|
||||
#define eflag '\\'
|
||||
++argv;
|
||||
#else
|
||||
const char *p;
|
||||
int nflag = 1;
|
||||
int eflag = 0;
|
||||
|
||||
/* Skip argv[0]. */
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc > 0 && *argv[0] == '-')
|
||||
{
|
||||
register char *temp;
|
||||
register int ix;
|
||||
|
||||
/*
|
||||
* If it appears that we are handling options, then make sure
|
||||
while (*++argv && (**argv == '-')) {
|
||||
/* If it appears that we are handling options, then make sure
|
||||
* that all of the options specified are actually valid.
|
||||
* Otherwise, the string should just be echoed.
|
||||
*/
|
||||
temp = argv[0] + 1;
|
||||
|
||||
for (ix = 0; temp[ix]; ix++)
|
||||
{
|
||||
if (strrchr("neE", temp[ix]) == 0)
|
||||
goto just_echo;
|
||||
}
|
||||
|
||||
if (!*temp)
|
||||
|
||||
if (!*(p = *argv + 1)) { /* A single '-', so echo it. */
|
||||
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++;
|
||||
|
||||
do {
|
||||
if (strrchr("neE", *p) == 0) {
|
||||
goto just_echo;
|
||||
}
|
||||
} while (*++p);
|
||||
|
||||
/* All of the options in this arg are valid, so handle them. */
|
||||
p = *argv + 1;
|
||||
do {
|
||||
if (*p == 'n') {
|
||||
nflag = 0;
|
||||
} else if (*p == 'e') {
|
||||
eflag = '\\';
|
||||
} else {
|
||||
eflag = 0;
|
||||
}
|
||||
} while (*++p);
|
||||
}
|
||||
|
||||
just_echo:
|
||||
while (argc > 0) {
|
||||
const char *arg = argv[0];
|
||||
#endif
|
||||
while (*argv) {
|
||||
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);
|
||||
while ((c = *(*argv)++)) {
|
||||
if (c == eflag) { /* Check for escape seq. */
|
||||
if (**argv == 'c') {
|
||||
/* '\c' means cancel newline and
|
||||
* ignore all subsequent chars. */
|
||||
goto DONE;
|
||||
}
|
||||
#ifndef CONFIG_FEATURE_FANCY_ECHO
|
||||
/* SUSv3 specifies that octal escapes must begin with '0'. */
|
||||
if (((unsigned int)(**argv - '1')) >= 7)
|
||||
#endif
|
||||
{
|
||||
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
|
||||
* of the form \0### are accepted. */
|
||||
if ((**argv == '0') && (((unsigned int)(argv[0][1] - '0')) < 8)) {
|
||||
(*argv)++;
|
||||
}
|
||||
/* bb_process_escape_sequence can handle nul correctly */
|
||||
c = bb_process_escape_sequence((const char **) argv);
|
||||
}
|
||||
}
|
||||
|
||||
putchar(c);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc > 0)
|
||||
putchar(' ');
|
||||
}
|
||||
if (!nflag)
|
||||
putchar('\n');
|
||||
fflush(stdout);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
if (*++argv) {
|
||||
putchar(' ');
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_FANCY_ECHO
|
||||
if (nflag) {
|
||||
putchar('\n');
|
||||
}
|
||||
#else
|
||||
putchar('\n');
|
||||
#endif
|
||||
|
||||
DONE:
|
||||
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
||||
Loaded 100 of 635 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user