Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
704b2c2122 | ||
|
|
53b55ac08d | ||
|
|
c36c2ba598 | ||
|
|
7f1978570f | ||
|
|
4aaefc2a50 | ||
|
|
c5b3242d3d | ||
|
|
056960d8dc | ||
|
|
0d5051def0 | ||
|
|
3a0057e2c5 | ||
|
|
f71378c4ad | ||
|
|
0a6f1d31e7 | ||
|
|
e708cb5f9a | ||
|
|
a4edd0e946 | ||
|
|
f9ff8a7d90 | ||
|
|
af9e533a54 | ||
|
|
48dcc16548 | ||
|
|
730cdb1904 | ||
|
|
0d4e51d390 | ||
|
|
0b57e28373 | ||
|
|
b0c2b7dfe3 | ||
|
|
2825ee8c2c | ||
|
|
a8035a51be | ||
|
|
7384d7dce0 | ||
|
|
0d3a02eba7 | ||
|
|
670bea210e | ||
|
|
d8adaa279e | ||
|
|
3bf60aa723 | ||
|
|
e110ccb672 | ||
|
|
0e0883e0e9 | ||
|
|
038c8eb5a9 | ||
|
|
7ddaf7caae | ||
|
|
bac75ac2d5 | ||
|
|
1ef92685cf | ||
|
|
ce4a586edb | ||
|
|
40e5e7c7ea | ||
|
|
20f61d35de | ||
|
|
44a9914709 | ||
|
|
2892c35bdb | ||
|
|
82d8502409 | ||
|
|
53f5061c7e | ||
|
|
bdc8db9685 | ||
|
|
741f2c9898 | ||
|
|
b9a1e56a80 | ||
|
|
2b1c367a98 | ||
|
|
3c0b425cde | ||
|
|
14e9e9d1ca | ||
|
|
9c09e0eeaa | ||
|
|
c319601db5 | ||
|
|
4e7244e6b2 | ||
|
|
8658816f71 | ||
|
|
f594986b37 | ||
|
|
c75f83d874 | ||
|
|
b3d6e2df95 | ||
|
|
798ab301c7 | ||
|
|
f6ba2da29f | ||
|
|
e0bf91d7c6 | ||
|
|
53737c5421 | ||
|
|
6bff9cc487 | ||
|
|
bd2e42f162 | ||
|
|
94fd480bab | ||
|
|
6317c4baf7 | ||
|
|
4987bbf979 | ||
|
|
5ec5415402 | ||
|
|
1a49fc5e92 | ||
|
|
fe4e13fb97 | ||
|
|
22b889a998 | ||
|
|
68ea1d0325 | ||
|
|
1365bb7861 | ||
|
|
78f57460f2 | ||
|
|
d2117e9c82 | ||
|
|
09f4af5afd | ||
|
|
827e45c518 | ||
|
|
fa45f22e50 | ||
|
|
d92168486b | ||
|
|
4aaf89f49f | ||
|
|
f90c28dd1e | ||
|
|
8d4c397d9d | ||
|
|
3e6ff9017f | ||
|
|
dd91724aa0 | ||
|
|
74e056bfc8 | ||
|
|
3c7361f53a | ||
|
|
ce89871ff7 | ||
|
|
195743f195 | ||
|
|
eba8ed71f0 | ||
|
|
9ba5bce06f | ||
|
|
01658a3eec | ||
|
|
3dbf1e877a | ||
|
|
afffbfe8c4 | ||
|
|
b180dd9e50 | ||
|
|
13d1fa1d01 | ||
|
|
df351d6109 | ||
|
|
39eea898c4 | ||
|
|
7e5291f111 | ||
|
|
32f8c170b0 | ||
|
|
ca6045955d | ||
|
|
e2c44fc966 | ||
|
|
5de909873a | ||
|
|
4cc8f31ffe | ||
|
|
ae5612ca6e | ||
|
|
ae20128e9f | ||
|
|
26d53eb197 | ||
|
|
ec9fad9a49 | ||
|
|
a7db19bb81 | ||
|
|
11ae573320 | ||
|
|
7850f1e2ac | ||
|
|
5986f8d1c6 | ||
|
|
651f8c04ef | ||
|
|
6c563bc1a1 | ||
|
|
8b728a25a3 | ||
|
|
702ec5926f | ||
|
|
8bb7df49c2 | ||
|
|
0f430e34af | ||
|
|
36278b9576 | ||
|
|
54851d3c65 | ||
|
|
07f2f3917a | ||
|
|
1a046d5f9d | ||
|
|
138ece09b5 | ||
|
|
e6c4de03c6 | ||
|
|
f15d4dad66 | ||
|
|
5efa2291aa | ||
|
|
c27b9544b6 | ||
|
|
47cdcdd359 | ||
|
|
21b7459add | ||
|
|
afbff22e6e | ||
|
|
452fd33ffa | ||
|
|
076cdc24fc | ||
|
|
9ead68975c | ||
|
|
323434be42 | ||
|
|
446dd27843 | ||
|
|
42ab250709 | ||
|
|
3b565cdf91 | ||
|
|
85adecb668 | ||
|
|
450736cd3c | ||
|
|
016771834a | ||
|
|
39842defda | ||
|
|
de4406747b | ||
|
|
7b91f02021 | ||
|
|
93ba60f01d | ||
|
|
1b6cff3df4 | ||
|
|
4f76bb6f3e | ||
|
|
4142d4dc66 | ||
|
|
e677dfedd1 | ||
|
|
d11578f916 | ||
|
|
2bf658d5cd | ||
|
|
afeb96547f | ||
|
|
d160a27ec1 | ||
|
|
dc12190ba2 | ||
|
|
37977622c4 | ||
|
|
7d597c4833 | ||
|
|
dbfff6cbde | ||
|
|
e6967b20cb | ||
|
|
3757f98d86 | ||
|
|
8373e70c55 | ||
|
|
7a9cc2dcdd | ||
|
|
15f9b92127 | ||
|
|
df1e9daf30 | ||
|
|
ed0d958c3e | ||
|
|
2498b155fd | ||
|
|
a0cfe94c4e | ||
|
|
b83ffafc15 | ||
|
|
56082dc2ae | ||
|
|
68c1d8400c | ||
|
|
b249fbb1dc | ||
|
|
8c16bc5012 | ||
|
|
4a25d8c9c3 | ||
|
|
0ed9923887 | ||
|
|
3574b70efc | ||
|
|
8079b155c2 | ||
|
|
bbc8e4789f | ||
|
|
2f3105725f | ||
|
|
5723934f7c | ||
|
|
41492d6c23 | ||
|
|
c163e5107f | ||
|
|
544891dd26 | ||
|
|
adea7a6101 | ||
|
|
4b2e69a1cf | ||
|
|
e13bc0bc68 | ||
|
|
ffc40bf3de | ||
|
|
b2007bffc5 | ||
|
|
5d9cad0253 | ||
|
|
7aa1f5c42a | ||
|
|
dbcd8ce464 | ||
|
|
7e9276b50a | ||
|
|
8fc300976f | ||
|
|
be30a6b8b0 | ||
|
|
54006bce25 | ||
|
|
7c3e7ac940 | ||
|
|
8d7bdc9deb | ||
|
|
9e37007edb | ||
|
|
90fe7fea10 | ||
|
|
477aedd77f | ||
|
|
5165fbed63 | ||
|
|
caeeb36784 | ||
|
|
a183f05825 | ||
|
|
f1142c5b11 | ||
|
|
cbe31dace5 | ||
|
|
94456f5984 | ||
|
|
12dceb1147 | ||
|
|
963791a9e9 | ||
|
|
f1bbb22dca | ||
|
|
f57a832063 | ||
|
|
b50da53e0c | ||
|
|
3d20f772c2 | ||
|
|
966b3a6f79 | ||
|
|
1cf8166329 | ||
|
|
47aea4ee71 | ||
|
|
19f86207f5 | ||
|
|
69c8572f29 | ||
|
|
f6a7227fd6 | ||
|
|
28a78ab62c | ||
|
|
6faae7deb4 | ||
|
|
361ee514c6 | ||
|
|
ca0f458ada | ||
|
|
733c4ad6eb | ||
|
|
fa4f146d7d | ||
|
|
5f2c79d8c7 | ||
|
|
af12bc6de4 | ||
|
|
3f5bcbfa3c | ||
|
|
a9c69762ba | ||
|
|
825ae5a166 | ||
|
|
99806ad2bd | ||
|
|
11b7a1deb7 | ||
|
|
d69d2da165 | ||
|
|
b50d707633 | ||
|
|
02b9f42a27 | ||
|
|
81bcc92c32 | ||
|
|
8305006f7c | ||
|
|
c1c43113b4 | ||
|
|
3ec8ffb121 | ||
|
|
67991cf824 | ||
|
|
68be2ab914 | ||
|
|
98e599ca06 | ||
|
|
ec45595300 | ||
|
|
88a5ceb450 | ||
|
|
fc83c4c353 | ||
|
|
6fd8c664c1 | ||
|
|
3af1f88725 | ||
|
|
dadf9c6dcd | ||
|
|
821fbf0f42 | ||
|
|
bc9afadecd | ||
|
|
728875f340 | ||
|
|
631064613f | ||
|
|
0c9d77ccfd | ||
|
|
de556615dc | ||
|
|
510f0ddafa | ||
|
|
649968ceb1 | ||
|
|
af8c65deaa | ||
|
|
c900575dc4 | ||
|
|
c30ab0f4a8 | ||
|
|
e78fd0f721 | ||
|
|
2fd52989f7 | ||
|
|
d238a7bcc8 | ||
|
|
1d70267450 | ||
|
|
df8ccb6350 | ||
|
|
096370d349 | ||
|
|
a164c647ac | ||
|
|
925edb828d | ||
|
|
c3fc3c5e7a | ||
|
|
29cff26f32 | ||
|
|
76c5e60d54 | ||
|
|
af4ac77d9d | ||
|
|
b5c29850e3 | ||
|
|
065c7e779a | ||
|
|
9b300d0b1f | ||
|
|
f2cc2762bb | ||
|
|
05e782ddd3 | ||
|
|
bd018b1bab | ||
|
|
dd19c69904 | ||
|
|
63ec273245 | ||
|
|
82d5e59ea2 | ||
|
|
79e898ac0e | ||
|
|
65225df2dc | ||
|
|
53cfb7e231 | ||
|
|
704d2a6c43 | ||
|
|
39573f7130 | ||
|
|
18d5064c47 | ||
|
|
9ba0daf4ba | ||
|
|
93a8e2e64b | ||
|
|
306f4fe480 | ||
|
|
22332fd26f | ||
|
|
ac21e93a3f | ||
|
|
4bbdd788e0 | ||
|
|
30f64c3aa2 | ||
|
|
8526067336 | ||
|
|
e57d54b456 | ||
|
|
201dc0d5a9 | ||
|
|
ceade5c856 | ||
|
|
8ec10a9483 | ||
|
|
90ca2848fd | ||
|
|
ed3ef50c23 | ||
|
|
ab050f5522 | ||
|
|
3654ca56fa | ||
|
|
4e33875759 | ||
|
|
a68b21a28e | ||
|
|
6e25f92636 | ||
|
|
a528dc7071 | ||
|
|
1e4b957ac3 | ||
|
|
5c9c8b4b26 | ||
|
|
d5cad14b11 | ||
|
|
dff9d54e32 | ||
|
|
5307eca7de | ||
|
|
114ad9c753 | ||
|
|
dbb8f8d123 | ||
|
|
d35c21587a | ||
|
|
ffde8673fe | ||
|
|
8ba1b1120e | ||
|
|
0bc20caea5 | ||
|
|
537d165216 | ||
|
|
c1b8f1224c | ||
|
|
155c89b0c3 | ||
|
|
15f29e7d86 | ||
|
|
cc2bcdc41d | ||
|
|
39b727f498 | ||
|
|
3862423884 | ||
|
|
70c6086474 | ||
|
|
86f3d5bad6 | ||
|
|
54e9457920 | ||
|
|
23a93f52aa | ||
|
|
f5d5e77321 | ||
|
|
26439a2991 | ||
|
|
088d9e0f05 | ||
|
|
7d69701d39 | ||
|
|
8c5cb31e1b | ||
|
|
a18aaf1b6a | ||
|
|
c5cd470fdb | ||
|
|
f6c6d9aacc | ||
|
|
24be980004 | ||
|
|
a5b55ca8a9 | ||
|
|
f1b0c77c22 | ||
|
|
59ab025363 | ||
|
|
2b8d07c590 | ||
|
|
9136e3c84e | ||
|
|
e132119f07 | ||
|
|
6705986f27 | ||
|
|
6d0921cc0b | ||
|
|
3b3f5c364a | ||
|
|
8f8dab94e5 | ||
|
|
0d5a08ed92 | ||
|
|
b098b6d74c | ||
|
|
fe9888ad97 | ||
|
|
965fa326a1 | ||
|
|
e2310b5a91 | ||
|
|
c73a7f9ba0 | ||
|
|
370fb08e79 | ||
|
|
6092680305 | ||
|
|
5f825ee6d6 | ||
|
|
f914a8af2b | ||
|
|
6f65a3a7e8 | ||
|
|
1d269432b1 | ||
|
|
8392acd8fc | ||
|
|
12f417edbd | ||
|
|
c9acf8c766 | ||
|
|
fd4c58d7c5 | ||
|
|
9aa23ba5a8 | ||
|
|
541ffe30a2 | ||
|
|
55787401ea | ||
|
|
744b064a34 | ||
|
|
59d31b68c3 | ||
|
|
8ea28be6d2 | ||
|
|
0bcc813a34 | ||
|
|
b0970d4fed | ||
|
|
eb60d8bcd1 | ||
|
|
55bccf315e | ||
|
|
defcd5e75e | ||
|
|
6c6ea6cba2 | ||
|
|
92386561f1 | ||
|
|
05ebdd03d4 | ||
|
|
0810f723b1 | ||
|
|
09acc06c10 | ||
|
|
849083c886 | ||
|
|
b3dc3b8990 | ||
|
|
70a7855980 | ||
|
|
1171c2fcb4 | ||
|
|
be7499c83c | ||
|
|
a9711a5969 | ||
|
|
59c09d06e3 | ||
|
|
5e23e3d631 | ||
|
|
fa0443216d | ||
|
|
47b005217e | ||
|
|
5e8b3ea19d | ||
|
|
58a408512b | ||
|
|
7541e3a812 | ||
|
|
004827d715 | ||
|
|
1944f547bd | ||
|
|
28b3c53f0d | ||
|
|
01bda5de6b | ||
|
|
27c7bec4d4 | ||
|
|
e6e818309e | ||
|
|
e9e182e255 | ||
|
|
2d5b64273f | ||
|
|
a9819b2908 | ||
|
|
e9f07fb6e8 | ||
|
|
16fdbe8b27 | ||
|
|
a6cd07099d | ||
|
|
e111d69ca2 | ||
|
|
70da6a66d2 | ||
|
|
3680c58084 | ||
|
|
5e8c0ffb75 | ||
|
|
e75f6a972c | ||
|
|
e80a2633bc | ||
|
|
8eb5985f94 | ||
|
|
8a6b619c96 | ||
|
|
eac2636513 | ||
|
|
a1f9775981 | ||
|
|
24ac017961 | ||
|
|
0d2acb0ead | ||
|
|
86349776d0 | ||
|
|
1fa1adea2a | ||
|
|
0dab829977 | ||
|
|
bfa7967c4a | ||
|
|
8677d7b6ec | ||
|
|
e699b9f0fb | ||
|
|
4f1b0124c7 | ||
|
|
8abc78aa84 | ||
|
|
1b622ff5ac | ||
|
|
aefe5629ab | ||
|
|
95fa0ea3d4 | ||
|
|
6f6aa9b428 | ||
|
|
e3a94f7d08 |
No files matched your search
@@ -2,3 +2,4 @@ busybox
|
||||
busybox.links
|
||||
_install
|
||||
loop.h
|
||||
applet_source_list
|
||||
@@ -64,8 +64,8 @@ Gyepi Sam <gyepi@praxis-sw.com>
|
||||
Linus Torvalds <torvalds@transmeta.com>
|
||||
mkswap, fsck.minix, mkfs.minix
|
||||
|
||||
Mark Whitley <markw@lineo.com>
|
||||
sed remix, bug fixes, style-guide, etc.
|
||||
Mark Whitley <markw@lineo.com> <markw@codepoet.org>
|
||||
grep, sed, cut, xargs, style-guide, new-applet-HOWTO, bug fixes, etc.
|
||||
|
||||
Charles P. Wright <cpwright@villagenet.com>
|
||||
gzip, mini-netcat(nc)
|
||||
|
||||
@@ -1,3 +1,144 @@
|
||||
0.50
|
||||
* Erik Andersen -- added ifconfig interface status reporting
|
||||
* Erik Andersen -- Debian packaging updates
|
||||
* Erik Andersen -- lash environment variable expansion rewritten,
|
||||
with lots of help/fixes/testing from Larry Doolittle.
|
||||
* Erik Andersen -- Fix use of busybox with dmalloc debugging lib
|
||||
* Erik Andersen -- fixed ls behavior for broken or very narrow terminals.
|
||||
* Erik Andersen -- stub umount2 and pivot_root if they are not available.
|
||||
* Erik Andersen -- libc5 fixes
|
||||
* Erik Andersen -- make init work with devfsd
|
||||
* Erik Andersen -- fixed df for nfs and dos where blksize = 512
|
||||
* Erik Andersen -- Make sure libpwd.a is linked _last_ so it
|
||||
overrides the system pwd/grp
|
||||
* Christophe Boyanique -- added an optional egrep alias for grep.
|
||||
* Christophe Boyanique -- added optional 'rm -i' support.
|
||||
* Kenneth Chalmers and Erik Andersen -- fixed ln so it
|
||||
behaves when given no arguments (prints usage) and when
|
||||
given just one arg (tries to make a link in the cwd).
|
||||
* Magnus Damm -- added a tftp applet
|
||||
* Magnus Damm -- powerpc support for busybox insmod.
|
||||
* David Douthitt -- fixed a build error in df.c when
|
||||
BB_FEATURE_HUMAN_READABLE was disabled
|
||||
* John Beppu -- wrote autodocifier.pl, which will be used to auto-
|
||||
generate the documentation from the source code, making life
|
||||
much simpler for all.
|
||||
* Magnus Damm <damm@opensource.se> -- Fixed an 'inner scope var
|
||||
masking outer scope var with same name' bug that prevented
|
||||
the loopback device from being unmounted if mount() failed.
|
||||
* Larry Doolittle -- rewrote ifconfig to make it smaller
|
||||
* Larry Doolittle and Erik Andersen -- cleanups to pristine source
|
||||
* Larry Doolittle -- many bugfixes resulting from regression testing
|
||||
* Gennady Feldman -- split syslogd.c into syslogd and klogd
|
||||
* Gennady Feldman -- make syslogd single threaded -- no more forking
|
||||
* Jeff Garzik -- getopt-ified rmmod.
|
||||
* Jeff Garzik -- glibc 2.2 warning cleanups
|
||||
* Jeff Garzik -- namespace pollution cleanup (staticified variables).
|
||||
* Erik Gustavsson <cyrano@algonet.se> -- allow env variables set on the
|
||||
kernel command line to be inherited into init and its children.
|
||||
* Erik Habbinga -- fixed an uninitialized substitution delimiter in sed.
|
||||
* Chris Jaeger -- Makefile cleanup to make option setting less error-prone
|
||||
* Chris Jaeger <cjaeger@ensim.com> -- Carefully check NFS_MOUNT_VERSION
|
||||
depending on what kernel is being used.
|
||||
* Quinn Jensen <jensenq@lineo.com> -- MIPS support for busybox insmod.
|
||||
* Evin Robertson -- new pivot_root applet
|
||||
* Kent Robotti -- usage message cleanups
|
||||
* Kent Robotti -- reworked dos2unix/unix2dos
|
||||
* Evin Robertson and Manuel Novoa III -- reworked how usage messages
|
||||
are stored to save several k of space.
|
||||
* Matt Kraai -- Keep trying if an NFS mount fails
|
||||
* Matt Kraai -- fixed insmod so it won't try to insmod directories.
|
||||
* Matt Kraai -- added nc listening support
|
||||
* Matt Kraai and David Douthitt -- reworked fine to support -type,
|
||||
-perm, -mtime, and other improvements.
|
||||
* Matt Kraai -- added find_applet_by_name and saved some memory thereby
|
||||
* Matt Kraai -- added chomp to reduce redundant code elsewhere
|
||||
* Matt Kraai -- Removed trailing \n chars from error_msg{,_and_die} messages.
|
||||
* John Lombardo -- fixed OOM in insmod.
|
||||
* Glenn McGrath -- bypass /proc in mount, now uses sysfs.
|
||||
* Glenn McGrath -- several updates to dpkg and dpkg-deb.
|
||||
* Manuel Novoa III -- several size optimizations: parse_mode,
|
||||
process_escape_sequence, format, and get_kernel_revision.
|
||||
* Manuel Novoa III -- rewrote ifconfig again to make it smaller still
|
||||
* Manuel Novoa III -- added ifconfig -a, updated interface reporting
|
||||
* Vladimir N. Oleynik -- Fixed a bug where init set PATH incorrectly
|
||||
* Vladimir N. Oleynik -- cleanups to route, cmdedit, mkdir,
|
||||
mkfs_minix, mkswap, chmod_chown_chgrp and utility.c
|
||||
* Vladimir N. Oleynik -- many fixes to cmdedit. so tab completion
|
||||
is now working and general editing is much improved, and to
|
||||
improve complex prompt handling.
|
||||
* Vladimir N. Oleynik -- added route status reporting.
|
||||
* Vladimir N. Oleynik -- fixed wget to use xfopen
|
||||
* Vladimir N. Oleynik -- new stty applet
|
||||
* Vladimir N. Oleynik -- fixed find, it used to stop on perm errors.
|
||||
* Vladimir N. Oleynik -- locale forced to posix for scripts
|
||||
* Vladimir N. Oleynik -- saved 128 bytes by moving error checking
|
||||
for several my_* functions into utility.c
|
||||
* Bjorn Wesen -- new ifconfig and route applet (taken from
|
||||
work done by Axis Communications).
|
||||
* Mark Whitley -- Added a 'How to contribute to Busybox' doc
|
||||
and updated the style guide.
|
||||
* Mark Whitley -- implemented grep -A, -B, and -C
|
||||
* Mark Whitley -- overhauled the test suite.
|
||||
|
||||
|
||||
-Erik Andersen, 15 March 2001
|
||||
|
||||
0.49
|
||||
|
||||
* Matt Kraai -- new sort.c
|
||||
* Matt Kraai -- new tail.c
|
||||
* Glenn McGrath -- new 'dpkg-deb' applet
|
||||
* Glenn McGrath -- new ar code
|
||||
* spoon -- new watchdog applet
|
||||
* Vladimir N. Oleynik <dzo@simtreas.ru> -- fixed cmdedit.c so now
|
||||
scrolling and tab completion in lash work properly. Also several
|
||||
byte saving optimizations.
|
||||
* Erik Andersen -- disabled many less commonly used applets by default
|
||||
* Mark Whitley -- more thrashing about to get clean perror_msg usage
|
||||
* Matt Kraai -- new command line munging
|
||||
* Larry Doolittle -- keep some locales from messing up busybox.sh
|
||||
* Matt Kraai -- cleaned up dd and tail with new parse_number routine
|
||||
* Mark Whitley -- remove debugging messages from deallocvt
|
||||
* Matt Kraai and Mark Whitley -- new document "How to Add a New Applet
|
||||
to BusyBox"
|
||||
* David Douthitt -- fixed "grep -qv" bug
|
||||
* Larry Doolittle -- fixed insmod bug with old kernels
|
||||
* Matt Kraai -- logger remixed to use getopt, selection of stdin made
|
||||
util-linux compatible
|
||||
* Erik Andersen -- many more internal symbols classified static to
|
||||
avoid namespace pollution
|
||||
* Matt Kraai -- nc listening support
|
||||
* Erik Andersen -- made sed understand arbitrary regexp delimiters
|
||||
* Matt Kraai et al. -- more tar improvements and bug fixes, now
|
||||
handles regexp file exclusion
|
||||
* Larry Doolittle -- new script (multibuild.pl) to automate build rule
|
||||
checking
|
||||
* Matt Kraai -- update/cleanup of the docs on how to use init
|
||||
* Erik Andersen -- renamed all sh.c symbols per the style guide,
|
||||
better if-then-else-fi handling
|
||||
* Erik Andersen -- cleaner division of labor between cmdedit.c and sh.c
|
||||
* Larry Doolittle -- shell data structure cleanup, fixed buglets
|
||||
in read, exec, and piped builtins
|
||||
* Erik Andersen -- md5sum was broken in 0.48. Now fixed (and doesn't
|
||||
use getline, shrinking static compiles (since nothing else used it).
|
||||
* ?? -- squashed memory leak in shell prompt handling
|
||||
* Mark Whitley -- Updates to style guide
|
||||
* Mark Whitley -- Big cleanup in utility.c: style guide compliance,
|
||||
de-macro-ifying some variables and functions
|
||||
* Erik Andersen -- ls now honors BB_FEATURE_AUTOWIDTH so it can find
|
||||
the width and height of the console.
|
||||
* Erik Andersen -- insmod now ignores -L and accepts the -o option.
|
||||
* Erik Andersen -- updates so you can now select from the Makefile
|
||||
whether or not to use the system's passwd and group functions.
|
||||
Since most systems use GNU libc, this can save you from having to
|
||||
install the /etc/nsswitch.conf configuration file and the required
|
||||
libnss_* libraries. Adds 1.5k. You can now, also, disable this,
|
||||
causing busybox to use the system's pwd.h and grp.h functions.
|
||||
|
||||
|
||||
-Erik Andersen, 27 January 2001
|
||||
|
||||
0.48
|
||||
|
||||
* Glenn McGrath -- tar now supports uncompressing tar files,
|
||||
|
||||
@@ -7,114 +7,122 @@
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
//#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
#define BB_CMP
|
||||
//#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
//#define BB_DC
|
||||
#define BB_DD
|
||||
#define BB_DEALLOCVT
|
||||
//#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
#define BB_DOS2UNIX
|
||||
#define BB_DUTMP
|
||||
//#define BB_DOS2UNIX
|
||||
//#define BB_DPKG
|
||||
//#define BB_DPKG_DEB
|
||||
//#define BB_DUTMP
|
||||
#define BB_DU
|
||||
#define BB_DUMPKMAP
|
||||
//#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
#define BB_FBSET
|
||||
#define BB_FDFLUSH
|
||||
//#define BB_EXPR
|
||||
//#define BB_FBSET
|
||||
//#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FREE
|
||||
#define BB_FREERAMDISK
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
//#define BB_FREERAMDISK
|
||||
//#define BB_FSCK_MINIX
|
||||
//#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
//#define BB_HOSTID
|
||||
//#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_IFCONFIG
|
||||
#define BB_INIT
|
||||
#define BB_INSMOD
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_LENGTH
|
||||
#define BB_KLOGD
|
||||
//#define BB_LENGTH
|
||||
#define BB_LN
|
||||
#define BB_LOADACM
|
||||
#define BB_LOADFONT
|
||||
#define BB_LOADKMAP
|
||||
//#define BB_LOADACM
|
||||
//#define BB_LOADFONT
|
||||
//#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
//#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
#define BB_MAKEDEVS
|
||||
#define BB_MD5SUM
|
||||
//#define BB_MAKEDEVS
|
||||
//#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
//#define BB_MKFIFO
|
||||
//#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
//#define BB_MKTEMP
|
||||
//#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
#define BB_PING
|
||||
//#define BB_MT
|
||||
//#define BB_NSLOOKUP
|
||||
//#define BB_PING
|
||||
//#define BB_PIVOT_ROOT
|
||||
#define BB_POWEROFF
|
||||
#define BB_PRINTF
|
||||
//#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
#define BB_READLINK
|
||||
//#define BB_RDATE
|
||||
//#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
#define BB_RENICE
|
||||
//#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
#define BB_RMMOD
|
||||
#define BB_RPMUNPACK
|
||||
//#define BB_RMMOD
|
||||
//#define BB_ROUTE
|
||||
//#define BB_RPMUNPACK
|
||||
#define BB_SED
|
||||
#define BB_SETKEYCODES
|
||||
//#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_STTY
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_SYSLOGD
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
#define BB_TELNET
|
||||
//#define BB_TEE
|
||||
//#define BB_TEST
|
||||
//#define BB_TELNET
|
||||
//#define BB_TFTP
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
//#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
#define BB_UPTIME
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
//#define BB_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
#define BB_UNIX2DOS
|
||||
#define BB_UPDATE
|
||||
//#define BB_UPDATE
|
||||
#define BB_UPTIME
|
||||
//#define BB_USLEEP
|
||||
//#define BB_WATCHDOG
|
||||
#define BB_WC
|
||||
//#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
@@ -127,28 +135,26 @@
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
// BusyBox will, by default, malloc space for its buffers. This costs code
|
||||
// size for the call to xmalloc. You can use the following feature to have
|
||||
// them put on the stack. For some very small machines with limited stack
|
||||
// space, this can be deadly. For most folks, this works just fine...
|
||||
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// lots and lots memory for more important things. NOTE: If you enable this
|
||||
// feature, you _must_ have patched the kernel to include the devps patch that
|
||||
// is included in the busybox/kernel-patches directory. You will also need to
|
||||
// create some device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
@@ -156,7 +162,7 @@
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
// show username/groupnames for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
@@ -186,22 +192,17 @@
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
// enable syslogd -C
|
||||
//#define BB_FEATURE_IPC_SYSLOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
@@ -219,6 +220,9 @@
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// use -i (interactive) flag for rm
|
||||
//#define BB_FEATURE_RM_INTERACTIVE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
@@ -231,13 +235,22 @@
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
// Enable command line editing in the shell.
|
||||
// Only relevant if BB_SH is enabled. On by default.
|
||||
#define BB_FEATURE_COMMAND_EDITING
|
||||
//
|
||||
// Enable tab completion in the shell. This is now working quite nicely.
|
||||
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
//
|
||||
// Attempts to match usernames in a ~-prefixed path
|
||||
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//among other things. Off by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
//#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell applets can be called using full path
|
||||
//names. This causes applets (i.e., most busybox commands) to override
|
||||
@@ -245,11 +258,15 @@
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
// Only relevant if BB_SH is enabled. Off by default.
|
||||
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
// Some deeply embedded systems don't have usernames or even hostnames,
|
||||
// and the default prompt can look rather hideous on them. Uncomment
|
||||
// this option for a simpler, path-only prompt (which was the default until
|
||||
// around BusyBox-0.48). On by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
@@ -257,17 +274,11 @@
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
// Support insmod/lsmod/rmmod for post 2.1 kernels
|
||||
//#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support modules status from pre 2.1 kernels
|
||||
//#define BB_FEATURE_LSMOD_OLD_KERNEL
|
||||
// Support modules status from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_LSMOD_NEW_KERNEL
|
||||
// Support insmod/lsmod/rmmod for pre 2.1 kernels
|
||||
//#define BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
@@ -275,6 +286,17 @@
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
// Enable ifconfig status reporting output -- this feature adds 12k.
|
||||
//#define BB_FEATURE_IFCONFIG_STATUS
|
||||
//
|
||||
// Enable ifconfig slip-specific options "keepalive" and "outfill"
|
||||
//#define BB_FEATURE_IFCONFIG_SLIP
|
||||
//
|
||||
// Enable ifconfig options "mem_start", "io_addr", and "irq".
|
||||
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
|
||||
//
|
||||
// Enable ifconfig option "hw". Currently works for only with "ether".
|
||||
//#define BB_FEATURE_IFCONFIG_HW
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
@@ -282,13 +304,35 @@
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
//#define BB_FEATURE_STATUSBAR
|
||||
#define BB_FEATURE_WGET_STATUSBAR
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
|
||||
#define BB_FEATURE_HUMAN_READABLE
|
||||
//
|
||||
// Support for the find -type option.
|
||||
#define BB_FEATURE_FIND_TYPE
|
||||
//
|
||||
// Support for the find -perm option.
|
||||
#define BB_FEATURE_FIND_PERM
|
||||
//
|
||||
// Support for the find -mtine option.
|
||||
#define BB_FEATURE_FIND_MTIME
|
||||
//
|
||||
// Support for the -A -B and -C context flags in grep
|
||||
//#define BB_FEATURE_GREP_CONTEXT
|
||||
//
|
||||
// Support for the EGREP applet (alias to the grep applet)
|
||||
//#define BB_FEATURE_GREP_EGREP_ALIAS
|
||||
//
|
||||
// Tell tftp what commands that should be supported.
|
||||
#define BB_FEATURE_TFTP_PUT
|
||||
#define BB_FEATURE_TFTP_GET
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
@@ -300,59 +344,105 @@
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#else
|
||||
#undef BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG
|
||||
#ifndef BB_DPKG_DEB
|
||||
#define BB_DPKG_DEB
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG_DEB
|
||||
#ifndef BB_AR
|
||||
#define BB_AR
|
||||
#endif
|
||||
#ifndef BB_TAR
|
||||
#define BB_TAR
|
||||
#endif
|
||||
#ifndef BB_FEATURE_TAR_GZIP
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
#if defined BB_IFCONFIG
|
||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||
#define BB_INTERFACE
|
||||
#endif
|
||||
#else
|
||||
#undef BB_INTERFACE
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_SYSLOGD
|
||||
#if defined BB_FEATURE_IPC_SYSLOG
|
||||
#define BB_LOGREAD
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_DOS2UNIX
|
||||
#define BB_UNIX2DOS
|
||||
#endif
|
||||
+84
-29
@@ -189,9 +189,6 @@
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
@@ -212,6 +209,9 @@
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// use -i (interactive) flag for rm
|
||||
//#define BB_FEATURE_RM_INTERACTIVE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
@@ -273,51 +273,106 @@
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#else
|
||||
#undef BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG
|
||||
#ifndef BB_DPKG_DEB
|
||||
#define BB_DPKG_DEB
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG_DEB
|
||||
#ifndef BB_AR
|
||||
#define BB_AR
|
||||
#endif
|
||||
#ifndef BB_TAR
|
||||
#define BB_TAR
|
||||
#endif
|
||||
#ifndef BB_FEATURE_TAR_GZIP
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
#if defined BB_IFCONFIG
|
||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||
#define BB_INTERFACE
|
||||
#endif
|
||||
#else
|
||||
#undef BB_INTERFACE
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_SYSLOGD
|
||||
#if defined BB_FEATURE_IPC_SYSLOG
|
||||
#define BB_LOGREAD
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_DOS2UNIX
|
||||
#define BB_UNIX2DOS
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@ mini-gzip(gzip), mini-netcat(mnc)
|
||||
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
|
||||
|
||||
Tons of new stuff as noted in header files
|
||||
Copyright (C) 1999 by Lineo, inc. and written by
|
||||
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
|
||||
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org>
|
||||
# Copyright (C) 1999,2000,2001 Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -19,7 +18,7 @@
|
||||
#
|
||||
|
||||
PROG := busybox
|
||||
VERSION := 0.48
|
||||
VERSION := 0.50
|
||||
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
|
||||
export VERSION
|
||||
|
||||
@@ -28,6 +27,11 @@ export VERSION
|
||||
# overridden at the command line. For example:
|
||||
# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
|
||||
|
||||
# If you want to add some simple compiler switches (like -march=i686),
|
||||
# especially from the command line, use this instead of CFLAGS directly.
|
||||
# For optimization overrides, it's better still to set OPTIMIZATION.
|
||||
CFLAGS_EXTRA =
|
||||
|
||||
# If you want a static binary, turn this on.
|
||||
DOSTATIC = false
|
||||
|
||||
@@ -37,6 +41,17 @@ DOSTATIC = false
|
||||
# Do not enable this for production builds...
|
||||
DODEBUG = false
|
||||
|
||||
# Setting this to `true' will cause busybox to directly use the system's
|
||||
# password and group functions. Assuming you use GNU libc, when this is
|
||||
# `true', you will need to install the /etc/nsswitch.conf configuration file
|
||||
# and the required libnss_* libraries. This generally makes your embedded
|
||||
# system quite a bit larger... If you leave this off, busybox will directly
|
||||
# use the /etc/password, /etc/group files (and your system will be smaller, and
|
||||
# I will get fewer emails asking about how glibc NSS works). Enabling this adds
|
||||
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs),
|
||||
# Most people will want to leave this set to false.
|
||||
USE_SYSTEM_PWD_GRP = true
|
||||
|
||||
# This enables compiling with dmalloc ( http://dmalloc.com/ )
|
||||
# which is an excellent public domain mem leak and malloc problem
|
||||
# detector. To enable dmalloc, before running busybox you will
|
||||
@@ -57,44 +72,65 @@ DOLFS = false
|
||||
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
|
||||
# Experimental and incomplete; tell the mailing list
|
||||
# <busybox@opensource.lineo.com> if you do or don't like it so far.
|
||||
BB_SRC_DIR = .
|
||||
BB_SRC_DIR =
|
||||
|
||||
# If you are running a cross compiler, you may want to set this
|
||||
# to something more interesting, like "powerpc-linux-".
|
||||
CROSS =
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
STRIPTOOL = $(CROSS)strip
|
||||
|
||||
# To compile vs an alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs. This is how I make
|
||||
# busybox compile with uC-Libc (needs BB_GETOPT and BB_FEATURE_NFSMOUNT
|
||||
# disabled at the moment).
|
||||
#LIBCDIR=/home/andersen/CVS/uClibc
|
||||
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
|
||||
# This make things very easy? Everything should compile and work as
|
||||
# expected these days...
|
||||
#CC = ../uClibc/extra/gcc-uClibc/gcc-uClibc-i386
|
||||
|
||||
# To compile vs some other alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs...
|
||||
#
|
||||
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
|
||||
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
|
||||
# using the compatible RPMs (compat-*) at http://www.redhat.com !
|
||||
#LIBCDIR=/usr/i386-glibc20-linux
|
||||
#
|
||||
# The following is used for libc5 (if you install altgcc and libc5-altdev
|
||||
# on a Debian system).
|
||||
#LIBCDIR=/usr/i486-linuxlibc1
|
||||
#
|
||||
# For other libraries, you are on your own...
|
||||
#LDFLAGS+=-nostdlib
|
||||
#LIBRARIES = $(LIBCDIR)/libc.a -lgcc
|
||||
#LIBRARIES = $(LIBCDIR)/lib/libc.a -lgcc
|
||||
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
|
||||
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
#--------------------------------------------------------
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
||||
OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
||||
then echo "-Os"; else echo "-O2" ; fi)
|
||||
|
||||
WARNINGS = -Wall
|
||||
|
||||
ifeq ($(DOLFS),true)
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# If you're going to do a lot of builds with a non-vanilla configuration,
|
||||
# it makes sense to adjust parameters above, so you can type "make"
|
||||
# by itself, instead of following it by the same half-dozen overrides
|
||||
# every time. The stuff below, on the other hand, is probably less
|
||||
# prone to casual user adjustment.
|
||||
#
|
||||
|
||||
ifeq ($(strip $(DOLFS)),true)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_FILE_OFFSET_BITS=64
|
||||
endif
|
||||
ifeq ($(DODMALLOC),true)
|
||||
ifeq ($(strip $(DODMALLOC)),true)
|
||||
# For testing mem leaks with dmalloc
|
||||
CFLAGS+=-DDMALLOC
|
||||
LIBRARIES = -ldmalloc
|
||||
# Force debug=true, since this is useless when not debugging...
|
||||
DODEBUG = true
|
||||
endif
|
||||
ifeq ($(DODEBUG),true)
|
||||
ifeq ($(strip $(DODEBUG)),true)
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIP =
|
||||
@@ -103,7 +139,7 @@ else
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
endif
|
||||
ifeq ($(DOSTATIC),true)
|
||||
ifeq ($(strip $(DOSTATIC)),true)
|
||||
LDFLAGS += --static
|
||||
#
|
||||
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
|
||||
@@ -123,30 +159,78 @@ ifndef $(PREFIX)
|
||||
endif
|
||||
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# Config.h in the build directory should take precedence over the
|
||||
# copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# Include files in the build directory should take precedence over
|
||||
# the copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
#
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
# If it gets in your way, set DISABLE_VPATH=yes
|
||||
ifeq ($(DISABLE_VPATH),yes)
|
||||
CONFIG_H = Config.h
|
||||
else
|
||||
VPATH = .:$(BB_SRC_DIR)
|
||||
CONFIG_LIST = $(addsuffix /Config.h,$(subst :, ,$(VPATH)))
|
||||
CONFIG_H = $(word 1,$(shell ls -f -1 $(CONFIG_LIST) 2>/dev/null))
|
||||
CFLAGS += -I- $(patsubst %,-I%,$(subst :, ,$(VPATH))) $(CROSS_CFLAGS)
|
||||
#
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
VPATH = $(BB_SRC_DIR)
|
||||
endif
|
||||
#ifneq ($(strip $(VPATH)),)
|
||||
# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
|
||||
#endif
|
||||
|
||||
OBJECTS = $(shell $(BB_SRC_DIR)/busybox.sh $(CONFIG_H) $(BB_SRC_DIR)) busybox.o messages.o usage.o utility.o
|
||||
# We need to set APPLET_SOURCES to something like
|
||||
# $(shell busybox.sh Config.h)
|
||||
# but in a manner that works with VPATH and BB_SRC_DIR.
|
||||
# Possible ways to approach this:
|
||||
#
|
||||
# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
|
||||
# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
|
||||
#
|
||||
# 2. Explicity search through .:$(VPATH) for slist.mk,
|
||||
# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
|
||||
#
|
||||
# 3. Create slist.mk in this directory, with commands embedded in
|
||||
# a $(shell ...) command, and $(MAKE) it immediately.
|
||||
#
|
||||
# 4. Use a real rule within this makefile to create a file that sets
|
||||
# APPLET_SOURCE_LIST, then include that file. Has complications
|
||||
# with the first trip through the makefile (before processing the
|
||||
# include) trying to do too much, and a spurious warning the first
|
||||
# time make is run.
|
||||
#
|
||||
# This is option 3:
|
||||
#
|
||||
#APPLET_SOURCES = $(shell \
|
||||
# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
|
||||
# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
|
||||
#)
|
||||
# And option 4:
|
||||
-include applet_source_list
|
||||
|
||||
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o messages.o usage.o utility.o
|
||||
CFLAGS += $(CROSS_CFLAGS)
|
||||
CFLAGS += -DBB_VER='"$(VERSION)"'
|
||||
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
|
||||
ifdef BB_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
|
||||
PWD_GRP = pwd_grp
|
||||
PWD_GRP_DIR = $(BB_SRC_DIR:=/)$(PWD_GRP)
|
||||
PWD_LIB = libpwd.a
|
||||
PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
|
||||
fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
|
||||
initgroups.c setgroups.c
|
||||
PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
|
||||
PWD_CFLAGS = -I$(PWD_GRP_DIR)
|
||||
else
|
||||
CFLAGS += -DUSE_SYSTEM_PWD_GRP
|
||||
endif
|
||||
|
||||
all: busybox busybox.links doc
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
all: applet_source_list busybox busybox.links doc
|
||||
|
||||
applet_source_list: busybox.sh Config.h
|
||||
(echo -n "APPLET_SOURCES := "; $(SHELL) $^ $(BB_SRC_DIR)) > $@
|
||||
|
||||
doc: olddoc
|
||||
|
||||
@@ -158,20 +242,21 @@ docs/BusyBox.txt: docs/busybox.pod
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
-mkdir -p docs
|
||||
-pod2text $(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.txt
|
||||
-pod2text $< > $@
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.1
|
||||
$< > $@
|
||||
|
||||
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
|
||||
- mkdir -p docs
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
|
||||
-@ mkdir -p docs/busybox.lineo.com
|
||||
- pod2html --noindex $(BB_SRC_DIR)/docs/busybox.pod > \
|
||||
- pod2html --noindex $< > \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
-@ rm -f pod2html*
|
||||
|
||||
@@ -203,24 +288,40 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
|
||||
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
|
||||
|
||||
|
||||
|
||||
busybox: $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
|
||||
busybox: $(PWD_LIB) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBRARIES) $(PWD_LIB)
|
||||
$(STRIP)
|
||||
|
||||
busybox.links: Config.h
|
||||
- $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@
|
||||
# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
|
||||
# but with VPATH, some or all of those file names are resolved to the
|
||||
# directories in which they live.
|
||||
busybox.links: busybox.mkll Config.h applets.h
|
||||
- $(SHELL) $^ >$@
|
||||
|
||||
nfsmount.o cmdedit.o: %.o: %.h
|
||||
$(OBJECTS): %.o: %.c Config.h busybox.h Makefile
|
||||
sh.o: cmdedit.h
|
||||
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
$(CC) -I- $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
|
||||
|
||||
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
- mkdir -p $(PWD_GRP)
|
||||
$(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
|
||||
|
||||
libpwd.a: $(PWD_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
usage.o: usage.h
|
||||
|
||||
utility.o: loop.h
|
||||
|
||||
loop.h: mk_loop_h.sh
|
||||
@ sh $<
|
||||
@ $(SHELL) $< > $@
|
||||
|
||||
test tests:
|
||||
cd tests && $(MAKE) all
|
||||
# old way of doing it
|
||||
#cd tests && $(MAKE) all
|
||||
# new way of doing it
|
||||
cd tests && ./tester.sh
|
||||
|
||||
clean:
|
||||
- cd tests && $(MAKE) clean
|
||||
@@ -228,23 +329,23 @@ clean:
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
|
||||
- rm -rf docs/busybox _install
|
||||
- rm -f busybox.links loop.h *~ *.o core
|
||||
- rm -f multibuild.log Config.h.orig
|
||||
- rm -rf docs/busybox _install libpwd.a
|
||||
- rm -f busybox.links loop.h *~ slist.mk core applet_source_list
|
||||
- find -name \*.o -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f busybox
|
||||
- cd tests && $(MAKE) distclean
|
||||
|
||||
install: busybox busybox.links
|
||||
$(BB_SRC_DIR)/install.sh $(PREFIX)
|
||||
install: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
|
||||
install-hardlinks: busybox busybox.links
|
||||
$(BB_SRC_DIR)/install.sh $(PREFIX) --hardlinks
|
||||
install-hardlinks: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
debug_pristine:
|
||||
@ echo VPATH=\"$(VPATH)\"
|
||||
@ echo CONFIG_LIST=\"$(CONFIG_LIST)\"
|
||||
@ echo CONFIG_H=\"$(CONFIG_H)\"
|
||||
@ echo OBJECTS=\"$(OBJECTS)\"
|
||||
|
||||
dist release: distclean doc
|
||||
@@ -255,17 +356,17 @@ dist release: distclean doc
|
||||
find busybox-$(VERSION)/ -type d \
|
||||
-name CVS \
|
||||
-print \
|
||||
| xargs rm -rf; \
|
||||
-exec rm -rf {} \; ; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .cvsignore \
|
||||
-print \
|
||||
| xargs rm -f; \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
| xargs rm -f; \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ the expected functionality and behave very much like their GNU counterparts.
|
||||
BusyBox has been written with size-optimization and limited resources in mind.
|
||||
It is also extremely modular so you can easily include or exclude commands (or
|
||||
features) at compile time. This makes it easy to customize your embedded
|
||||
systems. To create a working system, just add a kernel and an editor (such as
|
||||
e3 (http://www.sax.de/~adlibiti) or elvis-tiny).
|
||||
systems. To create a working system, just add /dev, a kernel, and an editor,
|
||||
such as nano, e3, or elvis-tiny. For a really minimal system, you can even use
|
||||
the busybox shell (not Bourne compatible, but very small and quite usable).
|
||||
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
@@ -27,7 +28,25 @@ After the build is complete, a busybox.links file is generated. This is
|
||||
used by 'make install' to create symlinks to the busybox binary for all
|
||||
compiled in functions. By default, 'make install' will place the symlink
|
||||
forest into `pwd`/_install unless you have defined the PREFIX environment
|
||||
variable (i.e., make PREFIX="/tmp/foo" install)
|
||||
variable (i.e., 'make PREFIX=/tmp/foo install')
|
||||
|
||||
----------------
|
||||
|
||||
Supported architectures:
|
||||
|
||||
Busybox in general will build on any architecture supported by gcc. It has
|
||||
a few specialized features added for __sparc__ and __alpha__. insmod
|
||||
functionality is currently limited to x86, ARM, and SH3/4.
|
||||
|
||||
Supported libcs:
|
||||
|
||||
glibc-2.0.x, glibc-2.1.x, Linux-libc5, uClibc. People are looking at
|
||||
newlib and diet-libc, but consider them unsupported, untested, or worse.
|
||||
|
||||
Supported kernels:
|
||||
|
||||
Full functionality requires Linux 2.0.x, 2.2.x, or 2.4.x. A large fraction
|
||||
of the code should run on just about anything.
|
||||
|
||||
----------------
|
||||
|
||||
|
||||
@@ -6,10 +6,18 @@ around to it some time. If you have any good ideas, please let me know.
|
||||
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
|
||||
needed or wanted in busybox (or else I'd have to link to libcrypt).
|
||||
|
||||
* Networking apps are going to be split out to a new package called netkit-tiny
|
||||
before the next release of Busybox. This will remove the following items
|
||||
from BusyBox: hostid, hostname, nc, nslookup, telnet, and ping. nfs
|
||||
mounting and syslogd (network logging) will remain in BusyBox.
|
||||
* We _were_ going to split networking apps into a new package called
|
||||
netkit-tiny. Per discussions on the mailing list, this isn't going
|
||||
to happen. False alarm. Sorry about the confusion.
|
||||
|
||||
* The busybox shell, lash, is really too weak for serious use, although it is
|
||||
possible to run simple systems with it. BusyBox 0.49 was supposed to have
|
||||
a new shell, updated to understand full Bourne grammer. Well, that simply
|
||||
didn't happen in time for the release. A rewrite is in progress that will
|
||||
result in a new shell that understands the full Bourne grammar. This new
|
||||
shell is being championed by Larry Doolittle <ldoolitt@recycle.lbl.gov>, and
|
||||
could use your help. Please see the work in progress at
|
||||
http://doolittle.faludi.com/~larry/parser.html
|
||||
|
||||
-Erik
|
||||
|
||||
@@ -18,43 +26,24 @@ around to it some time. If you have any good ideas, please let me know.
|
||||
Possible apps to include some time:
|
||||
|
||||
* hwclock
|
||||
* stty
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
|
||||
-----------------------
|
||||
-----------
|
||||
|
||||
The Busybox lash shell needs to be taught Bourne shell grammer. This
|
||||
is planned for the next release of Busybox. Look out ash, we are coming
|
||||
for you...
|
||||
Write a fixup_globals function to do just that right before calling
|
||||
non-forking applets. Or, just always fork...
|
||||
|
||||
-----------------------
|
||||
|
||||
Running the following:
|
||||
Run the following:
|
||||
|
||||
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
|
||||
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
|
||||
|
||||
reveals the list of all external (i.e. libc) things that BusyBox depends on.
|
||||
It would be a very nice thing to reduce this list to an absolute minimum, to
|
||||
reduce the footprint of busybox when staticly linking with libraries such as
|
||||
uClibc.
|
||||
|
||||
-----------------------
|
||||
|
||||
Currently, busybox bypasses libc NSS. Some folks might want that,
|
||||
so perhaps adding in the option to choose whether to go to libc for
|
||||
things like getpwnam() or whether to use the busybox version might
|
||||
be nice.
|
||||
|
||||
-----------------------
|
||||
|
||||
Most wanted list:
|
||||
|
||||
[andersen@slag busybox]$ grep -l getgroups *.[ch]
|
||||
test.c
|
||||
|
||||
Policy violation. getgroups uses libc nss, which is unlikely
|
||||
to be present in an embedded system.
|
||||
reduce the footprint of busybox, especially when staticly linking with
|
||||
libraries such as uClibc.
|
||||
|
||||
-----------------------
|
||||
|
||||
|
||||
@@ -10,382 +10,433 @@
|
||||
* file result in the listing remaining in ascii order. You have been warned.
|
||||
*/
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_ODDNAME
|
||||
#undef APPLET_NOUSAGE
|
||||
|
||||
|
||||
#if defined(PROTOTYPES)
|
||||
#define APPLET(a,b,c,d) \
|
||||
extern int b(int argc, char **argv); \
|
||||
extern const char d[];
|
||||
#define APPLET_NOUSAGE(a,b,c) \
|
||||
extern int b(int argc, char **argv);
|
||||
#define APPLET(a,b,c) extern int b(int argc, char **argv);
|
||||
#define APPLET_NOUSAGE(a,b,c) extern int b(int argc, char **argv);
|
||||
#define APPLET_ODDNAME(a,b,c,d) extern int b(int argc, char **argv);
|
||||
extern const char usage_messages[];
|
||||
#elif defined(MAKE_USAGE)
|
||||
#ifdef BB_FEATURE_TRIVIAL_HELP
|
||||
#define APPLET(a,b,c) a##_trivial_usage "\0"
|
||||
#define APPLET_NOUSAGE(a,b,c) "\0"
|
||||
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\0"
|
||||
#else
|
||||
#define APPLET(a,b,c) a##_trivial_usage "\n\n" a##_full_usage "\0"
|
||||
#define APPLET_NOUSAGE(a,b,c) "\0"
|
||||
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\n\n" d##_full_usage "\0"
|
||||
#endif
|
||||
#elif defined(MAKE_LINKS)
|
||||
#define APPLET(a,b,c,d) LINK c a
|
||||
#define APPLET_NOUSAGE(a,b,c) LINK c a
|
||||
# define APPLET(a,b,c) LINK c a
|
||||
# define APPLET_NOUSAGE(a,b,c) LINK c a
|
||||
# define APPLET_ODDNAME(a,b,c,d) LINK c a
|
||||
#else
|
||||
const struct BB_applet applets[] = {
|
||||
#define APPLET(a,b,c,d) {a,b,c,d},
|
||||
#define APPLET_NOUSAGE(a,b,c) {a,b,c,NULL},
|
||||
const struct BB_applet applets[] = {
|
||||
#define APPLET(a,b,c) {#a,b,c},
|
||||
#define APPLET_NOUSAGE(a,b,c) {a,b,c},
|
||||
#define APPLET_ODDNAME(a,b,c,d) {a,b,c},
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef BB_TEST
|
||||
APPLET("[", test_main, _BB_DIR_USR_BIN, test_usage)
|
||||
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_AR
|
||||
APPLET("ar", ar_main, _BB_DIR_USR_BIN, ar_usage)
|
||||
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
APPLET("basename", basename_main, _BB_DIR_USR_BIN, basename_usage)
|
||||
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
|
||||
#ifdef BB_CAT
|
||||
APPLET("cat", cat_main, _BB_DIR_BIN, cat_usage)
|
||||
APPLET(cat, cat_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage)
|
||||
APPLET(chgrp, chmod_chown_chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chmod", chmod_chown_chgrp_main, _BB_DIR_BIN, chmod_usage)
|
||||
APPLET(chmod, chmod_chown_chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chown", chmod_chown_chgrp_main, _BB_DIR_BIN, chown_usage)
|
||||
APPLET(chown, chmod_chown_chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
APPLET("chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage)
|
||||
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
APPLET("chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage)
|
||||
APPLET(chvt, chvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
APPLET("clear", clear_main, _BB_DIR_USR_BIN, clear_usage)
|
||||
APPLET(clear, clear_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CMP
|
||||
APPLET("cmp", cmp_main, _BB_DIR_USR_BIN, cmp_usage)
|
||||
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET("cp", cp_mv_main, _BB_DIR_BIN, cp_usage)
|
||||
APPLET(cp, cp_mv_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
APPLET("cut", cut_main, _BB_DIR_USR_BIN, cut_usage)
|
||||
APPLET(cut, cut_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
APPLET("date", date_main, _BB_DIR_BIN, date_usage)
|
||||
APPLET(date, date_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
APPLET("dc", dc_main, _BB_DIR_USR_BIN, dc_usage)
|
||||
APPLET(dc, dc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
APPLET("dd", dd_main, _BB_DIR_BIN, dd_usage)
|
||||
APPLET(dd, dd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
APPLET("deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage)
|
||||
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
APPLET("df", df_main, _BB_DIR_BIN, df_usage)
|
||||
APPLET(df, df_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
APPLET("dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage)
|
||||
APPLET(dirname, dirname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
APPLET("dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage)
|
||||
APPLET(dmesg, dmesg_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
APPLET("dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage)
|
||||
APPLET(dos2unix, dos2unix_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DPKG
|
||||
APPLET(dpkg, dpkg_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DPKG_DEB
|
||||
APPLET_ODDNAME("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb)
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
APPLET("du", du_main, _BB_DIR_USR_BIN, du_usage)
|
||||
APPLET(du, du_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
APPLET("dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage)
|
||||
APPLET(dumpkmap, dumpkmap_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
APPLET("dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage)
|
||||
APPLET(dutmp, dutmp_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
APPLET("echo", echo_main, _BB_DIR_BIN, echo_usage)
|
||||
APPLET(echo, echo_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#if defined(BB_FEATURE_GREP_EGREP_ALIAS) && defined(BB_GREP)
|
||||
APPLET_NOUSAGE("egrep", init_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_EXPR
|
||||
APPLET("expr", expr_main, _BB_DIR_USR_BIN, expr_usage)
|
||||
APPLET(expr, expr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET("false", false_main, _BB_DIR_BIN, false_usage)
|
||||
APPLET(false, false_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
APPLET_NOUSAGE("fbset", fbset_main, _BB_DIR_USR_SBIN)
|
||||
APPLET(fbset, fbset_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
APPLET("fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage)
|
||||
APPLET(fdflush, fdflush_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
APPLET("find", find_main, _BB_DIR_USR_BIN, find_usage)
|
||||
APPLET(find, find_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
APPLET("free", free_main, _BB_DIR_USR_BIN, free_usage)
|
||||
APPLET(free, free_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
APPLET("freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage)
|
||||
APPLET(freeramdisk, freeramdisk_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
APPLET("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage)
|
||||
APPLET_ODDNAME("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix)
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
APPLET("getopt", getopt_main, _BB_DIR_BIN, getopt_usage)
|
||||
APPLET(getopt, getopt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
APPLET("grep", grep_main, _BB_DIR_BIN, grep_usage)
|
||||
APPLET(grep, grep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET("gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage)
|
||||
APPLET(gunzip, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
APPLET("gzip", gzip_main, _BB_DIR_BIN, gzip_usage)
|
||||
APPLET(gzip, gzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
APPLET("halt", halt_main, _BB_DIR_SBIN, halt_usage)
|
||||
APPLET(halt, halt_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
APPLET("head", head_main, _BB_DIR_USR_BIN, head_usage)
|
||||
APPLET(head, head_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
APPLET("hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage)
|
||||
APPLET(hostid, hostid_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
APPLET("hostname", hostname_main, _BB_DIR_BIN, hostname_usage)
|
||||
APPLET(hostname, hostname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
APPLET("id", id_main, _BB_DIR_USR_BIN, id_usage)
|
||||
APPLET(id, id_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_IFCONFIG
|
||||
APPLET(ifconfig, ifconfig_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
APPLET_NOUSAGE("init", init_main, _BB_DIR_SBIN)
|
||||
APPLET(init, init_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
APPLET("insmod", insmod_main, _BB_DIR_SBIN, insmod_usage)
|
||||
APPLET(insmod, insmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
APPLET("kill", kill_main, _BB_DIR_BIN, kill_usage)
|
||||
APPLET(kill, kill_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
APPLET("killall", kill_main, _BB_DIR_USR_BIN, killall_usage)
|
||||
APPLET(killall, kill_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KLOGD
|
||||
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
APPLET("length", length_main, _BB_DIR_USR_BIN, length_usage)
|
||||
APPLET(length, length_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LINUXRC
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
APPLET("ln", ln_main, _BB_DIR_BIN, ln_usage)
|
||||
APPLET(ln, ln_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
APPLET("loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage)
|
||||
APPLET(loadacm, loadacm_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
APPLET("loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage)
|
||||
APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
APPLET("loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage)
|
||||
APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
APPLET("logger", logger_main, _BB_DIR_USR_BIN, logger_usage)
|
||||
APPLET(logger, logger_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
APPLET("logname", logname_main, _BB_DIR_USR_BIN, logname_usage)
|
||||
APPLET(logname, logname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGREAD
|
||||
APPLET(logread, logread_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
APPLET("ls", ls_main, _BB_DIR_BIN, ls_usage)
|
||||
APPLET(ls, ls_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
APPLET("lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage)
|
||||
APPLET(lsmod, lsmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
APPLET("makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage)
|
||||
APPLET(makedevs, makedevs_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
APPLET("md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage)
|
||||
APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
APPLET("mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage)
|
||||
APPLET(mkdir, mkdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
APPLET("mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage)
|
||||
APPLET(mkfifo, mkfifo_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
APPLET("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage)
|
||||
APPLET_ODDNAME("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix)
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
APPLET("mknod", mknod_main, _BB_DIR_BIN, mknod_usage)
|
||||
APPLET(mknod, mknod_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
APPLET("mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage)
|
||||
APPLET(mkswap, mkswap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
APPLET("mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage)
|
||||
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
APPLET("more", more_main, _BB_DIR_BIN, more_usage)
|
||||
APPLET(more, more_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
APPLET("mount", mount_main, _BB_DIR_BIN, mount_usage)
|
||||
APPLET(mount, mount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
APPLET("mt", mt_main, _BB_DIR_BIN, mt_usage)
|
||||
APPLET(mt, mt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET("mv", cp_mv_main, _BB_DIR_BIN, mv_usage)
|
||||
APPLET(mv, cp_mv_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
APPLET("nc", nc_main, _BB_DIR_USR_BIN, nc_usage)
|
||||
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
APPLET("nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage)
|
||||
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage)
|
||||
APPLET(ping, ping_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PIVOT_ROOT
|
||||
APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage)
|
||||
APPLET(poweroff, poweroff_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
APPLET("printf", printf_main, _BB_DIR_USR_BIN, printf_usage)
|
||||
APPLET(printf, printf_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
APPLET("ps", ps_main, _BB_DIR_BIN, ps_usage)
|
||||
APPLET(ps, ps_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
APPLET("pwd", pwd_main, _BB_DIR_BIN, pwd_usage)
|
||||
APPLET(pwd, pwd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
APPLET("rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage)
|
||||
APPLET(rdate, rdate_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_READLINK
|
||||
APPLET("readlink", readlink_main, _BB_DIR_USR_BIN, readlink_usage)
|
||||
APPLET(readlink, readlink_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
APPLET("reboot", reboot_main, _BB_DIR_SBIN, reboot_usage)
|
||||
APPLET(reboot, reboot_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
APPLET("renice", renice_main, _BB_DIR_USR_BIN, renice_usage)
|
||||
APPLET(renice, renice_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
APPLET("reset", reset_main, _BB_DIR_USR_BIN, reset_usage)
|
||||
APPLET(reset, reset_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
APPLET("rm", rm_main, _BB_DIR_BIN, rm_usage)
|
||||
APPLET(rm, rm_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
APPLET("rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage)
|
||||
APPLET(rmdir, rmdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
APPLET("rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage)
|
||||
APPLET(rmmod, rmmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ROUTE
|
||||
APPLET(route, route_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RPMUNPACK
|
||||
APPLET("rpmunpack", rpmunpack_main, _BB_DIR_USR_BIN, rpmunpack_usage)
|
||||
APPLET(rpmunpack, rpmunpack_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
APPLET("sed", sed_main, _BB_DIR_BIN, sed_usage)
|
||||
APPLET(sed, sed_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
APPLET("setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage)
|
||||
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
APPLET("sh", shell_main, _BB_DIR_BIN, shell_usage)
|
||||
APPLET(sh, shell_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
APPLET("sleep", sleep_main, _BB_DIR_BIN, sleep_usage)
|
||||
APPLET(sleep, sleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
APPLET("sort", sort_main, _BB_DIR_USR_BIN, sort_usage)
|
||||
APPLET(sort, sort_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_STTY
|
||||
APPLET(stty, stty_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET("swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage)
|
||||
APPLET(swapoff, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET("swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage)
|
||||
APPLET(swapon, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
APPLET("sync", sync_main, _BB_DIR_BIN, sync_usage)
|
||||
APPLET(sync, sync_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
APPLET("syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage)
|
||||
APPLET(syslogd, syslogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
APPLET("tail", tail_main, _BB_DIR_USR_BIN, tail_usage)
|
||||
APPLET(tail, tail_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
APPLET("tar", tar_main, _BB_DIR_BIN, tar_usage)
|
||||
APPLET(tar, tar_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
APPLET("tee", tee_main, _BB_DIR_USR_BIN, tee_usage)
|
||||
APPLET(tee, tee_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
APPLET("telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage)
|
||||
APPLET(telnet, telnet_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
APPLET("test", test_main, _BB_DIR_USR_BIN, test_usage)
|
||||
APPLET(test, test_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TFTP
|
||||
APPLET(tftp, tftp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
APPLET("touch", touch_main, _BB_DIR_BIN, touch_usage)
|
||||
APPLET(touch, touch_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
APPLET("tr", tr_main, _BB_DIR_USR_BIN, tr_usage)
|
||||
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET("true", true_main, _BB_DIR_BIN, true_usage)
|
||||
APPLET(true, true_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
APPLET("tty", tty_main, _BB_DIR_USR_BIN, tty_usage)
|
||||
APPLET(tty, tty_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
APPLET("umount", umount_main, _BB_DIR_BIN, umount_usage)
|
||||
APPLET(umount, umount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
APPLET("uname", uname_main, _BB_DIR_BIN, uname_usage)
|
||||
APPLET(uname, uname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
APPLET("uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage)
|
||||
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
APPLET("unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage)
|
||||
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
APPLET("update", update_main, _BB_DIR_SBIN, update_usage)
|
||||
APPLET(update, update_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
APPLET("uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage)
|
||||
APPLET(uptime, uptime_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
APPLET("usleep", usleep_main, _BB_DIR_BIN, usleep_usage)
|
||||
APPLET(usleep, usleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
APPLET("uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage)
|
||||
APPLET(uudecode, uudecode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
APPLET("uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage)
|
||||
APPLET(uuencode, uuencode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WATCHDOG
|
||||
APPLET(watchdog, watchdog_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
APPLET("wc", wc_main, _BB_DIR_USR_BIN, wc_usage)
|
||||
APPLET(wc, wc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
APPLET("wget", wget_main, _BB_DIR_USR_BIN, wget_usage)
|
||||
APPLET(wget, wget_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
APPLET("which", which_main, _BB_DIR_USR_BIN, which_usage)
|
||||
APPLET(which, which_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
APPLET("whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage)
|
||||
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
APPLET("xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage)
|
||||
APPLET(xargs, xargs_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
APPLET("yes", yes_main, _BB_DIR_USR_BIN, yes_usage)
|
||||
APPLET(yes, yes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET("zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage)
|
||||
APPLET(zcat, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_LINKS)
|
||||
{ 0,NULL,0,NULL}
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
|
||||
{ 0,NULL,0 }
|
||||
};
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,NULL} entry above. */
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
#endif
|
||||
+42
-64
@@ -1,8 +1,10 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
@@ -14,8 +16,6 @@
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
|
||||
|
||||
const char *applet_name;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
@@ -54,7 +54,7 @@ static char *busybox_fullpath()
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
error_msg("%s: %s\n", proc, strerror(errno));
|
||||
perror_msg("%s", proc);
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
@@ -69,16 +69,16 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links) Link = symlink;
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
sprintf ( command, "%s/%s",
|
||||
install_dir[applets[i].location],
|
||||
applets[i].name);
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
error_msg("%s: %s\n", command, strerror(errno));
|
||||
perror_msg("%s", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,9 +87,29 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct BB_applet search_applet, *applet;
|
||||
const char *s;
|
||||
applet_name = "busybox";
|
||||
const char *s;
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
@@ -121,39 +141,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
search_applet.name = applet_name;
|
||||
applet = bsearch(&search_applet, applets, NUM_APPLETS,
|
||||
sizeof(struct BB_applet), applet_name_compare);
|
||||
if (applet != NULL) {
|
||||
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(applet->usage);
|
||||
exit((*(applet->main)) (argc, argv));
|
||||
}
|
||||
|
||||
return(busybox_main(argc, argv));
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0;
|
||||
int ps_index;
|
||||
char *index, *index2;
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
@@ -179,31 +166,22 @@ int busybox_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* We do not want the word "busybox" to show up in ps, so we move
|
||||
* everything in argv around to fake ps into showing what we want it to
|
||||
* show. Since we are only shrinking the string, we don't need to move
|
||||
* __environ or any of that tedious stuff... */
|
||||
ps_index = 0;
|
||||
index=*argv;
|
||||
index2=argv[argc];
|
||||
index2+=strlen(argv[argc]);
|
||||
while(ps_index < argc) {
|
||||
argv[ps_index]=index;
|
||||
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
|
||||
index+=(strlen(index));
|
||||
*index='\0';
|
||||
index++;
|
||||
ps_index++;
|
||||
}
|
||||
while(index<=index2)
|
||||
*index++='\0';
|
||||
argv[ps_index]=NULL;
|
||||
/* Move the command line down a notch */
|
||||
len = argv[argc] + strlen(argv[argc]) - argv[1];
|
||||
memmove(argv[0], argv[1], len);
|
||||
memset(argv[0] + len, 0, argv[1] - argv[0]);
|
||||
|
||||
/* Fix up the argv pointers */
|
||||
len = argv[1] - argv[0];
|
||||
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] -= len;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
|
||||
+10
-2
@@ -1,12 +1,20 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
match($2,"_BB_DIR[A-Z_]*")
|
||||
dir=substr($2,RSTART+7,RLENGTH-7)
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
|
||||
+7
-4
@@ -1,13 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr '[:upper:]' '[:lower:]' | sort
|
||||
| tr A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
cd ${2:-.}
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
prefix=$1
|
||||
if [ "$prefix" = "" ]; then
|
||||
echo "No installation directory, aborting."
|
||||
|
||||
+4
-1494
File diff suppressed because it is too large.
Load diff
+1716
File diff suppressed because it is too large.
Load diff
@@ -3,7 +3,7 @@
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
@@ -21,371 +21,207 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Last modified 20 September 2000
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <malloc.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BLOCK_SIZE 60
|
||||
#define PRESERVE_DATE 1 /* preserve original dates */
|
||||
#define VERBOSE 2 /* be verbose */
|
||||
#define DISPLAY 4 /* display contents */
|
||||
#define EXT_TO_FILE 8 /* extract contents of archive */
|
||||
#define EXT_TO_STDOUT 16 /* extract to stdout */
|
||||
#define RECURSIVE 32
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
#define MAX_NAME_LENGTH 100
|
||||
|
||||
//#define BB_DECLARE_EXTERN
|
||||
//#define bb_need_io_error
|
||||
//#include "messages.c"
|
||||
|
||||
//#define BB_AR_EXPERIMENTAL_UNTAR
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
typedef struct rawTarHeader {
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 */
|
||||
} rawTarHeader_t;
|
||||
#endif
|
||||
|
||||
typedef struct rawArHeader { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6], gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} rawArHeader_t;
|
||||
|
||||
typedef struct headerL {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct headerL *next;
|
||||
} headerL_t;
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
/*
|
||||
* identify Tar header (magic field) and reset srcFd to entry position
|
||||
* return the headerL_t struct for the filename descriptor
|
||||
*/
|
||||
static int checkTarMagic(int srcFd)
|
||||
extern ar_headers_t get_ar_headers(int srcFd)
|
||||
{
|
||||
off_t headerStart;
|
||||
char magic[6];
|
||||
typedef struct raw_ar_header_s { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6];
|
||||
char gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} raw_ar_header_t;
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
lseek(srcFd, (off_t) 257, SEEK_CUR);
|
||||
full_read(srcFd, magic, 6);
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
if (strncmp(magic, "ustar", 5)!=0)
|
||||
return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
raw_ar_header_t raw_ar_header;
|
||||
|
||||
|
||||
static int readTarHeader(int srcFd, headerL_t *current)
|
||||
{
|
||||
rawTarHeader_t rawTarHeader;
|
||||
unsigned char *temp = (unsigned char *) &rawTarHeader;
|
||||
long sum = 0;
|
||||
int i;
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
for (i = 0; i < 148 ; i++)
|
||||
sum += temp[i];
|
||||
sum += ' ' * 8;
|
||||
for (i = 156; i < 512 ; i++)
|
||||
sum += temp[i];
|
||||
if (sum!= strtol(rawTarHeader.chksum, NULL, 8))
|
||||
return(FALSE);
|
||||
sscanf(rawTarHeader.name, "%s", current->name);
|
||||
current->size = strtol(rawTarHeader.size, NULL, 8);
|
||||
current->uid = strtol(rawTarHeader.uid, NULL, 8);
|
||||
current->gid = strtol(rawTarHeader.gid, NULL, 8);
|
||||
current->mode = strtol(rawTarHeader.mode, NULL, 8);
|
||||
current->mtime = strtol(rawTarHeader.mtime, NULL, 8);
|
||||
current->offset = lseek(srcFd, 0 , SEEK_CUR);
|
||||
|
||||
current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
current = current->next;
|
||||
return(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* identify Ar header (magic) and reset srcFd to entry position
|
||||
*/
|
||||
static int checkArMagic(int srcFd)
|
||||
{
|
||||
off_t headerStart;
|
||||
char arMagic[8];
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, arMagic, 8) != 8) {
|
||||
error_msg("fatal error\n");
|
||||
return (FALSE);
|
||||
}
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
|
||||
if (strncmp(arMagic,"!<arch>",7) != 0)
|
||||
return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* get, check and correct the converted header
|
||||
*/
|
||||
static int readArEntry(int srcFd, headerL_t *entry)
|
||||
{
|
||||
size_t nameLength;
|
||||
rawArHeader_t rawArHeader;
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
if ((rawArHeader.fmag[0]!='`') || (rawArHeader.fmag[1]!='\n')) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
strncpy(entry->name, rawArHeader.name, 16);
|
||||
nameLength=strcspn(entry->name, " \\");
|
||||
entry->name[nameLength]='\0';
|
||||
parse_mode(rawArHeader.mode, &entry->mode);
|
||||
entry->mtime = atoi(rawArHeader.date);
|
||||
entry->uid = atoi(rawArHeader.uid);
|
||||
entry->gid = atoi(rawArHeader.gid);
|
||||
entry->size = (size_t) atoi(rawArHeader.size);
|
||||
entry->offset = initialOffset + (off_t) 60;
|
||||
|
||||
nameLength = strcspn(entry->name, "/");
|
||||
ar_headers_t *head, *entry;
|
||||
char ar_magic[8];
|
||||
char *long_name=NULL;
|
||||
|
||||
/* handle GNU style short filenames, strip trailing '/' */
|
||||
if (nameLength > 0)
|
||||
entry->name[nameLength]='\0';
|
||||
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
/* handle GNU style long filenames */
|
||||
if (nameLength == 0) {
|
||||
/* escape from recursive call */
|
||||
if (entry->name[1]=='0')
|
||||
return(TRUE);
|
||||
/* check ar magic */
|
||||
if (full_read(srcFd, ar_magic, 8) != 8) {
|
||||
error_msg_and_die("cannot read magic");
|
||||
}
|
||||
|
||||
/* the data section contains the real filename */
|
||||
if (entry->name[1]=='/') {
|
||||
char tempName[MAX_NAME_LENGTH];
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
if (entry->size > MAX_NAME_LENGTH)
|
||||
entry->size = MAX_NAME_LENGTH;
|
||||
full_read(srcFd, tempName, entry->size);
|
||||
tempName[entry->size-3]='\0';
|
||||
|
||||
/* read the second header for this entry */
|
||||
/* be carefull, this is recursive */
|
||||
if (readArEntry(srcFd, entry)==FALSE)
|
||||
return(FALSE);
|
||||
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
|
||||
/* check the end of header markers are valid */
|
||||
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
|
||||
char newline;
|
||||
if (raw_ar_header.fmag[1]!='`') {
|
||||
break;
|
||||
}
|
||||
/* some version of ar, have an extra '\n' after each entry */
|
||||
read(srcFd, &newline, 1);
|
||||
if (newline!='\n') {
|
||||
break;
|
||||
}
|
||||
/* fix up the header, we started reading 1 byte too early due to a '\n' */
|
||||
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
|
||||
/* dont worry about adding the last '\n', we dont need it now */
|
||||
}
|
||||
|
||||
if ((entry->name[0]='/') && (entry->name[1]='0'))
|
||||
strcpy(entry->name, tempName);
|
||||
entry->size = (size_t) atoi(raw_ar_header.size);
|
||||
/* long filenames have '/' as the first character */
|
||||
if (raw_ar_header.name[0] == '/') {
|
||||
if (raw_ar_header.name[1] == '/') {
|
||||
/* multiple long filenames are stored as data in one entry */
|
||||
long_name = (char *) xrealloc(long_name, entry->size);
|
||||
full_read(srcFd, long_name, entry->size);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
error_msg("Invalid long filename\n");
|
||||
return(FALSE);
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
|
||||
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
|
||||
strcpy(entry->name, &long_name[long_name_offset]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* return the headerL_t struct for the specified filename
|
||||
*/
|
||||
static headerL_t *getHeaders(int srcFd, headerL_t *head, int funct)
|
||||
{
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
int tar=FALSE;
|
||||
#endif
|
||||
int ar=FALSE;
|
||||
headerL_t *list;
|
||||
off_t initialOffset;
|
||||
|
||||
list = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
initialOffset=lseek(srcFd, 0, SEEK_CUR);
|
||||
if (checkArMagic(srcFd)==TRUE)
|
||||
ar=TRUE;
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
if (checkTarMagic(srcFd)==TRUE)
|
||||
tar=TRUE;
|
||||
|
||||
if (tar==TRUE) {
|
||||
while(readTarHeader(srcFd, list)==TRUE) {
|
||||
off_t tarOffset;
|
||||
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*list->next = *head;
|
||||
*head = *list;
|
||||
|
||||
/* recursive check for sub-archives */
|
||||
if ((funct & RECURSIVE) == RECURSIVE)
|
||||
head = getHeaders(srcFd, head, funct);
|
||||
tarOffset = (off_t) head->size/512;
|
||||
if ( head->size % 512 > 0)
|
||||
tarOffset++;
|
||||
tarOffset=tarOffset*512;
|
||||
lseek(srcFd, head->offset + tarOffset, SEEK_SET);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ar==TRUE) {
|
||||
lseek(srcFd, 8, SEEK_CUR);
|
||||
while(1) {
|
||||
if (readArEntry(srcFd, list) == FALSE) {
|
||||
lseek(srcFd, ++initialOffset, SEEK_CUR);
|
||||
if (readArEntry(srcFd, list) == FALSE)
|
||||
return(head);
|
||||
}
|
||||
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*list->next = *head;
|
||||
*head = *list;
|
||||
/* recursive check for sub-archives */
|
||||
if (funct & RECURSIVE)
|
||||
head = getHeaders(srcFd, head, funct);
|
||||
lseek(srcFd, head->offset + head->size, SEEK_SET);
|
||||
else {
|
||||
/* short filenames */
|
||||
entry->name = xmalloc(16);
|
||||
strncpy(entry->name, raw_ar_header.name, 16);
|
||||
}
|
||||
}
|
||||
return(head);
|
||||
}
|
||||
entry->name[strcspn(entry->name, " /")]='\0';
|
||||
|
||||
/*
|
||||
* find an entry in the linked list matching the filename
|
||||
*/
|
||||
static headerL_t *findEntry(headerL_t *head, const char *filename)
|
||||
{
|
||||
while(head->next != NULL) {
|
||||
if (strcmp(filename, head->name)==0)
|
||||
return(head);
|
||||
head=head->next;
|
||||
/* convert the rest of the now valid char header to its typed struct */
|
||||
parse_mode(raw_ar_header.mode, &entry->mode);
|
||||
entry->mtime = atoi(raw_ar_header.date);
|
||||
entry->uid = atoi(raw_ar_header.uid);
|
||||
entry->gid = atoi(raw_ar_header.gid);
|
||||
entry->offset = lseek(srcFd, 0, SEEK_CUR);
|
||||
|
||||
/* add this entries header to our combined list */
|
||||
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*entry->next = *head;
|
||||
*head = *entry;
|
||||
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
|
||||
}
|
||||
return(NULL);
|
||||
return(*head);
|
||||
}
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
headerL_t *header, *entry, *extractList;
|
||||
const int preserve_date = 1; /* preserve original dates */
|
||||
const int verbose = 2; /* be verbose */
|
||||
const int display = 4; /* display contents */
|
||||
const int extract_to_file = 8; /* extract contents of archive */
|
||||
const int extract_to_stdout = 16; /* extract to stdout */
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpxR")) != -1) {
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
|
||||
ar_headers_t head, *extract_list=NULL;
|
||||
|
||||
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
funct |= PRESERVE_DATE;
|
||||
funct |= preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
funct |= VERBOSE;
|
||||
funct |= verbose;
|
||||
break;
|
||||
case 't':
|
||||
funct |= DISPLAY;
|
||||
break;
|
||||
case 'x':
|
||||
funct |= EXT_TO_FILE;
|
||||
funct |= display;
|
||||
break;
|
||||
case 'p':
|
||||
funct |= EXT_TO_STDOUT;
|
||||
funct |= extract_to_stdout;
|
||||
break;
|
||||
case 'R':
|
||||
funct |= RECURSIVE;
|
||||
case 'x':
|
||||
funct |= extract_to_file;
|
||||
break;
|
||||
default:
|
||||
usage(ar_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
usage(ar_usage);
|
||||
show_usage();
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s\n", argv[optind]);
|
||||
error_msg_and_die("Cannot read %s", argv[optind]);
|
||||
|
||||
optind++;
|
||||
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
header = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
optind++;
|
||||
head = get_ar_headers(srcFd);
|
||||
|
||||
header = getHeaders(srcFd, header, funct);
|
||||
/* find files to extract or display */
|
||||
if (optind<argc) {
|
||||
/* only handle specified files */
|
||||
while(optind < argc) {
|
||||
if ( (entry = findEntry(header, argv[optind])) != NULL) {
|
||||
entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*entry->next = *extractList;
|
||||
*extractList = *entry;
|
||||
/* search through argv and build extract list */
|
||||
for (;optind<argc; optind++) {
|
||||
ar_headers_t *ar_entry;
|
||||
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
ar_entry = &head;
|
||||
while (ar_entry->next != NULL) {
|
||||
if (strcmp(argv[optind], ar_entry->name) == 0) {
|
||||
ar_headers_t *tmp;
|
||||
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*tmp = *extract_list;
|
||||
*extract_list = *ar_entry;
|
||||
extract_list->next = tmp;
|
||||
break;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
ar_entry=ar_entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* if individual files not found extract all files */
|
||||
if (extract_list->next==NULL) {
|
||||
extract_list = &head;
|
||||
}
|
||||
else
|
||||
extractList = header;
|
||||
|
||||
while(extractList->next != NULL) {
|
||||
if (funct & EXT_TO_FILE) {
|
||||
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
|
||||
create_path(extractList->name, 0666);
|
||||
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
|
||||
/* find files to extract or display */
|
||||
while (extract_list->next != NULL) {
|
||||
if (funct & extract_to_file) {
|
||||
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
|
||||
}
|
||||
if (funct & EXT_TO_STDOUT) {
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, fileno(stdout), (size_t) extractList->size);
|
||||
else if (funct & extract_to_stdout) {
|
||||
dstFd = fileno(stdout);
|
||||
}
|
||||
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
|
||||
if (funct & VERBOSE)
|
||||
printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
|
||||
extractList->uid, extractList->gid,
|
||||
extractList->size, time_string(extractList->mtime));
|
||||
printf("%s\n", extractList->name);
|
||||
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
|
||||
lseek(srcFd, extract_list->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
|
||||
}
|
||||
extractList=extractList->next;
|
||||
if (funct & verbose) {
|
||||
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
|
||||
extract_list->uid, extract_list->gid,
|
||||
extract_list->size, time_string(extract_list->mtime));
|
||||
}
|
||||
if ((funct & display) || (funct & verbose)){
|
||||
printf("%s\n", extract_list->name);
|
||||
}
|
||||
extract_list=extract_list->next;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+148
-312
@@ -3,7 +3,7 @@
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
@@ -21,371 +21,207 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Last modified 20 September 2000
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <malloc.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BLOCK_SIZE 60
|
||||
#define PRESERVE_DATE 1 /* preserve original dates */
|
||||
#define VERBOSE 2 /* be verbose */
|
||||
#define DISPLAY 4 /* display contents */
|
||||
#define EXT_TO_FILE 8 /* extract contents of archive */
|
||||
#define EXT_TO_STDOUT 16 /* extract to stdout */
|
||||
#define RECURSIVE 32
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
#define MAX_NAME_LENGTH 100
|
||||
|
||||
//#define BB_DECLARE_EXTERN
|
||||
//#define bb_need_io_error
|
||||
//#include "messages.c"
|
||||
|
||||
//#define BB_AR_EXPERIMENTAL_UNTAR
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
typedef struct rawTarHeader {
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 */
|
||||
} rawTarHeader_t;
|
||||
#endif
|
||||
|
||||
typedef struct rawArHeader { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6], gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} rawArHeader_t;
|
||||
|
||||
typedef struct headerL {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct headerL *next;
|
||||
} headerL_t;
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
/*
|
||||
* identify Tar header (magic field) and reset srcFd to entry position
|
||||
* return the headerL_t struct for the filename descriptor
|
||||
*/
|
||||
static int checkTarMagic(int srcFd)
|
||||
extern ar_headers_t get_ar_headers(int srcFd)
|
||||
{
|
||||
off_t headerStart;
|
||||
char magic[6];
|
||||
typedef struct raw_ar_header_s { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6];
|
||||
char gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} raw_ar_header_t;
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
lseek(srcFd, (off_t) 257, SEEK_CUR);
|
||||
full_read(srcFd, magic, 6);
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
if (strncmp(magic, "ustar", 5)!=0)
|
||||
return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
raw_ar_header_t raw_ar_header;
|
||||
|
||||
|
||||
static int readTarHeader(int srcFd, headerL_t *current)
|
||||
{
|
||||
rawTarHeader_t rawTarHeader;
|
||||
unsigned char *temp = (unsigned char *) &rawTarHeader;
|
||||
long sum = 0;
|
||||
int i;
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
for (i = 0; i < 148 ; i++)
|
||||
sum += temp[i];
|
||||
sum += ' ' * 8;
|
||||
for (i = 156; i < 512 ; i++)
|
||||
sum += temp[i];
|
||||
if (sum!= strtol(rawTarHeader.chksum, NULL, 8))
|
||||
return(FALSE);
|
||||
sscanf(rawTarHeader.name, "%s", current->name);
|
||||
current->size = strtol(rawTarHeader.size, NULL, 8);
|
||||
current->uid = strtol(rawTarHeader.uid, NULL, 8);
|
||||
current->gid = strtol(rawTarHeader.gid, NULL, 8);
|
||||
current->mode = strtol(rawTarHeader.mode, NULL, 8);
|
||||
current->mtime = strtol(rawTarHeader.mtime, NULL, 8);
|
||||
current->offset = lseek(srcFd, 0 , SEEK_CUR);
|
||||
|
||||
current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
current = current->next;
|
||||
return(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* identify Ar header (magic) and reset srcFd to entry position
|
||||
*/
|
||||
static int checkArMagic(int srcFd)
|
||||
{
|
||||
off_t headerStart;
|
||||
char arMagic[8];
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, arMagic, 8) != 8) {
|
||||
error_msg("fatal error\n");
|
||||
return (FALSE);
|
||||
}
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
|
||||
if (strncmp(arMagic,"!<arch>",7) != 0)
|
||||
return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* get, check and correct the converted header
|
||||
*/
|
||||
static int readArEntry(int srcFd, headerL_t *entry)
|
||||
{
|
||||
size_t nameLength;
|
||||
rawArHeader_t rawArHeader;
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
if ((rawArHeader.fmag[0]!='`') || (rawArHeader.fmag[1]!='\n')) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
strncpy(entry->name, rawArHeader.name, 16);
|
||||
nameLength=strcspn(entry->name, " \\");
|
||||
entry->name[nameLength]='\0';
|
||||
parse_mode(rawArHeader.mode, &entry->mode);
|
||||
entry->mtime = atoi(rawArHeader.date);
|
||||
entry->uid = atoi(rawArHeader.uid);
|
||||
entry->gid = atoi(rawArHeader.gid);
|
||||
entry->size = (size_t) atoi(rawArHeader.size);
|
||||
entry->offset = initialOffset + (off_t) 60;
|
||||
|
||||
nameLength = strcspn(entry->name, "/");
|
||||
ar_headers_t *head, *entry;
|
||||
char ar_magic[8];
|
||||
char *long_name=NULL;
|
||||
|
||||
/* handle GNU style short filenames, strip trailing '/' */
|
||||
if (nameLength > 0)
|
||||
entry->name[nameLength]='\0';
|
||||
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
/* handle GNU style long filenames */
|
||||
if (nameLength == 0) {
|
||||
/* escape from recursive call */
|
||||
if (entry->name[1]=='0')
|
||||
return(TRUE);
|
||||
/* check ar magic */
|
||||
if (full_read(srcFd, ar_magic, 8) != 8) {
|
||||
error_msg_and_die("cannot read magic");
|
||||
}
|
||||
|
||||
/* the data section contains the real filename */
|
||||
if (entry->name[1]=='/') {
|
||||
char tempName[MAX_NAME_LENGTH];
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
if (entry->size > MAX_NAME_LENGTH)
|
||||
entry->size = MAX_NAME_LENGTH;
|
||||
full_read(srcFd, tempName, entry->size);
|
||||
tempName[entry->size-3]='\0';
|
||||
|
||||
/* read the second header for this entry */
|
||||
/* be carefull, this is recursive */
|
||||
if (readArEntry(srcFd, entry)==FALSE)
|
||||
return(FALSE);
|
||||
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
|
||||
/* check the end of header markers are valid */
|
||||
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
|
||||
char newline;
|
||||
if (raw_ar_header.fmag[1]!='`') {
|
||||
break;
|
||||
}
|
||||
/* some version of ar, have an extra '\n' after each entry */
|
||||
read(srcFd, &newline, 1);
|
||||
if (newline!='\n') {
|
||||
break;
|
||||
}
|
||||
/* fix up the header, we started reading 1 byte too early due to a '\n' */
|
||||
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
|
||||
/* dont worry about adding the last '\n', we dont need it now */
|
||||
}
|
||||
|
||||
if ((entry->name[0]='/') && (entry->name[1]='0'))
|
||||
strcpy(entry->name, tempName);
|
||||
entry->size = (size_t) atoi(raw_ar_header.size);
|
||||
/* long filenames have '/' as the first character */
|
||||
if (raw_ar_header.name[0] == '/') {
|
||||
if (raw_ar_header.name[1] == '/') {
|
||||
/* multiple long filenames are stored as data in one entry */
|
||||
long_name = (char *) xrealloc(long_name, entry->size);
|
||||
full_read(srcFd, long_name, entry->size);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
error_msg("Invalid long filename\n");
|
||||
return(FALSE);
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
|
||||
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
|
||||
strcpy(entry->name, &long_name[long_name_offset]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* return the headerL_t struct for the specified filename
|
||||
*/
|
||||
static headerL_t *getHeaders(int srcFd, headerL_t *head, int funct)
|
||||
{
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
int tar=FALSE;
|
||||
#endif
|
||||
int ar=FALSE;
|
||||
headerL_t *list;
|
||||
off_t initialOffset;
|
||||
|
||||
list = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
initialOffset=lseek(srcFd, 0, SEEK_CUR);
|
||||
if (checkArMagic(srcFd)==TRUE)
|
||||
ar=TRUE;
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
if (checkTarMagic(srcFd)==TRUE)
|
||||
tar=TRUE;
|
||||
|
||||
if (tar==TRUE) {
|
||||
while(readTarHeader(srcFd, list)==TRUE) {
|
||||
off_t tarOffset;
|
||||
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*list->next = *head;
|
||||
*head = *list;
|
||||
|
||||
/* recursive check for sub-archives */
|
||||
if ((funct & RECURSIVE) == RECURSIVE)
|
||||
head = getHeaders(srcFd, head, funct);
|
||||
tarOffset = (off_t) head->size/512;
|
||||
if ( head->size % 512 > 0)
|
||||
tarOffset++;
|
||||
tarOffset=tarOffset*512;
|
||||
lseek(srcFd, head->offset + tarOffset, SEEK_SET);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ar==TRUE) {
|
||||
lseek(srcFd, 8, SEEK_CUR);
|
||||
while(1) {
|
||||
if (readArEntry(srcFd, list) == FALSE) {
|
||||
lseek(srcFd, ++initialOffset, SEEK_CUR);
|
||||
if (readArEntry(srcFd, list) == FALSE)
|
||||
return(head);
|
||||
}
|
||||
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*list->next = *head;
|
||||
*head = *list;
|
||||
/* recursive check for sub-archives */
|
||||
if (funct & RECURSIVE)
|
||||
head = getHeaders(srcFd, head, funct);
|
||||
lseek(srcFd, head->offset + head->size, SEEK_SET);
|
||||
else {
|
||||
/* short filenames */
|
||||
entry->name = xmalloc(16);
|
||||
strncpy(entry->name, raw_ar_header.name, 16);
|
||||
}
|
||||
}
|
||||
return(head);
|
||||
}
|
||||
entry->name[strcspn(entry->name, " /")]='\0';
|
||||
|
||||
/*
|
||||
* find an entry in the linked list matching the filename
|
||||
*/
|
||||
static headerL_t *findEntry(headerL_t *head, const char *filename)
|
||||
{
|
||||
while(head->next != NULL) {
|
||||
if (strcmp(filename, head->name)==0)
|
||||
return(head);
|
||||
head=head->next;
|
||||
/* convert the rest of the now valid char header to its typed struct */
|
||||
parse_mode(raw_ar_header.mode, &entry->mode);
|
||||
entry->mtime = atoi(raw_ar_header.date);
|
||||
entry->uid = atoi(raw_ar_header.uid);
|
||||
entry->gid = atoi(raw_ar_header.gid);
|
||||
entry->offset = lseek(srcFd, 0, SEEK_CUR);
|
||||
|
||||
/* add this entries header to our combined list */
|
||||
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*entry->next = *head;
|
||||
*head = *entry;
|
||||
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
|
||||
}
|
||||
return(NULL);
|
||||
return(*head);
|
||||
}
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
headerL_t *header, *entry, *extractList;
|
||||
const int preserve_date = 1; /* preserve original dates */
|
||||
const int verbose = 2; /* be verbose */
|
||||
const int display = 4; /* display contents */
|
||||
const int extract_to_file = 8; /* extract contents of archive */
|
||||
const int extract_to_stdout = 16; /* extract to stdout */
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpxR")) != -1) {
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
|
||||
ar_headers_t head, *extract_list=NULL;
|
||||
|
||||
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
funct |= PRESERVE_DATE;
|
||||
funct |= preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
funct |= VERBOSE;
|
||||
funct |= verbose;
|
||||
break;
|
||||
case 't':
|
||||
funct |= DISPLAY;
|
||||
break;
|
||||
case 'x':
|
||||
funct |= EXT_TO_FILE;
|
||||
funct |= display;
|
||||
break;
|
||||
case 'p':
|
||||
funct |= EXT_TO_STDOUT;
|
||||
funct |= extract_to_stdout;
|
||||
break;
|
||||
case 'R':
|
||||
funct |= RECURSIVE;
|
||||
case 'x':
|
||||
funct |= extract_to_file;
|
||||
break;
|
||||
default:
|
||||
usage(ar_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
usage(ar_usage);
|
||||
show_usage();
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s\n", argv[optind]);
|
||||
error_msg_and_die("Cannot read %s", argv[optind]);
|
||||
|
||||
optind++;
|
||||
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
header = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
optind++;
|
||||
head = get_ar_headers(srcFd);
|
||||
|
||||
header = getHeaders(srcFd, header, funct);
|
||||
/* find files to extract or display */
|
||||
if (optind<argc) {
|
||||
/* only handle specified files */
|
||||
while(optind < argc) {
|
||||
if ( (entry = findEntry(header, argv[optind])) != NULL) {
|
||||
entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*entry->next = *extractList;
|
||||
*extractList = *entry;
|
||||
/* search through argv and build extract list */
|
||||
for (;optind<argc; optind++) {
|
||||
ar_headers_t *ar_entry;
|
||||
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
ar_entry = &head;
|
||||
while (ar_entry->next != NULL) {
|
||||
if (strcmp(argv[optind], ar_entry->name) == 0) {
|
||||
ar_headers_t *tmp;
|
||||
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*tmp = *extract_list;
|
||||
*extract_list = *ar_entry;
|
||||
extract_list->next = tmp;
|
||||
break;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
ar_entry=ar_entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* if individual files not found extract all files */
|
||||
if (extract_list->next==NULL) {
|
||||
extract_list = &head;
|
||||
}
|
||||
else
|
||||
extractList = header;
|
||||
|
||||
while(extractList->next != NULL) {
|
||||
if (funct & EXT_TO_FILE) {
|
||||
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
|
||||
create_path(extractList->name, 0666);
|
||||
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
|
||||
/* find files to extract or display */
|
||||
while (extract_list->next != NULL) {
|
||||
if (funct & extract_to_file) {
|
||||
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
|
||||
}
|
||||
if (funct & EXT_TO_STDOUT) {
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, fileno(stdout), (size_t) extractList->size);
|
||||
else if (funct & extract_to_stdout) {
|
||||
dstFd = fileno(stdout);
|
||||
}
|
||||
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
|
||||
if (funct & VERBOSE)
|
||||
printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
|
||||
extractList->uid, extractList->gid,
|
||||
extractList->size, time_string(extractList->mtime));
|
||||
printf("%s\n", extractList->name);
|
||||
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
|
||||
lseek(srcFd, extract_list->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
|
||||
}
|
||||
extractList=extractList->next;
|
||||
if (funct & verbose) {
|
||||
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
|
||||
extract_list->uid, extract_list->gid,
|
||||
extract_list->size, time_string(extract_list->mtime));
|
||||
}
|
||||
if ((funct & display) || (funct & verbose)){
|
||||
printf("%s\n", extract_list->name);
|
||||
}
|
||||
extract_list=extract_list->next;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+855
@@ -0,0 +1,855 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <search.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* Stupid libc doesn't have a reliable way for use to know
|
||||
* that libc5 is being used. Assume this is good enough */
|
||||
#if !defined __GLIBC__ && !defined __UCLIBC__
|
||||
#error It looks like you are using libc5, which does not support
|
||||
#error tfind(). tfind() is used by busybox dpkg.
|
||||
#error Please disable BB_DPKG. Sorry.
|
||||
#endif
|
||||
|
||||
#define DEPENDSMAX 64 /* maximum number of depends we can handle */
|
||||
|
||||
/* Should we do full dependency checking? */
|
||||
#define DODEPENDS 1
|
||||
|
||||
/* Should we do debugging? */
|
||||
#define DODEBUG 1
|
||||
|
||||
#ifdef DODEBUG
|
||||
#define SYSTEM(x) do_system(x)
|
||||
#define DPRINTF(fmt,args...) fprintf(stderr, fmt, ##args)
|
||||
#else
|
||||
#define SYSTEM(x) system(x)
|
||||
#define DPRINTF(fmt,args...) /* nothing */
|
||||
#endif
|
||||
|
||||
/* from dpkg-deb.c */
|
||||
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename);
|
||||
static const int dpkg_deb_contents = 1;
|
||||
static const int dpkg_deb_control = 2;
|
||||
// const int dpkg_deb_info = 4;
|
||||
static const int dpkg_deb_extract = 8;
|
||||
static const int dpkg_deb_verbose_extract = 16;
|
||||
static const int dpkg_deb_list = 32;
|
||||
|
||||
static const char statusfile[] = "/var/lib/dpkg/status.udeb";
|
||||
static const char new_statusfile[] = "/var/lib/dpkg/status.udeb.new";
|
||||
static const char bak_statusfile[] = "/var/lib/dpkg/status.udeb.bak";
|
||||
|
||||
static const char dpkgcidir[] = "/var/lib/dpkg/tmp.ci/";
|
||||
|
||||
static const char infodir[] = "/var/lib/dpkg/info/";
|
||||
static const char udpkg_quiet[] = "UDPKG_QUIET";
|
||||
|
||||
//static const int status_wantstart = 0;
|
||||
//static const int status_wantunknown = (1 << 0);
|
||||
static const int status_wantinstall = (1 << 1);
|
||||
//static const int status_wanthold = (1 << 2);
|
||||
//static const int status_wantdeinstall = (1 << 3);
|
||||
//static const int status_wantpurge = (1 << 4);
|
||||
static const int status_wantmask = 31;
|
||||
|
||||
//static const int status_flagstart = 5;
|
||||
static const int status_flagok = (1 << 5); /* 32 */
|
||||
//static const int status_flagreinstreq = (1 << 6);
|
||||
//static const int status_flaghold = (1 << 7);
|
||||
//static const int status_flagholdreinstreq = (1 << 8);
|
||||
static const int status_flagmask = 480;
|
||||
|
||||
//static const int status_statusstart = 9;
|
||||
//static const int status_statusnoninstalled = (1 << 9); /* 512 */
|
||||
static const int status_statusunpacked = (1 << 10);
|
||||
static const int status_statushalfconfigured = (1 << 11);
|
||||
static const int status_statusinstalled = (1 << 12);
|
||||
static const int status_statushalfinstalled = (1 << 13);
|
||||
//static const int status_statusconfigfiles = (1 << 14);
|
||||
//static const int status_statuspostinstfailed = (1 << 15);
|
||||
//static const int status_statusremovalfailed = (1 << 16);
|
||||
static const int status_statusmask = 130560; /* i assume status_statusinstalled is supposed to be included */
|
||||
|
||||
static const char *statuswords[][10] = {
|
||||
{ (char *) 0, "unknown", "install", "hold", "deinstall", "purge", 0 },
|
||||
{ (char *) 5, "ok", "reinstreq", "hold", "hold-reinstreq", 0 },
|
||||
{ (char *) 9, "not-installed", "unpacked", "half-configured",
|
||||
"installed", "half-installed", "config-files",
|
||||
"post-inst-failed", "removal-failed", 0 }
|
||||
};
|
||||
|
||||
static const int color_white = 0;
|
||||
static const int color_grey = 1;
|
||||
static const int color_black = 2;
|
||||
|
||||
/* data structures */
|
||||
typedef struct package_s {
|
||||
char *file;
|
||||
char *package;
|
||||
char *version;
|
||||
char *depends;
|
||||
char *provides;
|
||||
char *description;
|
||||
int installer_menu_item;
|
||||
unsigned long status;
|
||||
char color; /* for topo-sort */
|
||||
struct package_s *requiredfor[DEPENDSMAX];
|
||||
unsigned short requiredcount;
|
||||
struct package_s *next;
|
||||
} package_t;
|
||||
|
||||
#ifdef DODEBUG
|
||||
static int do_system(const char *cmd)
|
||||
{
|
||||
DPRINTF("cmd is %s\n", cmd);
|
||||
return system(cmd);
|
||||
}
|
||||
#else
|
||||
#define do_system(cmd) system(cmd)
|
||||
#endif
|
||||
|
||||
static int package_compare(const void *p1, const void *p2)
|
||||
{
|
||||
return strcmp(((package_t *)p1)->package,
|
||||
((package_t *)p2)->package);
|
||||
}
|
||||
|
||||
static int remove_dpkgcidir()
|
||||
{
|
||||
char *rm_dpkgcidir = NULL;
|
||||
|
||||
rm_dpkgcidir = (char *) xmalloc(strlen(dpkgcidir) + 8);
|
||||
strcpy(rm_dpkgcidir, "rm -rf ");
|
||||
strcat(rm_dpkgcidir, dpkgcidir);
|
||||
|
||||
if (SYSTEM(rm_dpkgcidir) != 0) {
|
||||
perror("mkdir ");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef DODEPENDS
|
||||
#include <ctype.h>
|
||||
|
||||
static char **depends_split(const char *dependsstr)
|
||||
{
|
||||
static char *dependsvec[DEPENDSMAX];
|
||||
char *p;
|
||||
int i = 0;
|
||||
|
||||
dependsvec[0] = 0;
|
||||
if (dependsstr == 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
p = strdup(dependsstr);
|
||||
while (*p != 0 && *p != '\n') {
|
||||
if (*p != ' ') {
|
||||
if (*p == ',') {
|
||||
*p = 0;
|
||||
dependsvec[++i] = 0;
|
||||
} else {
|
||||
if (dependsvec[i] == 0) {
|
||||
dependsvec[i] = p;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*p = 0; /* eat the space... */
|
||||
}
|
||||
p++;
|
||||
}
|
||||
*p = 0;
|
||||
|
||||
end:
|
||||
dependsvec[i+1] = 0;
|
||||
return dependsvec;
|
||||
}
|
||||
|
||||
/* Topological sort algorithm:
|
||||
* ordered is the output list, pkgs is the dependency graph, pkg is
|
||||
* the current node
|
||||
*
|
||||
* recursively add all the adjacent nodes to the ordered list, marking
|
||||
* each one as visited along the way
|
||||
*
|
||||
* yes, this algorithm looks a bit odd when all the params have the
|
||||
* same type :-)
|
||||
*/
|
||||
static void depends_sort_visit(package_t **ordered, package_t *pkgs,
|
||||
package_t *pkg)
|
||||
{
|
||||
unsigned short i;
|
||||
|
||||
/* mark node as processing */
|
||||
pkg->color = color_grey;
|
||||
|
||||
/* visit each not-yet-visited node */
|
||||
for (i = 0; i < pkg->requiredcount; i++)
|
||||
if (pkg->requiredfor[i]->color == color_white)
|
||||
depends_sort_visit(ordered, pkgs, pkg->requiredfor[i]);
|
||||
|
||||
#if 0
|
||||
/* add it to the list */
|
||||
newnode = (struct package_t *)xmalloc(sizeof(struct package_t));
|
||||
/* make a shallow copy */
|
||||
*newnode = *pkg;
|
||||
newnode->next = *ordered;
|
||||
*ordered = newnode;
|
||||
#endif
|
||||
|
||||
pkg->next = *ordered;
|
||||
*ordered = pkg;
|
||||
|
||||
/* mark node as done */
|
||||
pkg->color = color_black;
|
||||
}
|
||||
|
||||
static package_t *depends_sort(package_t *pkgs)
|
||||
{
|
||||
/* TODO: it needs to break cycles in the to-be-installed package
|
||||
* graph... */
|
||||
package_t *ordered = NULL;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
pkg->color = color_white;
|
||||
}
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
if (pkg->color == color_white) {
|
||||
depends_sort_visit(&ordered, pkgs, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Leaks the old list... return the new one... */
|
||||
return ordered;
|
||||
}
|
||||
|
||||
|
||||
/* resolve package dependencies --
|
||||
* for each package in the list of packages to be installed, we parse its
|
||||
* dependency info to determine if the dependent packages are either
|
||||
* already installed, or are scheduled to be installed. If both tests fail
|
||||
* than bail.
|
||||
*
|
||||
* The algorithm here is O(n^2*m) where n = number of packages to be
|
||||
* installed and m is the # of dependencies per package. Not a terribly
|
||||
* efficient algorithm, but given that at any one time you are unlikely
|
||||
* to install a very large number of packages it doesn't really matter
|
||||
*/
|
||||
static package_t *depends_resolve(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *pkg, *chk;
|
||||
package_t dependpkg;
|
||||
char **dependsvec;
|
||||
int i;
|
||||
void *found;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
dependsvec = depends_split(pkg->depends);
|
||||
i = 0;
|
||||
while (dependsvec[i] != 0) {
|
||||
/* Check for dependencies; first look for installed packages */
|
||||
dependpkg.package = dependsvec[i];
|
||||
if ((found = tfind(&dependpkg, &status, package_compare)) == 0 ||
|
||||
((chk = *(package_t **)found) &&
|
||||
(chk->status & (status_flagok | status_statusinstalled)) !=
|
||||
(status_flagok | status_statusinstalled))) {
|
||||
|
||||
/* if it fails, we look through the list of packages we are going to
|
||||
* install */
|
||||
for (chk = pkgs; chk != 0; chk = chk->next) {
|
||||
if (strcmp(chk->package, dependsvec[i]) == 0 || (chk->provides &&
|
||||
strncmp(chk->provides, dependsvec[i], strlen(dependsvec[i])) == 0)) {
|
||||
if (chk->requiredcount >= DEPENDSMAX) {
|
||||
fprintf(stderr, "Too many dependencies for %s\n", chk->package);
|
||||
return 0;
|
||||
}
|
||||
if (chk != pkg) {
|
||||
chk->requiredfor[chk->requiredcount++] = pkg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chk == 0) {
|
||||
fprintf(stderr, "%s depends on %s, but it is not going to be installed\n", pkg->package, dependsvec[i]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return depends_sort(pkgs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Status file handling routines
|
||||
*
|
||||
* This is a fairly minimalistic implementation. there are two main functions
|
||||
* that are supported:
|
||||
*
|
||||
* 1) reading the entire status file:
|
||||
* the status file is read into memory as a binary-tree, with just the
|
||||
* package and status info preserved
|
||||
*
|
||||
* 2) merging the status file
|
||||
* control info from (new) packages is merged into the status file,
|
||||
* replacing any pre-existing entries. when a merge happens, status info
|
||||
* read using the status_read function is written back to the status file
|
||||
*/
|
||||
static unsigned long status_parse(const char *line)
|
||||
{
|
||||
char *p;
|
||||
int i, j;
|
||||
unsigned long l = 0;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if ((p = strchr(line, ' ')) != NULL) {
|
||||
*p = 0;
|
||||
}
|
||||
j = 1;
|
||||
while (statuswords[i][j] != 0) {
|
||||
if (strcmp(line, statuswords[i][j]) == 0) {
|
||||
l |= (1 << ((int)statuswords[i][0] + j - 1));
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
/* parse error */
|
||||
if (statuswords[i][j] == 0) {
|
||||
return 0;
|
||||
}
|
||||
line = p+1;
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static const char *status_print(unsigned long flags)
|
||||
{
|
||||
/* this function returns a static buffer... */
|
||||
static char buf[256];
|
||||
int i, j;
|
||||
|
||||
buf[0] = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
j = 1;
|
||||
while (statuswords[i][j] != 0) {
|
||||
if ((flags & (1 << ((int)statuswords[i][0] + j - 1))) != 0) {
|
||||
strcat(buf, statuswords[i][j]);
|
||||
if (i < 2) strcat(buf, " ");
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (statuswords[i][j] == 0) {
|
||||
fprintf(stderr, "corrupted status flag!!\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a control file (or a stanza of a status file) and parse it,
|
||||
* filling parsed fields into the package structure
|
||||
*/
|
||||
static int control_read(FILE *file, package_t *p)
|
||||
{
|
||||
char *line;
|
||||
|
||||
while ((line = get_line_from_file(file)) != NULL) {
|
||||
line[strlen(line)] = 0;
|
||||
|
||||
if (strlen(line) == 0) {
|
||||
break;
|
||||
} else
|
||||
if (strstr(line, "Package: ") == line) {
|
||||
p->package = strdup(line + 9);
|
||||
} else
|
||||
if (strstr(line, "Status: ") == line) {
|
||||
p->status = status_parse(line + 8);
|
||||
} else
|
||||
if (strstr(line, "Depends: ") == line) {
|
||||
p->depends = strdup(line + 9);
|
||||
} else
|
||||
if (strstr(line, "Provides: ") == line) {
|
||||
p->provides = strdup(line + 10);
|
||||
} else
|
||||
if (strstr(line, "Description: ") == line) {
|
||||
p->description = strdup(line + 13);
|
||||
/* This is specific to the Debian Installer. Ifdef? */
|
||||
} else
|
||||
if (strstr(line, "installer-menu-item: ") == line) {
|
||||
p->installer_menu_item = atoi(line + 21);
|
||||
}
|
||||
/* TODO: localized descriptions */
|
||||
}
|
||||
free(line);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void *status_read(void)
|
||||
{
|
||||
FILE *f;
|
||||
void *status = 0;
|
||||
package_t *m = 0, *p = 0, *t = 0;
|
||||
|
||||
if ((f = fopen(statusfile, "r")) == NULL) {
|
||||
perror(statusfile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (getenv(udpkg_quiet) == NULL) {
|
||||
printf("(Reading database...)\n");
|
||||
}
|
||||
|
||||
while (!feof(f)) {
|
||||
m = (package_t *)xmalloc(sizeof(package_t));
|
||||
memset(m, 0, sizeof(package_t));
|
||||
control_read(f, m);
|
||||
if (m->package) {
|
||||
/*
|
||||
* If there is an item in the tree by this name,
|
||||
* it must be a virtual package; insert real
|
||||
* package in preference.
|
||||
*/
|
||||
tdelete(m, &status, package_compare);
|
||||
tsearch(m, &status, package_compare);
|
||||
if (m->provides) {
|
||||
/*
|
||||
* A "Provides" triggers the insertion
|
||||
* of a pseudo package into the status
|
||||
* binary-tree.
|
||||
*/
|
||||
p = (package_t *)xmalloc(sizeof(package_t));
|
||||
memset(p, 0, sizeof(package_t));
|
||||
p->package = strdup(m->provides);
|
||||
|
||||
t = *(package_t **)tsearch(p, &status, package_compare);
|
||||
if (t != p) {
|
||||
free(p->package);
|
||||
free(p);
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Pseudo package status is the
|
||||
* same as the status of the
|
||||
* package providing it
|
||||
* FIXME: (not quite right, if 2
|
||||
* packages of different statuses
|
||||
* provide it).
|
||||
*/
|
||||
t->status = m->status;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
free(m);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int status_merge(void *status, package_t *pkgs)
|
||||
{
|
||||
FILE *fin, *fout;
|
||||
char *line;
|
||||
package_t *pkg = 0, *statpkg = 0;
|
||||
package_t locpkg;
|
||||
int r = 0;
|
||||
|
||||
if ((fin = fopen(statusfile, "r")) == NULL) {
|
||||
perror(statusfile);
|
||||
return 0;
|
||||
}
|
||||
if ((fout = fopen(new_statusfile, "w")) == NULL) {
|
||||
perror(new_statusfile);
|
||||
return 0;
|
||||
}
|
||||
if (getenv(udpkg_quiet) == NULL) {
|
||||
printf("(Updating database...)\n");
|
||||
}
|
||||
|
||||
while (((line = get_line_from_file(fin)) != NULL) && !feof(fin)) {
|
||||
line[strlen(line)] = 0; /* trim newline */
|
||||
/* If we see a package header, find out if it's a package
|
||||
* that we have processed. if so, we skip that block for
|
||||
* now (write it at the end).
|
||||
*
|
||||
* we also look at packages in the status cache and update
|
||||
* their status fields
|
||||
*/
|
||||
if (strstr(line, "Package: ") == line) {
|
||||
for (pkg = pkgs; pkg != 0 && strncmp(line + 9,
|
||||
pkg->package, strlen(line) - 9) != 0;
|
||||
pkg = pkg->next) ;
|
||||
|
||||
locpkg.package = line + 9;
|
||||
statpkg = tfind(&locpkg, &status, package_compare);
|
||||
|
||||
/* note: statpkg should be non-zero, unless the status
|
||||
* file was changed while we are processing (no locking
|
||||
* is currently done...
|
||||
*/
|
||||
if (statpkg != 0) {
|
||||
statpkg = *(package_t **)statpkg;
|
||||
}
|
||||
}
|
||||
if (pkg != 0) {
|
||||
continue;
|
||||
}
|
||||
if (strstr(line, "Status: ") == line && statpkg != 0) {
|
||||
snprintf(line, sizeof(line), "Status: %s",
|
||||
status_print(statpkg->status));
|
||||
}
|
||||
fputs(line, fout);
|
||||
fputc('\n', fout);
|
||||
}
|
||||
free(line);
|
||||
|
||||
// Print out packages we processed.
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
fprintf(fout, "Package: %s\nStatus: %s\n",
|
||||
pkg->package, status_print(pkg->status));
|
||||
if (pkg->depends)
|
||||
fprintf(fout, "Depends: %s\n", pkg->depends);
|
||||
if (pkg->provides)
|
||||
fprintf(fout, "Provides: %s\n", pkg->provides);
|
||||
if (pkg->installer_menu_item)
|
||||
fprintf(fout, "installer-menu-item: %i\n", pkg->installer_menu_item);
|
||||
if (pkg->description)
|
||||
fprintf(fout, "Description: %s\n", pkg->description);
|
||||
fputc('\n', fout);
|
||||
}
|
||||
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
r = rename(statusfile, bak_statusfile);
|
||||
if (r == 0) {
|
||||
r = rename(new_statusfile, statusfile);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_file(const char *fn)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat(fn, &statbuf) < 0) {
|
||||
return 0;
|
||||
}
|
||||
return S_ISREG(statbuf.st_mode);
|
||||
}
|
||||
|
||||
static int dpkg_doconfigure(package_t *pkg)
|
||||
{
|
||||
int r;
|
||||
char postinst[1024];
|
||||
char buf[1024];
|
||||
|
||||
DPRINTF("Configuring %s\n", pkg->package);
|
||||
pkg->status &= status_statusmask;
|
||||
snprintf(postinst, sizeof(postinst), "%s%s.postinst", infodir, pkg->package);
|
||||
|
||||
if (is_file(postinst)) {
|
||||
snprintf(buf, sizeof(buf), "%s configure", postinst);
|
||||
if ((r = do_system(buf)) != 0) {
|
||||
fprintf(stderr, "postinst exited with status %d\n", r);
|
||||
pkg->status |= status_statushalfconfigured;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
pkg->status |= status_statusinstalled;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dpkg_dounpack(package_t *pkg)
|
||||
{
|
||||
int r = 0, i;
|
||||
char *cwd;
|
||||
FILE *outfp;
|
||||
char *src_file = NULL;
|
||||
char *dst_file = NULL;
|
||||
char *lst_file = NULL;
|
||||
char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst",
|
||||
"/conffiles", "/md5sums", "/shlibs", "/templates" };
|
||||
char buf[1024], buf2[1024];
|
||||
|
||||
DPRINTF("Unpacking %s\n", pkg->package);
|
||||
|
||||
cwd = getcwd(0, 0);
|
||||
chdir("/");
|
||||
deb_extract(dpkg_deb_extract, "/", pkg->file);
|
||||
|
||||
/* Installs the package scripts into the info directory */
|
||||
for (i = 0; i < sizeof(adminscripts) / sizeof(adminscripts[0]); i++) {
|
||||
/* The full path of the current location of the admin file */
|
||||
src_file = xrealloc(src_file, strlen(dpkgcidir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
|
||||
strcpy(src_file, dpkgcidir);
|
||||
strcat(src_file, pkg->package);
|
||||
strcat(src_file, adminscripts[i]);
|
||||
|
||||
/* the full path of where we want the file to be copied to */
|
||||
dst_file = xrealloc(dst_file, strlen(infodir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
|
||||
strcpy(dst_file, infodir);
|
||||
strcat(dst_file, pkg->package);
|
||||
strcat(dst_file, adminscripts[i]);
|
||||
|
||||
/* copy admin file to permanent home */
|
||||
if (copy_file(src_file, dst_file, TRUE, FALSE, FALSE) < 0) {
|
||||
error_msg_and_die("Cannot copy %s to %s ", buf, buf2);
|
||||
}
|
||||
|
||||
/* create the list file */
|
||||
lst_file = (char *) xmalloc(strlen(infodir) + strlen(pkg->package) + 6);
|
||||
strcpy(lst_file, infodir);
|
||||
strcat(lst_file, pkg->package);
|
||||
strcat(lst_file, ".list");
|
||||
outfp = freopen(lst_file, "w", stdout);
|
||||
deb_extract(dpkg_deb_list, NULL, pkg->file);
|
||||
stdout = freopen(NULL, "w", outfp);
|
||||
|
||||
printf("done\n");
|
||||
getchar();
|
||||
|
||||
fclose(outfp);
|
||||
}
|
||||
|
||||
pkg->status &= status_wantmask;
|
||||
pkg->status |= status_wantinstall;
|
||||
pkg->status &= status_flagmask;
|
||||
pkg->status |= status_flagok;
|
||||
pkg->status &= status_statusmask;
|
||||
|
||||
if (r == 0) {
|
||||
pkg->status |= status_statusunpacked;
|
||||
} else {
|
||||
pkg->status |= status_statushalfinstalled;
|
||||
}
|
||||
chdir(cwd);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract and parse the control.tar.gz from the specified package
|
||||
*/
|
||||
static int dpkg_unpackcontrol(package_t *pkg)
|
||||
{
|
||||
char *tmp_name;
|
||||
FILE *file;
|
||||
int length;
|
||||
|
||||
/* clean the temp directory (dpkgcidir) be recreating it */
|
||||
remove_dpkgcidir();
|
||||
if (mkdir(dpkgcidir, S_IRWXU) != 0) {
|
||||
perror("mkdir");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the package name from the file name,
|
||||
* first remove the directories
|
||||
*/
|
||||
if ((tmp_name = strrchr(pkg->file, '/')) == NULL) {
|
||||
tmp_name = pkg->file;
|
||||
} else {
|
||||
tmp_name++;
|
||||
}
|
||||
/* now remove trailing version numbers etc */
|
||||
length = strcspn(tmp_name, "_.");
|
||||
pkg->package = (char *) xmalloc(length + 1);
|
||||
/* store the package name */
|
||||
strncpy(pkg->package, tmp_name, length);
|
||||
|
||||
/* work out the full extraction path */
|
||||
tmp_name = (char *) xmalloc(strlen(dpkgcidir) + strlen(pkg->package) + 9);
|
||||
memset(tmp_name, 0, strlen(dpkgcidir) + strlen(pkg->package) + 9);
|
||||
strcpy(tmp_name, dpkgcidir);
|
||||
strcat(tmp_name, pkg->package);
|
||||
|
||||
/* extract control.tar.gz to the full extraction path */
|
||||
deb_extract(dpkg_deb_control, tmp_name, pkg->file);
|
||||
|
||||
/* parse the extracted control file */
|
||||
strcat(tmp_name, "/control");
|
||||
if ((file = fopen(tmp_name, "r")) == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (control_read(file, pkg) == EXIT_FAILURE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int dpkg_unpack(package_t *pkgs, void *status)
|
||||
{
|
||||
int r = 0;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
if (dpkg_unpackcontrol(pkg) == EXIT_FAILURE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ((r = dpkg_dounpack(pkg)) != 0 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
status_merge(status, pkgs);
|
||||
remove_dpkgcidir();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int dpkg_configure(package_t *pkgs, void *status)
|
||||
{
|
||||
int r = 0;
|
||||
void *found;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0 && r == 0; pkg = pkg->next) {
|
||||
found = tfind(pkg, &status, package_compare);
|
||||
|
||||
if (found == 0) {
|
||||
fprintf(stderr, "Trying to configure %s, but it is not installed\n", pkg->package);
|
||||
r = 1;
|
||||
}
|
||||
/* configure the package listed in the status file;
|
||||
* not pkg, as we have info only for the latter
|
||||
*/
|
||||
else {
|
||||
r = dpkg_doconfigure(*(package_t **)found);
|
||||
}
|
||||
}
|
||||
status_merge(status, 0);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int dpkg_install(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *p, *ordered = 0;
|
||||
|
||||
/* Stage 1: parse all the control information */
|
||||
for (p = pkgs; p != 0; p = p->next) {
|
||||
if (dpkg_unpackcontrol(p) == EXIT_FAILURE) {
|
||||
perror(p->file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Stage 2: resolve dependencies */
|
||||
#ifdef DODEPENDS
|
||||
ordered = depends_resolve(pkgs, status);
|
||||
#else
|
||||
ordered = pkgs;
|
||||
#endif
|
||||
|
||||
/* Stage 3: install */
|
||||
for (p = ordered; p != 0; p = p->next) {
|
||||
p->status &= status_wantmask;
|
||||
p->status |= status_wantinstall;
|
||||
|
||||
/* for now the flag is always set to ok... this is probably
|
||||
* not what we want
|
||||
*/
|
||||
p->status &= status_flagmask;
|
||||
p->status |= status_flagok;
|
||||
|
||||
DPRINTF("Installing %s\n", p->package);
|
||||
if (dpkg_dounpack(p) != 0) {
|
||||
perror(p->file);
|
||||
}
|
||||
if (dpkg_doconfigure(p) != 0) {
|
||||
perror(p->file);
|
||||
}
|
||||
}
|
||||
|
||||
if (ordered != 0) {
|
||||
status_merge(status, pkgs);
|
||||
}
|
||||
remove_dpkgcidir();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dpkg_remove(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *p;
|
||||
|
||||
for (p = pkgs; p != 0; p = p->next)
|
||||
{
|
||||
}
|
||||
status_merge(status, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int dpkg_main(int argc, char **argv)
|
||||
{
|
||||
char opt = 0;
|
||||
char *s;
|
||||
package_t *p, *packages = NULL;
|
||||
char *cwd = getcwd(0, 0);
|
||||
void *status = NULL;
|
||||
|
||||
while (*++argv) {
|
||||
if (**argv == '-') {
|
||||
/* Nasty little hack to "parse" long options. */
|
||||
s = *argv;
|
||||
while (*s == '-') {
|
||||
s++;
|
||||
}
|
||||
opt=s[0];
|
||||
} else {
|
||||
p = (package_t *)xmalloc(sizeof(package_t));
|
||||
memset(p, 0, sizeof(package_t));
|
||||
|
||||
if (**argv == '/') {
|
||||
p->file = *argv;
|
||||
} else
|
||||
if (opt != 'c') {
|
||||
p->file = xmalloc(strlen(cwd) + strlen(*argv) + 2);
|
||||
sprintf(p->file, "%s/%s", cwd, *argv);
|
||||
} else {
|
||||
p->package = strdup(*argv);
|
||||
}
|
||||
|
||||
p->next = packages;
|
||||
packages = p;
|
||||
}
|
||||
}
|
||||
|
||||
status = status_read();
|
||||
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
return dpkg_install(packages, status);
|
||||
case 'r':
|
||||
return dpkg_remove(packages, status);
|
||||
case 'u':
|
||||
return dpkg_unpack(packages, status);
|
||||
case 'c':
|
||||
return dpkg_configure(packages, status);
|
||||
default :
|
||||
show_usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Merge this applet into dpkg when dpkg becomes more stable
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
extern ar_headers_t get_ar_headers(int srcFd);
|
||||
extern int tar_unzip_init(int tarFd);
|
||||
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int tostdoutFlag, int verboseFlag, char** extractList, char** excludeList);
|
||||
|
||||
static const int dpkg_deb_contents = 1;
|
||||
static const int dpkg_deb_control = 2;
|
||||
// const int dpkg_deb_info = 4;
|
||||
static const int dpkg_deb_extract = 8;
|
||||
static const int dpkg_deb_verbose_extract = 16;
|
||||
static const int dpkg_deb_list = 32;
|
||||
|
||||
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename)
|
||||
{
|
||||
char **extract_list = NULL;
|
||||
ar_headers_t *ar_headers = NULL;
|
||||
char ar_filename[15];
|
||||
int extract_flag = FALSE;
|
||||
int list_flag = FALSE;
|
||||
int verbose_flag = FALSE;
|
||||
int extract_to_stdout = FALSE;
|
||||
int srcFd = 0;
|
||||
int status;
|
||||
|
||||
if (dpkg_deb_contents == (dpkg_deb_contents & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
verbose_flag = TRUE;
|
||||
list_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_list == (dpkg_deb_list & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
list_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_control == (dpkg_deb_control & optflags)) {
|
||||
strcpy(ar_filename, "control.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_extract == (dpkg_deb_extract & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_verbose_extract == (dpkg_deb_verbose_extract & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
list_flag = TRUE;
|
||||
}
|
||||
|
||||
ar_headers = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
srcFd = open(deb_filename, O_RDONLY);
|
||||
|
||||
*ar_headers = get_ar_headers(srcFd);
|
||||
if (ar_headers->next == NULL) {
|
||||
error_msg_and_die("Couldnt find %s in %s", ar_filename, deb_filename);
|
||||
}
|
||||
|
||||
while (ar_headers->next != NULL) {
|
||||
if (strcmp(ar_headers->name, ar_filename) == 0) {
|
||||
break;
|
||||
}
|
||||
ar_headers = ar_headers->next;
|
||||
}
|
||||
lseek(srcFd, ar_headers->offset, SEEK_SET);
|
||||
srcFd = tar_unzip_init(srcFd);
|
||||
if ( dir_name != NULL) {
|
||||
if (is_directory(dir_name, TRUE, NULL)==FALSE) {
|
||||
mkdir(dir_name, 0755);
|
||||
}
|
||||
if (chdir(dir_name)==-1) {
|
||||
error_msg_and_die("Cannot change to dir %s", dir_name);
|
||||
}
|
||||
}
|
||||
status = readTarFile(srcFd, extract_flag, list_flag, extract_to_stdout, verbose_flag, NULL, extract_list);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
extern int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
char *target_dir = NULL;
|
||||
int opt = 0;
|
||||
int optflag = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "cexXl")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
optflag |= dpkg_deb_contents;
|
||||
break;
|
||||
case 'e':
|
||||
optflag |= dpkg_deb_control;
|
||||
break;
|
||||
case 'X':
|
||||
optflag |= dpkg_deb_verbose_extract;
|
||||
break;
|
||||
case 'x':
|
||||
optflag |= dpkg_deb_extract;
|
||||
break;
|
||||
case 'l':
|
||||
optflag |= dpkg_deb_list;
|
||||
break;
|
||||
/* case 'I':
|
||||
optflag |= dpkg_deb_info;
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (((optind + 1 ) > argc) || (optflag == 0)) {
|
||||
show_usage();
|
||||
}
|
||||
if ((optflag & dpkg_deb_control) || (optflag & dpkg_deb_extract) || (optflag & dpkg_deb_verbose_extract)) {
|
||||
if ( (optind + 1) == argc ) {
|
||||
target_dir = (char *) xmalloc(7);
|
||||
strcpy(target_dir, "DEBIAN");
|
||||
} else {
|
||||
target_dir = (char *) xmalloc(strlen(argv[optind + 1]));
|
||||
strcpy(target_dir, argv[optind + 1]);
|
||||
}
|
||||
}
|
||||
deb_extract(optflag, target_dir, argv[optind]);
|
||||
/* else if (optflag & dpkg_deb_info) {
|
||||
extract_flag = TRUE;
|
||||
extract_to_stdout = TRUE;
|
||||
strcpy(ar_filename, "control.tar.gz");
|
||||
extract_list = argv+optind+1;
|
||||
printf("list one is [%s]\n",extract_list[0]);
|
||||
}
|
||||
*/
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
+40
-37
@@ -57,7 +57,6 @@ static char *license_msg[] = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#include "busybox.h"
|
||||
#include <getopt.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
@@ -71,45 +70,46 @@ static char *license_msg[] = {
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_memory_exhausted
|
||||
#define bb_need_name_too_long
|
||||
#include "messages.c"
|
||||
|
||||
#define RECORD_IO 0
|
||||
static const int RECORD_IO = 0;
|
||||
|
||||
/* Return codes from gzip */
|
||||
#define OK 0
|
||||
#define ERROR 1
|
||||
#define WARNING 2
|
||||
static const int OK = 0;
|
||||
static const int ERROR = 1;
|
||||
static const int WARNING = 2;
|
||||
|
||||
#define DEFLATED 8
|
||||
#define INBUFSIZ 0x2000 /* input buffer size */
|
||||
#define INBUF_EXTRA 64 /* required by unlzw() */
|
||||
#define OUTBUFSIZ 8192 /* output buffer size */
|
||||
#define OUTBUF_EXTRA 2048 /* required by unlzw() */
|
||||
#define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */
|
||||
static const int DEFLATED = 8;
|
||||
static const int INBUFSIZ = 0x2000; /* input buffer size */
|
||||
static const int INBUF_EXTRA = 64; /* required by unlzw() */
|
||||
static const int OUTBUFSIZ = 8192; /* output buffer size */
|
||||
static const int OUTBUF_EXTRA = 2048; /* required by unlzw() */
|
||||
static const int DIST_BUFSIZE = 0x2000; /* buffer for distances, see trees.c */
|
||||
|
||||
#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */
|
||||
|
||||
/* gzip flag byte */
|
||||
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
|
||||
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
|
||||
#define COMMENT 0x10 /* bit 4 set: file comment present */
|
||||
#define WSIZE 0x8000 /* window size--must be a power of two, and */
|
||||
static const int EXTRA_FIELD = 0x04; /* bit 2 set: extra field present */
|
||||
static const int ORIG_NAME = 0x08; /* bit 3 set: original file name present */
|
||||
static const int COMMENT = 0x10; /* bit 4 set: file comment present */
|
||||
static const int WSIZE = 0x8000; /* window size--must be a power of two, and */
|
||||
/* at least 32K for zip's deflate method */
|
||||
|
||||
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
|
||||
#define BMAX 16 /* maximum bit length of any code (16 for explode) */
|
||||
#define N_MAX 288 /* maximum number of codes in any set */
|
||||
static const int BMAX = 16; /* maximum bit length of any code (16 for explode) */
|
||||
static const int N_MAX = 288; /* maximum number of codes in any set */
|
||||
|
||||
/* PKZIP header definitions */
|
||||
#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */
|
||||
#define LOCCRC 14 /* offset of crc */
|
||||
#define LOCLEN 22 /* offset of uncompressed length */
|
||||
#define EXTHDR 16 /* size of extended local header, inc sig */
|
||||
static const int LOCSIG = 0x04034b50L; /* four-byte lead-in (lsb first) */
|
||||
static const int LOCCRC = 14; /* offset of crc */
|
||||
static const int LOCLEN = 22; /* offset of uncompressed length */
|
||||
static const int EXTHDR = 16; /* size of extended local header, inc sig */
|
||||
|
||||
#define BITS 16
|
||||
static const int BITS = 16;
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef DEBUG
|
||||
@@ -132,7 +132,7 @@ static char *license_msg[] = {
|
||||
# ifdef BUFSIZ
|
||||
# define MAX_PATH_LEN BUFSIZ
|
||||
# else
|
||||
# define MAX_PATH_LEN 1024
|
||||
static const int MAX_PATH_LEN = 1024;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -165,8 +165,8 @@ static ush *tab_prefix1;
|
||||
/* local variables */
|
||||
static int test_mode = 0; /* check file integrity option */
|
||||
static int foreground; /* set if program run in foreground */
|
||||
static int method = DEFLATED; /* compression method */
|
||||
static int exit_code = OK; /* program exit code */
|
||||
static int method; /* compression method */
|
||||
static int exit_code; /* program exit code */
|
||||
static int last_member; /* set for .zip and .Z files */
|
||||
static int part_nb; /* number of parts in .gz file */
|
||||
static long ifile_size; /* input file size, -1 for devices (debug only) */
|
||||
@@ -297,7 +297,7 @@ int in; /* input file descriptor */
|
||||
|
||||
method = (int) get_byte();
|
||||
if (method != DEFLATED) {
|
||||
error_msg("unknown method %d -- get newer version of gzip\n", method);
|
||||
error_msg("unknown method %d -- get newer version of gzip", method);
|
||||
exit_code = ERROR;
|
||||
return -1;
|
||||
}
|
||||
@@ -1116,11 +1116,11 @@ int in, out; /* input and output file descriptors */
|
||||
if (res == 3) {
|
||||
error_msg(memory_exhausted);
|
||||
} else if (res != 0) {
|
||||
error_msg("invalid compressed data--format violated\n");
|
||||
error_msg("invalid compressed data--format violated");
|
||||
}
|
||||
|
||||
} else {
|
||||
error_msg("internal error, invalid method\n");
|
||||
error_msg("internal error, invalid method");
|
||||
}
|
||||
|
||||
/* Get the crc and original length */
|
||||
@@ -1149,15 +1149,15 @@ int in, out; /* input and output file descriptors */
|
||||
|
||||
/* Validate decompression */
|
||||
if (orig_crc != updcrc(outbuf, 0)) {
|
||||
error_msg("invalid compressed data--crc error\n");
|
||||
error_msg("invalid compressed data--crc error");
|
||||
}
|
||||
if (orig_len != (ulg) bytes_out) {
|
||||
error_msg("invalid compressed data--length error\n");
|
||||
error_msg("invalid compressed data--length error");
|
||||
}
|
||||
|
||||
/* Check if there are more entries in a pkzip file */
|
||||
if (pkzip && inptr + 4 < insize && LG(inbuf + inptr) == LOCSIG) {
|
||||
fprintf(stderr, "has more than one entry--rest ignored\n");
|
||||
error_msg("has more than one entry--rest ignored");
|
||||
if (exit_code == OK)
|
||||
exit_code = WARNING;
|
||||
}
|
||||
@@ -1222,8 +1222,11 @@ int gunzip_main(int argc, char **argv)
|
||||
int force = 0;
|
||||
struct stat statBuf;
|
||||
char *delFileName;
|
||||
char ifname[MAX_PATH_LEN + 1]; /* input file name */
|
||||
char ofname[MAX_PATH_LEN + 1]; /* output file name */
|
||||
RESERVE_BB_BUFFER(ifname, MAX_PATH_LEN+1); /* input file name */
|
||||
RESERVE_BB_BUFFER(ofname, MAX_PATH_LEN+1); /* output file name */
|
||||
|
||||
method = DEFLATED; /* default compression method */
|
||||
exit_code = OK; /* let's go out on a limb and assume everything will run fine (wink wink) */
|
||||
|
||||
if (strcmp(applet_name, "zcat") == 0) {
|
||||
force = 1;
|
||||
@@ -1247,7 +1250,7 @@ int gunzip_main(int argc, char **argv)
|
||||
force = 1;
|
||||
break;
|
||||
default:
|
||||
usage(gunzip_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1258,9 +1261,9 @@ int gunzip_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
|
||||
error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
|
||||
error_msg_and_die( "data not read from terminal. Use -f to force it.");
|
||||
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
|
||||
error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
|
||||
error_msg_and_die( "data not written to terminal. Use -f to force it.");
|
||||
|
||||
gunzip_init();
|
||||
|
||||
@@ -1272,7 +1275,7 @@ int gunzip_main(int argc, char **argv)
|
||||
} else {
|
||||
/* Open up the input file */
|
||||
if (argc <= 0)
|
||||
usage(gunzip_usage);
|
||||
show_usage();
|
||||
if (strlen(*argv) > MAX_PATH_LEN) {
|
||||
error_msg(name_too_long);
|
||||
exit(WARNING);
|
||||
|
||||
+24
-43
@@ -29,11 +29,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
|
||||
/* These defines are very important for BusyBox. Without these,
|
||||
* huge chunks of ram are pre-allocated making the BusyBox bss
|
||||
* size Freaking Huge(tm), which is a bad thing.*/
|
||||
@@ -43,8 +38,15 @@
|
||||
/* I don't like nested includes, but the string and io functions are used
|
||||
* too often
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
|
||||
#define memzero(s, n) memset ((void *)(s), 0, (n))
|
||||
|
||||
#ifndef RETSIGTYPE
|
||||
@@ -1381,7 +1383,7 @@ int length;
|
||||
(char *) window + start, length) != EQUAL) {
|
||||
fprintf(stderr,
|
||||
" start %d, match %d, length %d\n", start, match, length);
|
||||
error_msg("invalid match\n");
|
||||
error_msg("invalid match");
|
||||
}
|
||||
if (verbose > 1) {
|
||||
fprintf(stderr, "\\[%d,%d]", start - match, length);
|
||||
@@ -1627,12 +1629,6 @@ ulg deflate()
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
#if defined(DIRENT)
|
||||
# include <dirent.h>
|
||||
typedef struct dirent dir_type;
|
||||
@@ -1811,7 +1807,7 @@ int gzip_main(int argc, char **argv)
|
||||
case 'd':
|
||||
exit(gunzip_main(argc, argv));
|
||||
default:
|
||||
usage(gzip_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1821,9 +1817,9 @@ int gzip_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
|
||||
error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
|
||||
error_msg_and_die( "data not read from terminal. Use -f to force it.");
|
||||
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
|
||||
error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
|
||||
error_msg_and_die( "data not written to terminal. Use -f to force it.");
|
||||
|
||||
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
|
||||
if (foreground) {
|
||||
@@ -1864,21 +1860,16 @@ int gzip_main(int argc, char **argv)
|
||||
} else {
|
||||
/* Open up the input file */
|
||||
if (argc <= 0)
|
||||
usage(gzip_usage);
|
||||
show_usage();
|
||||
strncpy(ifname, *argv, MAX_PATH_LEN);
|
||||
|
||||
/* Open input fille */
|
||||
/* Open input file */
|
||||
inFileNum = open(ifname, O_RDONLY);
|
||||
if (inFileNum < 0) {
|
||||
perror(ifname);
|
||||
exit(WARNING);
|
||||
}
|
||||
if (inFileNum < 0)
|
||||
perror_msg_and_die("%s", ifname);
|
||||
/* Get the time stamp on the input file. */
|
||||
result = stat(ifname, &statBuf);
|
||||
if (result < 0) {
|
||||
perror(ifname);
|
||||
exit(WARNING);
|
||||
}
|
||||
if (stat(ifname, &statBuf) < 0)
|
||||
perror_msg_and_die("%s", ifname);
|
||||
time_stamp = statBuf.st_ctime;
|
||||
ifile_size = statBuf.st_size;
|
||||
}
|
||||
@@ -1909,10 +1900,8 @@ int gzip_main(int argc, char **argv)
|
||||
#else
|
||||
outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL);
|
||||
#endif
|
||||
if (outFileNum < 0) {
|
||||
perror(ofname);
|
||||
exit(WARNING);
|
||||
}
|
||||
if (outFileNum < 0)
|
||||
perror_msg_and_die("%s", ofname);
|
||||
SET_BINARY_MODE(outFileNum);
|
||||
/* Set permissions on the file */
|
||||
fchmod(outFileNum, statBuf.st_mode);
|
||||
@@ -1930,10 +1919,8 @@ int gzip_main(int argc, char **argv)
|
||||
else
|
||||
delFileName = ofname;
|
||||
|
||||
if (unlink(delFileName) < 0) {
|
||||
perror(delFileName);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (unlink(delFileName) < 0)
|
||||
perror_msg_and_die("%s", delFileName);
|
||||
}
|
||||
|
||||
return(exit_code);
|
||||
@@ -2902,7 +2889,7 @@ int eof; /* true if this is the last block for a file */
|
||||
#endif
|
||||
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
|
||||
if (buf == (char *) 0)
|
||||
error_msg("block vanished\n");
|
||||
error_msg("block vanished");
|
||||
|
||||
copy_block(buf, (unsigned) stored_len, 0); /* without header */
|
||||
compressed_len = stored_len << 3;
|
||||
@@ -3085,7 +3072,7 @@ local void set_file_type()
|
||||
bin_freq += dyn_ltree[n++].Freq;
|
||||
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
|
||||
if (*file_type == BINARY && translate_eol) {
|
||||
error_msg("-l used on binary file\n");
|
||||
error_msg("-l used on binary file");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3106,12 +3093,6 @@ local void set_file_type()
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* Copy input to output unchanged: zcat == cat with --force.
|
||||
* IN assertion: insize bytes have already been read in inbuf.
|
||||
@@ -3247,7 +3228,7 @@ char *env; /* name of environment variable */
|
||||
|
||||
/* Copy the program name first */
|
||||
if (oargc-- < 0)
|
||||
error_msg("argc<=0\n");
|
||||
error_msg("argc<=0");
|
||||
*(nargv++) = *(oargv++);
|
||||
|
||||
/* Then copy the environment args */
|
||||
|
||||
+217
-225
@@ -6,7 +6,7 @@
|
||||
* ground up. It still has remnents of the old code lying about, but it is
|
||||
* very different now (i.e. cleaner, less global variables, etc)
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Based in part in the tar implementation in sash
|
||||
@@ -36,11 +36,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_io_error
|
||||
#define bb_need_name_longer_than_foo
|
||||
#include "messages.c"
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@@ -51,6 +46,15 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <getopt.h>
|
||||
#include <fnmatch.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_io_error
|
||||
#define bb_need_name_longer_than_foo
|
||||
#include "messages.c"
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
extern int unzip(int in, int out);
|
||||
@@ -63,7 +67,7 @@ extern int gunzip_init();
|
||||
#define MINOR(dev) ((dev)&0xff)
|
||||
#endif
|
||||
|
||||
#define NAME_SIZE 100
|
||||
enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */
|
||||
|
||||
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
|
||||
struct TarHeader
|
||||
@@ -93,9 +97,9 @@ typedef struct TarHeader TarHeader;
|
||||
/* A few useful constants */
|
||||
#define TAR_MAGIC "ustar" /* ustar and a null */
|
||||
#define TAR_VERSION " " /* Be compatable with GNU tar format */
|
||||
#define TAR_MAGIC_LEN 6
|
||||
#define TAR_VERSION_LEN 2
|
||||
#define TAR_BLOCK_SIZE 512
|
||||
static const int TAR_MAGIC_LEN = 6;
|
||||
static const int TAR_VERSION_LEN = 2;
|
||||
static const int TAR_BLOCK_SIZE = 512;
|
||||
|
||||
/* A nice enum with all the possible tar file content types */
|
||||
enum TarFileType
|
||||
@@ -134,7 +138,7 @@ struct TarInfo
|
||||
typedef struct TarInfo TarInfo;
|
||||
|
||||
/* Local procedures to restore files from a tar file. */
|
||||
static int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int tostdoutFlag, int verboseFlag, char** extractList,
|
||||
char** excludeList);
|
||||
|
||||
@@ -146,14 +150,14 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
/* Signal handler for when child gzip process dies... */
|
||||
void child_died()
|
||||
static void child_died()
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static int tar_unzip_init(int tarFd)
|
||||
extern int tar_unzip_init(int tarFd)
|
||||
{
|
||||
int child_pid;
|
||||
static int unzip_pipe[2];
|
||||
@@ -161,23 +165,33 @@ static int tar_unzip_init(int tarFd)
|
||||
signal(SIGCHLD, child_died);
|
||||
|
||||
if (pipe(unzip_pipe)!=0)
|
||||
error_msg_and_die("pipe error\n");
|
||||
|
||||
error_msg_and_die("pipe error");
|
||||
|
||||
if ( (child_pid = fork()) == -1)
|
||||
error_msg_and_die("fork failure\n");
|
||||
error_msg_and_die("fork failure");
|
||||
|
||||
if (child_pid==0) {
|
||||
/* child process */
|
||||
close(unzip_pipe[0]);
|
||||
gunzip_init();
|
||||
unzip(tarFd, unzip_pipe[1]);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
else {
|
||||
/* return fd of uncompressed data to parent process */
|
||||
close(unzip_pipe[1]);
|
||||
return(unzip_pipe[0]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
static struct option longopts[] = {
|
||||
{ "exclude", 1, NULL, 'e' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
extern int tar_main(int argc, char **argv)
|
||||
{
|
||||
char** excludeList=NULL;
|
||||
@@ -185,7 +199,6 @@ extern int tar_main(int argc, char **argv)
|
||||
const char *tarName="-";
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
int excludeListSize=0;
|
||||
char *excludeFileName ="-";
|
||||
FILE *fileList;
|
||||
char file[256];
|
||||
#endif
|
||||
@@ -198,126 +211,108 @@ extern int tar_main(int argc, char **argv)
|
||||
int verboseFlag = FALSE;
|
||||
int tostdoutFlag = FALSE;
|
||||
int status = FALSE;
|
||||
int firstOpt = TRUE;
|
||||
int stopIt;
|
||||
int opt;
|
||||
|
||||
if (argc <= 1)
|
||||
usage(tar_usage);
|
||||
show_usage();
|
||||
|
||||
while (*(++argv) && (**argv == '-' || firstOpt == TRUE)) {
|
||||
firstOpt=FALSE;
|
||||
stopIt=FALSE;
|
||||
while (stopIt==FALSE && **argv) {
|
||||
switch (*((*argv)++)) {
|
||||
case 'c':
|
||||
if (extractFlag == TRUE || listFlag == TRUE)
|
||||
goto flagError;
|
||||
createFlag = TRUE;
|
||||
break;
|
||||
case 'x':
|
||||
if (listFlag == TRUE || createFlag == TRUE)
|
||||
goto flagError;
|
||||
extractFlag = TRUE;
|
||||
break;
|
||||
case 't':
|
||||
if (extractFlag == TRUE || createFlag == TRUE)
|
||||
goto flagError;
|
||||
listFlag = TRUE;
|
||||
break;
|
||||
if (argv[1][0] != '-') {
|
||||
char *tmp = xmalloc(strlen(argv[1]) + 2);
|
||||
tmp[0] = '-';
|
||||
strcpy(tmp + 1, argv[1]);
|
||||
argv[1] = tmp;
|
||||
}
|
||||
|
||||
while (
|
||||
#ifndef BB_FEATURE_TAR_EXCLUDE
|
||||
(opt = getopt(argc, argv, "cxtzvOf:"))
|
||||
#else
|
||||
(opt = getopt_long(argc, argv, "cxtzvOf:X:", longopts, NULL))
|
||||
#endif
|
||||
> 0) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
if (extractFlag == TRUE || listFlag == TRUE)
|
||||
goto flagError;
|
||||
createFlag = TRUE;
|
||||
break;
|
||||
case 'x':
|
||||
if (listFlag == TRUE || createFlag == TRUE)
|
||||
goto flagError;
|
||||
extractFlag = TRUE;
|
||||
break;
|
||||
case 't':
|
||||
if (extractFlag == TRUE || createFlag == TRUE)
|
||||
goto flagError;
|
||||
listFlag = TRUE;
|
||||
break;
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
case 'z':
|
||||
unzipFlag = TRUE;
|
||||
break;
|
||||
case 'z':
|
||||
unzipFlag = TRUE;
|
||||
break;
|
||||
#endif
|
||||
case 'v':
|
||||
verboseFlag = TRUE;
|
||||
break;
|
||||
case 'O':
|
||||
tostdoutFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
if (*tarName != '-')
|
||||
error_msg_and_die( "Only one 'f' option allowed\n");
|
||||
tarName = *(++argv);
|
||||
if (tarName == NULL)
|
||||
error_msg_and_die( "Option requires an argument: No file specified\n");
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
case 'v':
|
||||
verboseFlag = TRUE;
|
||||
break;
|
||||
case 'O':
|
||||
tostdoutFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
if (*tarName != '-')
|
||||
error_msg_and_die( "Only one 'f' option allowed");
|
||||
tarName = optarg;
|
||||
break;
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
case 'e':
|
||||
if (strcmp(*argv, "xclude")==0) {
|
||||
excludeList=xrealloc( excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = *(++argv);
|
||||
if (excludeList[excludeListSize] == NULL)
|
||||
error_msg_and_die( "Option requires an argument: No file specified\n");
|
||||
/* Remove leading "/"s */
|
||||
if (*excludeList[excludeListSize] =='/')
|
||||
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
}
|
||||
case 'X':
|
||||
if (*excludeFileName != '-')
|
||||
error_msg_and_die("Only one 'X' option allowed\n");
|
||||
excludeFileName = *(++argv);
|
||||
if (excludeFileName == NULL)
|
||||
error_msg_and_die("Option requires an argument: No file specified\n");
|
||||
fileList = fopen (excludeFileName, "r");
|
||||
if (! fileList)
|
||||
error_msg_and_die("Exclude file: file not found\n");
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
if (file[strlen(file)-1] == '\n')
|
||||
file[strlen(file)-1] = '\0';
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Remove leading "/"s */
|
||||
while (*excludeList[excludeListSize] == '/')
|
||||
excludeList[excludeListSize]++;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
}
|
||||
fclose(fileList);
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
case 'e':
|
||||
excludeList=xrealloc( excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = optarg;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
case 'X':
|
||||
fileList = xfopen(optarg, "r");
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
chomp(file);
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
}
|
||||
fclose(fileList);
|
||||
break;
|
||||
#endif
|
||||
case '-':
|
||||
break;
|
||||
default:
|
||||
usage(tar_usage);
|
||||
}
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Do the correct type of action supplying the rest of the
|
||||
* command line arguments as the list of files to process.
|
||||
*/
|
||||
if (createFlag == TRUE) {
|
||||
#ifndef BB_FEATURE_TAR_CREATE
|
||||
error_msg_and_die( "This version of tar was not compiled with tar creation support.\n");
|
||||
error_msg_and_die( "This version of tar was not compiled with tar creation support.");
|
||||
#else
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
if (unzipFlag==TRUE)
|
||||
error_msg_and_die("Creation of compressed not internally support by tar, pipe to busybox gunzip\n");
|
||||
error_msg_and_die("Creation of compressed not internally support by tar, pipe to busybox gunzip");
|
||||
#endif
|
||||
status = writeTarFile(tarName, verboseFlag, argv, excludeList);
|
||||
status = writeTarFile(tarName, verboseFlag, argv + optind, excludeList);
|
||||
#endif
|
||||
}
|
||||
if (listFlag == TRUE || extractFlag == TRUE) {
|
||||
int tarFd;
|
||||
if (*argv)
|
||||
extractList = argv;
|
||||
if (argv[optind])
|
||||
extractList = argv + optind;
|
||||
/* Open the tar file for reading. */
|
||||
if (!strcmp(tarName, "-"))
|
||||
tarFd = fileno(stdin);
|
||||
else
|
||||
tarFd = open(tarName, O_RDONLY);
|
||||
if (tarFd < 0)
|
||||
error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno));
|
||||
perror_msg_and_die("Error opening '%s'", tarName);
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
/* unzip tarFd in a seperate process */
|
||||
@@ -334,7 +329,7 @@ extern int tar_main(int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
flagError:
|
||||
error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified\n");
|
||||
error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -387,7 +382,7 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
}
|
||||
if ( (readSize = full_read(header->tarFd, buffer, readSize)) <= 0 ) {
|
||||
/* Tarball seems to have a problem */
|
||||
error_msg("Unexpected EOF in archive\n");
|
||||
error_msg("Unexpected EOF in archive");
|
||||
return( FALSE);
|
||||
}
|
||||
if ( readSize < writeSize )
|
||||
@@ -425,16 +420,18 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
return( TRUE);
|
||||
|
||||
if (create_path(header->name, header->mode) != TRUE) {
|
||||
error_msg("%s: Cannot mkdir: %s\n",
|
||||
header->name, strerror(errno));
|
||||
perror_msg("%s: Cannot mkdir", header->name);
|
||||
return( FALSE);
|
||||
}
|
||||
/* make the final component, just in case it was
|
||||
* omitted by create_path() (which will skip the
|
||||
* directory if it doesn't have a terminating '/') */
|
||||
if (mkdir(header->name, header->mode) == 0) {
|
||||
fixUpPermissions(header);
|
||||
if (mkdir(header->name, header->mode) < 0 && errno != EEXIST) {
|
||||
perror_msg("%s", header->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fixUpPermissions(header);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
@@ -445,8 +442,8 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
return( TRUE);
|
||||
|
||||
if (link(header->linkname, header->name) < 0) {
|
||||
error_msg("%s: Cannot create hard link to '%s': %s\n",
|
||||
header->name, header->linkname, strerror(errno));
|
||||
perror_msg("%s: Cannot create hard link to '%s'", header->name,
|
||||
header->linkname);
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
@@ -463,8 +460,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
|
||||
#ifdef S_ISLNK
|
||||
if (symlink(header->linkname, header->name) < 0) {
|
||||
error_msg("%s: Cannot create symlink to '%s': %s\n",
|
||||
header->name, header->linkname, strerror(errno));
|
||||
perror_msg("%s: Cannot create symlink to '%s'", header->name,
|
||||
header->linkname);
|
||||
return( FALSE);
|
||||
}
|
||||
/* Try to change ownership of the symlink.
|
||||
@@ -478,7 +475,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
/* Do not change permissions or date on symlink,
|
||||
* since it changes the pointed to file instead. duh. */
|
||||
#else
|
||||
error_msg("%s: Cannot create symlink to '%s': %s\n",
|
||||
error_msg("%s: Cannot create symlink to '%s': %s",
|
||||
header->name, header->linkname,
|
||||
"symlinks not supported");
|
||||
#endif
|
||||
@@ -493,14 +490,12 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
|
||||
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
|
||||
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
|
||||
error_msg("%s: Cannot mknod: %s\n",
|
||||
header->name, strerror(errno));
|
||||
perror_msg("%s: Cannot mknod", header->name);
|
||||
return( FALSE);
|
||||
}
|
||||
} else if (S_ISFIFO(header->mode)) {
|
||||
if (mkfifo(header->name, header->mode) < 0) {
|
||||
error_msg("%s: Cannot mkfifo: %s\n",
|
||||
header->name, strerror(errno));
|
||||
perror_msg("%s: Cannot mkfifo", header->name);
|
||||
return( FALSE);
|
||||
}
|
||||
}
|
||||
@@ -547,7 +542,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
|
||||
++*(header->name);
|
||||
|
||||
if (alreadyWarned == FALSE) {
|
||||
error_msg("Removing leading '/' from member names\n");
|
||||
error_msg("Removing leading '/' from member names");
|
||||
alreadyWarned = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -579,6 +574,47 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
static int exclude_file(char **excluded_files, const char *file)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (excluded_files == NULL)
|
||||
return 0;
|
||||
|
||||
for (i = 0; excluded_files[i] != NULL; i++) {
|
||||
if (excluded_files[i][0] == '/') {
|
||||
if (fnmatch(excluded_files[i], file,
|
||||
FNM_PATHNAME | FNM_LEADING_DIR) == 0)
|
||||
return 1;
|
||||
} else {
|
||||
const char *p;
|
||||
|
||||
for (p = file; p[0] != '\0'; p++) {
|
||||
if ((p == file || p[-1] == '/') && p[0] != '/' &&
|
||||
fnmatch(excluded_files[i], p,
|
||||
FNM_PATHNAME | FNM_LEADING_DIR) == 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int extract_file(char **extract_files, const char *file)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (extract_files == NULL)
|
||||
return 1;
|
||||
|
||||
for (i = 0; extract_files[i] != NULL; i++) {
|
||||
if (fnmatch(extract_files[i], file, FNM_LEADING_DIR) == 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a tar file and extract or list the specified files within it.
|
||||
@@ -593,7 +629,6 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int skipNextHeaderFlag=FALSE;
|
||||
TarHeader rawHeader;
|
||||
TarInfo header;
|
||||
char** tmpList;
|
||||
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up permission setting for us later. */
|
||||
@@ -608,7 +643,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
goto endgame;
|
||||
} else {
|
||||
errorFlag=TRUE;
|
||||
error_msg("Bad tar header, skipping\n");
|
||||
error_msg("Bad tar header, skipping");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -632,56 +667,29 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
}
|
||||
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
{
|
||||
int skipFlag=FALSE;
|
||||
/* Check for excluded files.... */
|
||||
for (tmpList=excludeList; tmpList && *tmpList; tmpList++) {
|
||||
/* Do some extra hoop jumping for when directory names
|
||||
* end in '/' but the entry in tmpList doesn't */
|
||||
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
|
||||
header.name[strlen(header.name)-1]=='/'
|
||||
&& strncmp( *tmpList, header.name,
|
||||
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
|
||||
/* If it is a regular file, pretend to extract it with
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
skipFlag=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (exclude_file(excludeList, header.name)) {
|
||||
/* There are not the droids you're looking for, move along */
|
||||
if (skipFlag==TRUE)
|
||||
continue;
|
||||
/* If it is a regular file, pretend to extract it with
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (extractList != NULL) {
|
||||
int skipFlag = TRUE;
|
||||
for (tmpList = extractList; *tmpList != NULL; tmpList++) {
|
||||
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
|
||||
header.name[strlen(header.name)-1]=='/'
|
||||
&& strncmp( *tmpList, header.name,
|
||||
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
|
||||
/* If it is a regular file, pretend to extract it with
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
skipFlag = FALSE;
|
||||
memmove(extractList+1, extractList,
|
||||
sizeof(*extractList)*(tmpList-extractList));
|
||||
extractList++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!extract_file(extractList, header.name)) {
|
||||
/* There are not the droids you're looking for, move along */
|
||||
if (skipFlag == TRUE) {
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 )
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
continue;
|
||||
/* If it is a regular file, pretend to extract it with
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (listFlag == TRUE) {
|
||||
@@ -782,7 +790,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
error_msg("Unknown file type '%c' in tar file\n", header.type);
|
||||
error_msg("Unknown file type '%c' in tar file", header.type);
|
||||
close( tarFd);
|
||||
return( FALSE);
|
||||
}
|
||||
@@ -790,11 +798,11 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
close(tarFd);
|
||||
if (status > 0) {
|
||||
/* Bummer - we read a partial header */
|
||||
error_msg( "Error reading tar file: %s\n", strerror(errno));
|
||||
perror_msg("Error reading tar file");
|
||||
return ( FALSE);
|
||||
}
|
||||
else if (errorFlag==TRUE) {
|
||||
error_msg( "Error exit delayed from previous errors\n");
|
||||
error_msg( "Error exit delayed from previous errors");
|
||||
return( FALSE);
|
||||
} else
|
||||
return( status);
|
||||
@@ -802,15 +810,9 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
/* Stuff to do when we are done */
|
||||
endgame:
|
||||
close( tarFd);
|
||||
if (extractList != NULL) {
|
||||
for (; *extractList != NULL; extractList++) {
|
||||
error_msg("%s: Not found in archive\n", *extractList);
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
}
|
||||
if ( *(header.name) == '\0' ) {
|
||||
if (errorFlag==TRUE)
|
||||
error_msg( "Error exit delayed from previous errors\n");
|
||||
error_msg( "Error exit delayed from previous errors");
|
||||
else
|
||||
return( TRUE);
|
||||
}
|
||||
@@ -939,47 +941,17 @@ static int putOctal (char *cp, int len, long value)
|
||||
|
||||
/* Write out a tar header for the specified file/directory/whatever */
|
||||
static int
|
||||
writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *statbuf)
|
||||
writeTarHeader(struct TarBallInfo *tbInfo, const char *header_name,
|
||||
const char *real_name, struct stat *statbuf)
|
||||
{
|
||||
long chksum=0;
|
||||
struct TarHeader header;
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
char** tmpList;
|
||||
#endif
|
||||
const unsigned char *cp = (const unsigned char *) &header;
|
||||
ssize_t size = sizeof(struct TarHeader);
|
||||
|
||||
memset( &header, 0, size);
|
||||
|
||||
if (*fileName=='/') {
|
||||
static int alreadyWarned=FALSE;
|
||||
if (alreadyWarned==FALSE) {
|
||||
error_msg("Removing leading '/' from member names\n");
|
||||
alreadyWarned=TRUE;
|
||||
}
|
||||
strncpy(header.name, fileName+1, sizeof(header.name));
|
||||
}
|
||||
else {
|
||||
strncpy(header.name, fileName, sizeof(header.name));
|
||||
}
|
||||
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
/* Check for excluded files.... */
|
||||
for (tmpList=tbInfo->excludeList; tmpList && *tmpList; tmpList++) {
|
||||
/* Do some extra hoop jumping for when directory names
|
||||
* end in '/' but the entry in tmpList doesn't */
|
||||
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
|
||||
header.name[strlen(header.name)-1]=='/'
|
||||
&& strncmp( *tmpList, header.name,
|
||||
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
|
||||
/* Set the mode to something that is not a regular file, thereby
|
||||
* faking out writeTarFile into thinking that nothing further need
|
||||
* be done for this file. Yes, I know this is ugly, but it works. */
|
||||
statbuf->st_mode = 0;
|
||||
return( TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
strncpy(header.name, header_name, sizeof(header.name));
|
||||
|
||||
putOctal(header.mode, sizeof(header.mode), statbuf->st_mode);
|
||||
putOctal(header.uid, sizeof(header.uid), statbuf->st_uid);
|
||||
@@ -1005,9 +977,9 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
int link_size=0;
|
||||
char buffer[BUFSIZ];
|
||||
header.typeflag = SYMTYPE;
|
||||
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
|
||||
link_size = readlink(real_name, buffer, sizeof(buffer) - 1);
|
||||
if ( link_size < 0) {
|
||||
error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
|
||||
perror_msg("Error reading symlink '%s'", header.name);
|
||||
return ( FALSE);
|
||||
}
|
||||
buffer[link_size] = '\0';
|
||||
@@ -1029,7 +1001,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
header.typeflag = REGTYPE;
|
||||
putOctal(header.size, sizeof(header.size), statbuf->st_size);
|
||||
} else {
|
||||
error_msg("%s: Unknown file type\n", fileName);
|
||||
error_msg("%s: Unknown file type", real_name);
|
||||
return ( FALSE);
|
||||
}
|
||||
|
||||
@@ -1046,7 +1018,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
|
||||
/* Now write the header out to disk */
|
||||
if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
|
||||
error_msg(io_error, fileName, strerror(errno));
|
||||
error_msg(io_error, real_name, strerror(errno));
|
||||
return ( FALSE);
|
||||
}
|
||||
/* Pad the header up to the tar block size */
|
||||
@@ -1068,6 +1040,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* userData)
|
||||
{
|
||||
struct TarBallInfo *tbInfo = (struct TarBallInfo *)userData;
|
||||
const char *header_name;
|
||||
|
||||
/*
|
||||
** Check to see if we are dealing with a hard link.
|
||||
@@ -1087,7 +1060,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
|
||||
/* It is against the rules to archive a socket */
|
||||
if (S_ISSOCK(statbuf->st_mode)) {
|
||||
error_msg("%s: socket ignored\n", fileName);
|
||||
error_msg("%s: socket ignored", fileName);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
@@ -1096,16 +1069,35 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
* the new tarball */
|
||||
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
|
||||
tbInfo->statBuf.st_ino == statbuf->st_ino) {
|
||||
error_msg("%s: file is the archive; skipping\n", fileName);
|
||||
error_msg("%s: file is the archive; skipping", fileName);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
header_name = fileName;
|
||||
while (header_name[0] == '/') {
|
||||
static int alreadyWarned=FALSE;
|
||||
if (alreadyWarned==FALSE) {
|
||||
error_msg("Removing leading '/' from member names");
|
||||
alreadyWarned=TRUE;
|
||||
}
|
||||
header_name++;
|
||||
}
|
||||
|
||||
if (strlen(fileName) >= NAME_SIZE) {
|
||||
error_msg(name_longer_than_foo, NAME_SIZE);
|
||||
return ( TRUE);
|
||||
}
|
||||
|
||||
if (writeTarHeader(tbInfo, fileName, statbuf)==FALSE) {
|
||||
if (header_name[0] == '\0')
|
||||
return TRUE;
|
||||
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
if (exclude_file(tbInfo->excludeList, header_name)) {
|
||||
return SKIP;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (writeTarHeader(tbInfo, header_name, fileName, statbuf)==FALSE) {
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
@@ -1118,7 +1110,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
|
||||
/* open the file we want to archive, and make sure all is well */
|
||||
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
|
||||
error_msg("%s: Cannot open: %s\n", fileName, strerror(errno));
|
||||
error_msg("%s: Cannot open: %s", fileName, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
@@ -1157,7 +1149,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
|
||||
/* Make sure there is at least one file to tar up. */
|
||||
if (*argv == NULL)
|
||||
error_msg_and_die("Cowardly refusing to create an empty archive\n");
|
||||
error_msg_and_die("Cowardly refusing to create an empty archive");
|
||||
|
||||
/* Open the tar file for writing. */
|
||||
if (!strcmp(tarName, "-"))
|
||||
@@ -1165,7 +1157,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
else
|
||||
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (tbInfo.tarFd < 0) {
|
||||
error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
|
||||
perror_msg( "Error opening '%s'", tarName);
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
return ( FALSE);
|
||||
}
|
||||
@@ -1200,7 +1192,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
/* Hang up the tools, close up shop, head home */
|
||||
close(tarFd);
|
||||
if (errorFlag == TRUE) {
|
||||
error_msg("Error exit delayed from previous errors\n");
|
||||
error_msg("Error exit delayed from previous errors");
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
+6
-3
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,8 +21,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
@@ -30,7 +33,7 @@ extern int basename_main(int argc, char **argv)
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(basename_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
@@ -14,8 +16,6 @@
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
|
||||
|
||||
const char *applet_name;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
@@ -54,7 +54,7 @@ static char *busybox_fullpath()
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
error_msg("%s: %s\n", proc, strerror(errno));
|
||||
perror_msg("%s", proc);
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
@@ -69,16 +69,16 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links) Link = symlink;
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
sprintf ( command, "%s/%s",
|
||||
install_dir[applets[i].location],
|
||||
applets[i].name);
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
error_msg("%s: %s\n", command, strerror(errno));
|
||||
perror_msg("%s", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,9 +87,29 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct BB_applet search_applet, *applet;
|
||||
const char *s;
|
||||
applet_name = "busybox";
|
||||
const char *s;
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
@@ -121,39 +141,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
search_applet.name = applet_name;
|
||||
applet = bsearch(&search_applet, applets, NUM_APPLETS,
|
||||
sizeof(struct BB_applet), applet_name_compare);
|
||||
if (applet != NULL) {
|
||||
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(applet->usage);
|
||||
exit((*(applet->main)) (argc, argv));
|
||||
}
|
||||
|
||||
return(busybox_main(argc, argv));
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0;
|
||||
int ps_index;
|
||||
char *index, *index2;
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
@@ -179,31 +166,22 @@ int busybox_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* We do not want the word "busybox" to show up in ps, so we move
|
||||
* everything in argv around to fake ps into showing what we want it to
|
||||
* show. Since we are only shrinking the string, we don't need to move
|
||||
* __environ or any of that tedious stuff... */
|
||||
ps_index = 0;
|
||||
index=*argv;
|
||||
index2=argv[argc];
|
||||
index2+=strlen(argv[argc]);
|
||||
while(ps_index < argc) {
|
||||
argv[ps_index]=index;
|
||||
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
|
||||
index+=(strlen(index));
|
||||
*index='\0';
|
||||
index++;
|
||||
ps_index++;
|
||||
}
|
||||
while(index<=index2)
|
||||
*index++='\0';
|
||||
argv[ps_index]=NULL;
|
||||
/* Move the command line down a notch */
|
||||
len = argv[argc] + strlen(argv[argc]) - argv[1];
|
||||
memmove(argv[0], argv[1], len);
|
||||
memset(argv[0] + len, 0, argv[1] - argv[0]);
|
||||
|
||||
/* Fix up the argv pointers */
|
||||
len = argv[1] - argv[0];
|
||||
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] -= len;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
|
||||
@@ -26,27 +26,28 @@
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <mntent.h>
|
||||
#include <regex.h>
|
||||
/* for the _syscall() macros */
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <features.h>
|
||||
/* Stupid libc doesn't have a reliable way for use to know
|
||||
* that libc5 is being used. Assume this is good enough */
|
||||
#if ! defined __GLIBC__ && ! defined __UCLIBC__
|
||||
/* libc5 doesn't define socklen_t */
|
||||
typedef unsigned int socklen_t;
|
||||
#endif
|
||||
|
||||
|
||||
/* Some useful definitions */
|
||||
#define FALSE ((int) 0)
|
||||
#define TRUE ((int) 1)
|
||||
#define SKIP ((int) 2)
|
||||
|
||||
/* for mtab.c */
|
||||
#define MTAB_GETMOUNTPT '1'
|
||||
@@ -68,26 +69,6 @@ static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
|
||||
#endif
|
||||
|
||||
|
||||
/* I don't like nested includes, but the string and io functions are used
|
||||
* too often
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
|
||||
# include <string.h>
|
||||
# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# define memzero(s, n) memset ((void *)(s), 0, (n))
|
||||
#else
|
||||
# include <strings.h>
|
||||
# define strchr index
|
||||
# define strrchr rindex
|
||||
# define memcpy(d, s, n) bcopy((s), (d), (n))
|
||||
# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
|
||||
# define memzero(s, n) bzero((s), (n))
|
||||
#endif
|
||||
|
||||
|
||||
enum Location {
|
||||
_BB_DIR_ROOT = 0,
|
||||
_BB_DIR_BIN,
|
||||
@@ -100,7 +81,6 @@ struct BB_applet {
|
||||
const char* name;
|
||||
int (*main)(int argc, char** argv);
|
||||
enum Location location;
|
||||
const char* usage;
|
||||
};
|
||||
/* From busybox.c */
|
||||
extern const struct BB_applet applets[];
|
||||
@@ -116,13 +96,12 @@ extern const struct BB_applet applets[];
|
||||
#undef PROTOTYPES
|
||||
|
||||
extern const char *applet_name;
|
||||
extern int applet_name_compare(const void *x, const void *y);
|
||||
|
||||
extern void usage(const char *usage) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void show_usage(void) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...);
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
extern void perror_msg(const char *s, ...);
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
|
||||
const char *mode_string(int mode);
|
||||
const char *time_string(time_t timeVal);
|
||||
@@ -147,6 +126,7 @@ int makeString(int argc, const char **argv, char *buf, int bufLen);
|
||||
char *getChunk(int size);
|
||||
char *chunkstrdup(const char *str);
|
||||
void freeChunks(void);
|
||||
ssize_t safe_read(int fd, void *buf, size_t count);
|
||||
int full_write(int fd, const char *buf, int len);
|
||||
int full_read(int fd, char *buf, int len);
|
||||
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
|
||||
@@ -177,27 +157,39 @@ extern void print_file(FILE *file);
|
||||
extern int print_file_by_name(char *filename);
|
||||
extern char process_escape_sequence(char **ptr);
|
||||
extern char *get_last_path_component(char *path);
|
||||
extern void xregcomp(regex_t *preg, const char *regex, int cflags);
|
||||
extern FILE *wfopen(const char *path, const char *mode);
|
||||
extern FILE *xfopen(const char *path, const char *mode);
|
||||
extern void chomp(char *s);
|
||||
extern void trim(char *s);
|
||||
extern struct BB_applet *find_applet_by_name(const char *name);
|
||||
void run_applet_by_name(const char *name, int argc, char **argv);
|
||||
|
||||
#ifndef DMALLOC
|
||||
#ifndef DMALLOC
|
||||
extern void *xmalloc (size_t size);
|
||||
extern void *xrealloc(void *old, size_t size);
|
||||
extern void *xcalloc(size_t nmemb, size_t size);
|
||||
extern char *xstrdup (const char *s);
|
||||
#endif
|
||||
extern char *xstrndup (const char *s, int n);
|
||||
extern char * safe_strncpy(char *dst, const char *src, size_t size);
|
||||
|
||||
struct suffix_mult {
|
||||
char *suffix;
|
||||
int mult;
|
||||
};
|
||||
|
||||
extern unsigned long parse_number(const char *numstr,
|
||||
const struct suffix_mult *suffixes);
|
||||
|
||||
|
||||
/* These parse entries in /etc/passwd and /etc/group. This is desirable
|
||||
* for BusyBox since we want to avoid using the glibc NSS stuff, which
|
||||
* increases target size and is often not needed embedded systems. */
|
||||
extern long my_getpwnam(char *name);
|
||||
extern long my_getgrnam(char *name);
|
||||
extern long my_getpwnam(const char *name);
|
||||
extern long my_getgrnam(const char *name);
|
||||
extern void my_getpwuid(char *name, long uid);
|
||||
extern void my_getgrgid(char *group, long gid);
|
||||
extern long my_getpwnamegid(char *name);
|
||||
extern long my_getpwnamegid(const char *name);
|
||||
|
||||
extern int device_open(char *device, int mode);
|
||||
|
||||
@@ -222,6 +214,11 @@ int nfsmount(const char *spec, const char *node, int *flags,
|
||||
#define RB_POWER_OFF 0x4321fedc
|
||||
#endif
|
||||
|
||||
#if defined(BB_KLOGD) || defined(BB_LOGGER)
|
||||
void syslog_msg_with_name(const char *name, int facility, int pri, const char *msg);
|
||||
void syslog_msg(int facility, int pri, const char *msg);
|
||||
#endif
|
||||
|
||||
/* Include our own copy of struct sysinfo to avoid binary compatability
|
||||
* problems with Linux 2.4, which changed things. Grumble, grumble. */
|
||||
struct sysinfo {
|
||||
@@ -250,4 +247,25 @@ extern int sysinfo (struct sysinfo* info);
|
||||
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
|
||||
#endif
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
const char *make_human_readable_str(unsigned long val, unsigned long hr);
|
||||
#endif
|
||||
enum {
|
||||
KILOBYTE = 1024,
|
||||
MEGABYTE = (KILOBYTE*1024),
|
||||
GIGABYTE = (MEGABYTE*1024)
|
||||
};
|
||||
|
||||
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
|
||||
#else
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
|
||||
#endif
|
||||
|
||||
#if defined(BB_FEATURE_RM_INTERACTIVE) && defined(BB_RM)
|
||||
int ask_confirmation(void);
|
||||
#endif
|
||||
|
||||
#endif /* _BB_INTERNAL_H_ */
|
||||
+10
-2
@@ -1,12 +1,20 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
match($2,"_BB_DIR[A-Z_]*")
|
||||
dir=substr($2,RSTART+7,RLENGTH-7)
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
|
||||
+7
-4
@@ -1,13 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr '[:upper:]' '[:lower:]' | sort
|
||||
| tr A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
cd ${2:-.}
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
Name: busybox
|
||||
Version: 0.48
|
||||
Version: 0.50
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,8 +21,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
+10
-22
@@ -3,7 +3,7 @@
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,15 +22,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_option
|
||||
#define bb_need_too_few_args
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
|
||||
|
||||
static long uid = -1;
|
||||
@@ -64,7 +65,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
case CHMOD_APP:
|
||||
/* Parse the specified modes */
|
||||
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
|
||||
error_msg_and_die( "unknown mode: %s\n", theMode);
|
||||
error_msg_and_die( "unknown mode: %s", theMode);
|
||||
}
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
@@ -80,17 +81,13 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
int recursiveFlag = FALSE;
|
||||
char *groupName=NULL;
|
||||
char *p=NULL;
|
||||
const char *appUsage;
|
||||
|
||||
whichApp = (strcmp(applet_name, "chown") == 0)?
|
||||
CHOWN_APP : (strcmp(applet_name, "chmod") == 0)?
|
||||
CHMOD_APP : CHGRP_APP;
|
||||
|
||||
appUsage = (whichApp == CHOWN_APP)?
|
||||
chown_usage : (whichApp == CHMOD_APP) ? chmod_usage : chgrp_usage;
|
||||
whichApp = (applet_name[2]=='o')? /* chown */
|
||||
CHOWN_APP : (applet_name[2]=='m')? /* chmod */
|
||||
CHMOD_APP : CHGRP_APP;
|
||||
|
||||
if (argc < 2)
|
||||
usage(appUsage);
|
||||
show_usage();
|
||||
argv++;
|
||||
|
||||
/* Parse options */
|
||||
@@ -125,8 +122,6 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
gid = strtoul(groupName, &p, 10); /* maybe it's already numeric */
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
if (gid == -1)
|
||||
goto bad_group;
|
||||
} else {
|
||||
groupName = strchr(*argv, '.');
|
||||
if (groupName == NULL)
|
||||
@@ -136,8 +131,6 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
gid = strtoul(groupName, &p, 10);
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
if (gid == -1)
|
||||
goto bad_group;
|
||||
} else
|
||||
gid = -1;
|
||||
}
|
||||
@@ -148,9 +141,6 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
uid = strtoul(*argv, &p, 10); /* if numeric ... */
|
||||
if (*argv == p)
|
||||
uid = my_getpwnam(*argv);
|
||||
if (uid == -1) {
|
||||
error_msg_and_die( "unknown user name: %s\n", *argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,8 +155,6 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
bad_group:
|
||||
error_msg_and_die( "unknown group name: %s\n", groupName);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,23 +22,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(chroot_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
@@ -57,7 +58,7 @@ int chroot_main(int argc, char **argv)
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,33 +4,32 @@
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
#include "busybox.h"
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_ACTIVATE 0x5606 /* make vt active */
|
||||
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage (chvt_usage);
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,8 +22,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int clear_main(int argc, char **argv)
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
#ifndef CMDEDIT_H
|
||||
#define CMDEDIT_H
|
||||
|
||||
#ifdef BB_FEATURE_SH_COMMAND_EDITING
|
||||
/* unix systems can #define POSIX to use termios, otherwise
|
||||
* the bsd or sysv interface will be used
|
||||
*/
|
||||
|
||||
#ifdef BB_FEATURE_COMMAND_EDITING
|
||||
#include <stddef.h>
|
||||
|
||||
typedef size_t (*cmdedit_strwidth_proc)(char *);
|
||||
#include "busybox.h"
|
||||
|
||||
void cmdedit_init(void);
|
||||
void cmdedit_terminate(void);
|
||||
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
|
||||
void cmdedit_setwidth(int); /* specify width of screen */
|
||||
void cmdedit_histadd(char *); /* adds entries to hist */
|
||||
void cmdedit_strwidth(cmdedit_strwidth_proc); /* to bind cmdedit_strlen */
|
||||
|
||||
extern int (*cmdedit_in_hook)(char *);
|
||||
extern int (*cmdedit_out_hook)(char *);
|
||||
extern int (*cmdedit_tab_hook)(char *, int, int *);
|
||||
|
||||
#endif /* BB_FEATURE_SH_COMMAND_EDITING */
|
||||
#endif /* BB_FEATURE_COMMAND_EDITING */
|
||||
|
||||
#endif /* CMDEDIT_H */
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,10 +22,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
@@ -35,7 +36,7 @@ int cmp_main(int argc, char **argv)
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
usage(cmp_usage);
|
||||
show_usage();
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
|
||||
+11
-12
@@ -4,33 +4,32 @@
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
#include "busybox.h"
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_ACTIVATE 0x5606 /* make vt active */
|
||||
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage (chvt_usage);
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,8 +22,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int clear_main(int argc, char **argv)
|
||||
|
||||
+12
-17
@@ -3,15 +3,15 @@
|
||||
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
|
||||
* Renamed deallocvt.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
|
||||
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
@@ -19,30 +19,25 @@ int deallocvt_main(int argc, char *argv[])
|
||||
|
||||
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
|
||||
if (argc > 2)
|
||||
usage(deallocvt_usage);
|
||||
show_usage();
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
if (argc == 1) {
|
||||
printf("erik: A\n");
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else
|
||||
printf("erik: B\n");
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
error_msg("0: illegal VT number\n");
|
||||
error_msg("0: illegal VT number");
|
||||
else if (num == 1)
|
||||
error_msg("VT 1 cannot be deallocated\n");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
error_msg_and_die("could not deallocate console %d\n", num);
|
||||
}
|
||||
error_msg("VT 1 cannot be deallocated");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
printf("erik: C\n");
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -20,11 +20,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
@@ -32,11 +35,11 @@ struct kbentry {
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
|
||||
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
{
|
||||
@@ -45,12 +48,12 @@ int dumpkmap_main(int argc, char **argv)
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
usage(dumpkmap_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
error_msg("Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
perror_msg("Error opening /dev/tty0");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -78,7 +81,7 @@ int dumpkmap_main(int argc, char **argv)
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
|
||||
error_msg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
}
|
||||
else {
|
||||
write(1,(void*)&ke.kb_value,2);
|
||||
|
||||
+28
-39
@@ -7,7 +7,6 @@
|
||||
* Peter Novodvorsky <petya@logic.ru>
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
@@ -17,9 +16,10 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/kd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef unsigned short unicode;
|
||||
|
||||
@@ -34,18 +34,16 @@ int loadacm_main(int argc, char **argv)
|
||||
int fd;
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
usage(loadacm_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd < 0) {
|
||||
error_msg("Error opening /dev/tty1: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
perror_msg_and_die("Error opening /dev/tty1");
|
||||
}
|
||||
|
||||
if (screen_map_load(fd, stdin)) {
|
||||
error_msg("Error loading acm: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
perror_msg_and_die("Error loading acm");
|
||||
}
|
||||
|
||||
write(fd, "\033(K", 3);
|
||||
@@ -62,7 +60,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
int is_unicode;
|
||||
|
||||
if (fstat(fileno(fp), &stbuf))
|
||||
perror("Cannot stat map file"), exit(1);
|
||||
perror_msg_and_die("Cannot stat map file");
|
||||
|
||||
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
|
||||
if (!
|
||||
@@ -72,18 +70,16 @@ int screen_map_load(int fd, FILE * fp)
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg("16bit screen-map MUST be a regular file.\n"),
|
||||
exit(1);
|
||||
error_msg_and_die("16bit screen-map MUST be a regular file.");
|
||||
else
|
||||
perror("fseek failed reading binary 16bit screen-map"),
|
||||
exit(1);
|
||||
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
|
||||
perror("Cannot read [new] map from file"), exit(1);
|
||||
perror_msg_and_die("Cannot read [new] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.\n");
|
||||
error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -91,7 +87,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
/* same if it was binary, ie. if parse_failed */
|
||||
if (parse_failed || is_unicode) {
|
||||
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
|
||||
perror("PIO_UNISCRNMAP ioctl"), exit(1);
|
||||
perror_msg_and_die("PIO_UNISCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -100,10 +96,10 @@ int screen_map_load(int fd, FILE * fp)
|
||||
/* rewind... */
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file."),
|
||||
exit(1);
|
||||
else
|
||||
perror("fseek failed assuming 8bit screen-map"), exit(1);
|
||||
perror_msg_and_die("fseek failed assuming 8bit screen-map");
|
||||
}
|
||||
|
||||
/* ... and try an old 8-bit screen-map */
|
||||
@@ -113,26 +109,25 @@ int screen_map_load(int fd, FILE * fp)
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
/* should not - it succedeed above */
|
||||
error_msg("fseek() returned ESPIPE !\n"),
|
||||
exit(1);
|
||||
error_msg_and_die("fseek() returned ESPIPE !");
|
||||
else
|
||||
perror("fseek for binary 8bit screen-map"), exit(1);
|
||||
perror_msg_and_die("fseek for binary 8bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror("Cannot read [old] map from file"), exit(1);
|
||||
perror_msg_and_die("Cannot read [old] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.\n");
|
||||
error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ioctl(fd, PIO_SCRNMAP, buf))
|
||||
perror("PIO_SCRNMAP ioctl"), exit(1);
|
||||
perror_msg_and_die("PIO_SCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
error_msg("Error parsing symbolic map\n");
|
||||
error_msg("Error parsing symbolic map");
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -176,10 +171,8 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
|
||||
if (feof(fp))
|
||||
break;
|
||||
else {
|
||||
perror("uni_screen_map_read_ascii() can't read line");
|
||||
exit(2);
|
||||
}
|
||||
else
|
||||
perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
|
||||
}
|
||||
|
||||
/* get "charset-relative charcode", stripping leading spaces */
|
||||
@@ -319,12 +312,11 @@ void saveoldmap(int fd, char *omfil)
|
||||
int is_old_map = 0;
|
||||
|
||||
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
|
||||
perror("GIO_UNISCRNMAP ioctl error");
|
||||
perror_msg("GIO_UNISCRNMAP ioctl error");
|
||||
#endif
|
||||
if (ioctl(fd, GIO_SCRNMAP, buf)) {
|
||||
perror("GIO_SCRNMAP ioctl error");
|
||||
exit(1);
|
||||
} else
|
||||
if (ioctl(fd, GIO_SCRNMAP, buf))
|
||||
perror_msg_and_die("GIO_SCRNMAP ioctl error");
|
||||
else
|
||||
is_old_map = 1;
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
}
|
||||
@@ -334,14 +326,11 @@ void saveoldmap(int fd, char *omfil)
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
if (is_old_map) {
|
||||
#endif
|
||||
if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
|
||||
perror("Error writing map to file");
|
||||
exit(1);
|
||||
}
|
||||
if (fwrite(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Error writing map to file");
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
|
||||
perror("Error writing map to file");
|
||||
exit(1);
|
||||
perror_msg_and_die("Error writing map to file");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+15
-15
@@ -7,7 +7,6 @@
|
||||
* Loads the console font, and possibly the corresponding screen map(s).
|
||||
* (Adapted for busybox by Matej Vela.)
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@@ -20,14 +19,15 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include <endian.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define PSF_MAGIC1 0x36
|
||||
#define PSF_MAGIC2 0x04
|
||||
static const int PSF_MAGIC1 = 0x36;
|
||||
static const int PSF_MAGIC2 = 0x04;
|
||||
|
||||
#define PSF_MODE512 0x01
|
||||
#define PSF_MODEHASTAB 0x02
|
||||
#define PSF_MAXMODE 0x03
|
||||
#define PSF_SEPARATOR 0xFFFF
|
||||
static const int PSF_MODE512 = 0x01;
|
||||
static const int PSF_MODEHASTAB = 0x02;
|
||||
static const int PSF_MAXMODE = 0x03;
|
||||
static const int PSF_SEPARATOR = 0xFFFF;
|
||||
|
||||
struct psf_header {
|
||||
unsigned char magic1, magic2; /* Magic number */
|
||||
@@ -44,7 +44,7 @@ extern int loadfont_main(int argc, char **argv)
|
||||
int fd;
|
||||
|
||||
if (argc != 1)
|
||||
usage(loadfont_usage);
|
||||
show_usage();
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0)
|
||||
@@ -62,7 +62,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32)
|
||||
error_msg_and_die("Bad character size %d\n", unit);
|
||||
error_msg_and_die("Bad character size %d", unit);
|
||||
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
@@ -119,8 +119,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
#ifdef ENOIOCTLCMD
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
error_msg("It seems this kernel is older than 1.1.92\n");
|
||||
error_msg_and_die("No Unicode mapping table loaded.\n");
|
||||
error_msg("It seems this kernel is older than 1.1.92");
|
||||
error_msg_and_die("No Unicode mapping table loaded.");
|
||||
} else
|
||||
#endif
|
||||
perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
@@ -174,11 +174,11 @@ static void loadnewfont(int fd)
|
||||
goto no_psf;
|
||||
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
error_msg_and_die("Unsupported psf file mode\n");
|
||||
error_msg_and_die("Unsupported psf file mode");
|
||||
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
|
||||
#if !defined( PIO_FONTX ) || defined( __sparc__ )
|
||||
if (fontsize != 256)
|
||||
error_msg_and_die("Only fontsize 256 supported\n");
|
||||
error_msg_and_die("Only fontsize 256 supported");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
@@ -186,7 +186,7 @@ static void loadnewfont(int fd)
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
error_msg_and_die("Input file: bad length\n");
|
||||
error_msg_and_die("Input file: bad length");
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
@@ -201,7 +201,7 @@ static void loadnewfont(int fd)
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377)
|
||||
error_msg_and_die("Bad input file size\n");
|
||||
error_msg_and_die("Bad input file size");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
|
||||
@@ -34,11 +37,11 @@ struct kbentry {
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
#define KDSKBENT 0x4B47 /* sets one entry in translation table */
|
||||
static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int loadkmap_main(int argc, char **argv)
|
||||
{
|
||||
@@ -48,7 +51,7 @@ int loadkmap_main(int argc, char **argv)
|
||||
char flags[MAX_NR_KEYMAPS], buff[7];
|
||||
|
||||
if (argc != 1)
|
||||
usage(loadkmap_usage);
|
||||
show_usage();
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0)
|
||||
@@ -56,7 +59,7 @@ int loadkmap_main(int argc, char **argv)
|
||||
|
||||
read(0, buff, 7);
|
||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
error_msg_and_die("This is not a valid binary keymap.\n");
|
||||
error_msg_and_die("This is not a valid binary keymap.");
|
||||
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
|
||||
perror_msg_and_die("Error reading keymap flags");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* and Kent Robotti <robotti@metconnect.com>
|
||||
*
|
||||
@@ -23,8 +23,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int reset_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -22,18 +22,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbkeycode {
|
||||
unsigned int scancode, keycode;
|
||||
};
|
||||
#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
|
||||
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
|
||||
|
||||
extern int
|
||||
setkeycodes_main(int argc, char** argv)
|
||||
@@ -43,7 +43,7 @@ setkeycodes_main(int argc, char** argv)
|
||||
struct kbkeycode a;
|
||||
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
usage(setkeycodes_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
@@ -52,18 +52,18 @@ setkeycodes_main(int argc, char** argv)
|
||||
a.keycode = atoi(argv[2]);
|
||||
a.scancode = sc = strtol(argv[1], &ep, 16);
|
||||
if (*ep) {
|
||||
error_msg_and_die("error reading SCANCODE: '%s'\n", argv[1]);
|
||||
error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
|
||||
}
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
}
|
||||
if (a.scancode > 255 || a.keycode > 127) {
|
||||
error_msg_and_die("SCANCODE or KEYCODE outside bounds\n");
|
||||
error_msg_and_die("SCANCODE or KEYCODE outside bounds");
|
||||
}
|
||||
if (ioctl(fd,KDSETKEYCODE,&a)) {
|
||||
perror("KDSETKEYCODE");
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,8 +21,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
@@ -30,7 +33,7 @@ extern int basename_main(int argc, char **argv)
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(basename_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
|
||||
+3
-2
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,8 +21,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
+6
-5
@@ -3,7 +3,7 @@
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,23 +22,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(chroot_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
@@ -57,7 +58,7 @@ int chroot_main(int argc, char **argv)
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -3,7 +3,7 @@
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,10 +22,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
@@ -35,7 +36,7 @@ int cmp_main(int argc, char **argv)
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
usage(cmp_usage);
|
||||
show_usage();
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
|
||||
+12
-11
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@enol.com>
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -54,12 +54,12 @@ static void decompose_list(const char *list)
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ static void decompose_list(const char *list)
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
error_msg_and_die("missing list of fields\n");
|
||||
error_msg_and_die("missing list of fields");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ extern int cut_main(int argc, char **argv)
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character\n");
|
||||
error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
@@ -209,16 +209,17 @@ extern int cut_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense
|
||||
only when operating on fields\n");
|
||||
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\n");
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields");
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
@@ -233,7 +234,7 @@ extern int cut_main(int argc, char **argv)
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
error_msg("%s: %s\n", argv[i], strerror(errno));
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
|
||||
+12
-11
@@ -20,18 +20,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_date
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_date
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
|
||||
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
@@ -45,7 +46,7 @@
|
||||
|
||||
/* Default input handling to save suprising some people */
|
||||
|
||||
struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
int nr;
|
||||
|
||||
@@ -72,7 +73,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
|
||||
/* The new stuff for LRP */
|
||||
|
||||
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
struct tm t;
|
||||
|
||||
@@ -150,7 +151,7 @@ int date_main(int argc, char **argv)
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
@@ -161,10 +162,10 @@ int date_main(int argc, char **argv)
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +178,7 @@ int date_main(int argc, char **argv)
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+115
-138
@@ -2,15 +2,8 @@
|
||||
/*
|
||||
* Mini dd implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999, 2000 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Based in part on code taken from sash.
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Permission to distribute this code under the GPL has been granted.
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,154 +21,138 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
#include <features.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
typedef unsigned long long int uintmax_t;
|
||||
#endif
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dd_main(int argc, char **argv)
|
||||
|
||||
static const struct suffix_mult dd_suffixes[] = {
|
||||
{ "c", 1 },
|
||||
{ "w", 2 },
|
||||
{ "b", 512 },
|
||||
{ "kD", 1000 },
|
||||
{ "k", 1024 },
|
||||
{ "MD", 1000000 },
|
||||
{ "M", 1048576 },
|
||||
{ "GD", 1000000000 },
|
||||
{ "G", 1073741824 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
char *inFile = NULL;
|
||||
char *outFile = NULL;
|
||||
int inFd;
|
||||
int outFd;
|
||||
int inCc = 0;
|
||||
int outCc;
|
||||
int trunc=TRUE;
|
||||
int sync=FALSE;
|
||||
long blockSize = 512,ibs;
|
||||
uintmax_t skipBlocks = 0;
|
||||
uintmax_t seekBlocks = 0;
|
||||
uintmax_t count = (uintmax_t) - 1;
|
||||
uintmax_t inTotal = 0;
|
||||
uintmax_t outTotal = 0;
|
||||
uintmax_t totalSize;
|
||||
int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
|
||||
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
|
||||
size_t bs = 512, count = -1;
|
||||
ssize_t n;
|
||||
off_t seek = 0, skip = 0;
|
||||
FILE *statusfp;
|
||||
char *infile = NULL, *outfile = NULL, *buf;
|
||||
|
||||
unsigned char buf[BUFSIZ];
|
||||
char *keyword = NULL;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strncmp("bs=", argv[i], 3) == 0)
|
||||
bs = parse_number(argv[i]+3, dd_suffixes);
|
||||
else if (strncmp("count=", argv[i], 6) == 0)
|
||||
count = parse_number(argv[i]+6, dd_suffixes);
|
||||
else if (strncmp("seek=", argv[i], 5) == 0)
|
||||
seek = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("skip=", argv[i], 5) == 0)
|
||||
skip = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("if=", argv[i], 3) == 0)
|
||||
infile = argv[i]+3;
|
||||
else if (strncmp("of=", argv[i], 3) == 0)
|
||||
outfile = argv[i]+3;
|
||||
else if (strncmp("conv=", argv[i], 5) == 0) {
|
||||
buf = argv[i]+5;
|
||||
while (1) {
|
||||
if (strncmp("notrunc", buf, 7) == 0) {
|
||||
trunc = FALSE;
|
||||
buf += 7;
|
||||
} else if (strncmp("sync", buf, 4) == 0) {
|
||||
sync = TRUE;
|
||||
buf += 4;
|
||||
} else {
|
||||
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
|
||||
}
|
||||
if (buf[0] == '\0')
|
||||
break;
|
||||
if (buf[0] == ',')
|
||||
buf++;
|
||||
}
|
||||
} else
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
buf = xmalloc(bs);
|
||||
|
||||
/* Parse any options */
|
||||
while (argc) {
|
||||
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
|
||||
inFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
|
||||
outFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (strncmp("count", *argv, 5) == 0) {
|
||||
count = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (count < 0) {
|
||||
error_msg("Bad count value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "bs", 2) == 0) {
|
||||
blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (blockSize <= 0) {
|
||||
error_msg("Bad block size value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "skip", 4) == 0) {
|
||||
skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (skipBlocks <= 0) {
|
||||
error_msg("Bad skip value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
if (infile != NULL) {
|
||||
if ((ifd = open(infile, O_RDONLY)) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
} else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = "standard input";
|
||||
}
|
||||
|
||||
} else if (strncmp(*argv, "seek", 4) == 0) {
|
||||
seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (seekBlocks <= 0) {
|
||||
error_msg("Bad seek value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "conv", 4) == 0) {
|
||||
keyword = (strchr(*argv, '=') + 1);
|
||||
if (strcmp(keyword, "notrunc") == 0)
|
||||
trunc=FALSE;
|
||||
if (strcmp(keyword, "sync") == 0)
|
||||
sync=TRUE;
|
||||
} else {
|
||||
goto usage;
|
||||
if (outfile != NULL) {
|
||||
oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
if (!seek && trunc)
|
||||
oflag |= O_TRUNC;
|
||||
|
||||
if ((ofd = open(outfile, oflag, 0666)) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
|
||||
if (seek && trunc) {
|
||||
if (ftruncate(ofd, seek * bs) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
statusfp = stdout;
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
statusfp = stderr;
|
||||
}
|
||||
|
||||
if (inFile == NULL)
|
||||
inFd = fileno(stdin);
|
||||
else
|
||||
inFd = open(inFile, 0);
|
||||
|
||||
if (inFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* free(buf); */
|
||||
perror_msg_and_die("%s", inFile);
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
outFd = fileno(stdout);
|
||||
else
|
||||
outFd = open(outFile, O_WRONLY | O_CREAT, 0666);
|
||||
|
||||
if (outFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* close(inFd);
|
||||
free(buf); */
|
||||
perror_msg_and_die("%s", outFile);
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
|
||||
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
|
||||
totalSize=count*blockSize;
|
||||
|
||||
ibs=blockSize;
|
||||
if (ibs > BUFSIZ)
|
||||
ibs=BUFSIZ;
|
||||
|
||||
while (totalSize > outTotal) {
|
||||
inCc = full_read(inFd, buf, ibs);
|
||||
inTotal += inCc;
|
||||
if ( (sync==TRUE) && (inCc>0) )
|
||||
while (inCc<ibs)
|
||||
buf[inCc++]='\0';
|
||||
|
||||
if ((outCc = full_write(outFd, buf, inCc)) < 1){
|
||||
if (outCc < 0 ){
|
||||
perror("Error during write");
|
||||
}
|
||||
while (in_full + in_part != count) {
|
||||
n = safe_read(ifd, buf, bs);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (n == bs)
|
||||
in_full++;
|
||||
else
|
||||
in_part++;
|
||||
if (sync) {
|
||||
memset(buf + n, '\0', bs - n);
|
||||
n = bs;
|
||||
}
|
||||
outTotal += outCc;
|
||||
}
|
||||
if (trunc == TRUE) {
|
||||
ftruncate(outFd, lseek(outFd, 0, SEEK_CUR));
|
||||
n = full_write(ofd, buf, n);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (n == bs)
|
||||
out_full++;
|
||||
else
|
||||
out_part++;
|
||||
}
|
||||
/* Note that we are not freeing memory or closing
|
||||
* files here, to save a few bytes. */
|
||||
#ifdef BB_FEATURE_CLEAN_UP
|
||||
close(inFd);
|
||||
close(outFd);
|
||||
#endif
|
||||
|
||||
printf("%ld+%d records in\n", (long) (inTotal / blockSize),
|
||||
(inTotal % blockSize) != 0);
|
||||
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
|
||||
(outTotal % blockSize) != 0);
|
||||
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
|
||||
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
usage:
|
||||
|
||||
usage(dd_usage);
|
||||
}
|
||||
+93
-34
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini df implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
@@ -22,40 +22,76 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern const char mtab_file[]; /* Defined in utility.c */
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
static unsigned long df_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
static int df(char *device, const char *mountPoint)
|
||||
static int do_df(char *device, const char *mount_point)
|
||||
{
|
||||
struct statfs s;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
long base;
|
||||
#endif
|
||||
|
||||
if (statfs(mountPoint, &s) != 0) {
|
||||
perror_msg("%s", mountPoint);
|
||||
if (statfs(mount_point, &s) != 0) {
|
||||
perror_msg("%s", mount_point);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (s.f_blocks > 0) {
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
if(blocks_used == 0)
|
||||
blocks_percent_used = 0;
|
||||
else {
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
}
|
||||
if (strcmp(device, "/dev/root") == 0) {
|
||||
/* Adjusts device to be the real root device,
|
||||
* or leaves device alone if it can't find it */
|
||||
find_real_root_device_name( device);
|
||||
}
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
switch (df_disp_hr) {
|
||||
case MEGABYTE:
|
||||
base = KILOBYTE;
|
||||
break;
|
||||
case KILOBYTE:
|
||||
base = 1;
|
||||
break;
|
||||
default:
|
||||
base = 0;
|
||||
}
|
||||
printf("%-20s %9s ", device,
|
||||
make_human_readable_str((unsigned long)(s.f_blocks *
|
||||
(s.f_bsize/(double)KILOBYTE)), base));
|
||||
printf("%9s ",
|
||||
make_human_readable_str((unsigned long)(
|
||||
(s.f_blocks - s.f_bfree) *
|
||||
(s.f_bsize/(double)KILOBYTE)), base));
|
||||
printf("%9s %3ld%% %s\n",
|
||||
make_human_readable_str((unsigned long)(s.f_bavail *
|
||||
(s.f_bsize/(double)KILOBYTE)), base),
|
||||
blocks_percent_used, mount_point);
|
||||
#else
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
|
||||
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
|
||||
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
|
||||
blocks_percent_used, mountPoint);
|
||||
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
|
||||
(long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
|
||||
(long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
|
||||
blocks_percent_used, mount_point);
|
||||
#endif
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -64,40 +100,63 @@ static int df(char *device, const char *mountPoint)
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int opt = 0;
|
||||
int i = 0;
|
||||
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
|
||||
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
|
||||
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
if (argc > 1) {
|
||||
struct mntent *mountEntry;
|
||||
|
||||
if (**(argv + 1) == '-') {
|
||||
usage(df_usage);
|
||||
while ((opt = getopt(argc, argv, "k"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
)) > 0)
|
||||
{
|
||||
switch (opt) {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h':
|
||||
df_disp_hr = 0;
|
||||
strcpy(disp_units_hdr, " Size");
|
||||
break;
|
||||
case 'm':
|
||||
df_disp_hr = MEGABYTE;
|
||||
strcpy(disp_units_hdr, "1M-blocks");
|
||||
break;
|
||||
#endif
|
||||
case 'k':
|
||||
/* default display is kilobytes */
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
while (argc > 1) {
|
||||
if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.\n", argv[1]);
|
||||
}
|
||||
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem", disp_units_hdr,
|
||||
"Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
if(optind < argc) {
|
||||
struct mntent *mount_entry;
|
||||
for(i = optind; i < argc; i++)
|
||||
{
|
||||
if ((mount_entry = find_mount_point(argv[i], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.", argv[i]);
|
||||
status = EXIT_FAILURE;
|
||||
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
} else if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
} else {
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
FILE *mount_table;
|
||||
struct mntent *mount_entry;
|
||||
|
||||
mountTable = setmntent(mtab_file, "r");
|
||||
if (mountTable == 0) {
|
||||
mount_table = setmntent(mtab_file, "r");
|
||||
if (mount_table == 0) {
|
||||
perror_msg("%s", mtab_file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((mountEntry = getmntent(mountTable))) {
|
||||
if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
while ((mount_entry = getmntent(mount_table))) {
|
||||
if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
endmntent(mount_table);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
+8
-3
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini dirname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -20,15 +20,20 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "busybox.h"
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dirname_main(int argc, char **argv)
|
||||
{
|
||||
char* s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-'))
|
||||
usage(dirname_usage);
|
||||
show_usage();
|
||||
argv++;
|
||||
|
||||
s=*argv+strlen(*argv)-1;
|
||||
|
||||
+146
-39
@@ -1,45 +1,152 @@
|
||||
/*
|
||||
Mini dos2unix implementation for busybox
|
||||
|
||||
Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA
|
||||
All rights reserved.
|
||||
* dos2unix for BusyBox
|
||||
*
|
||||
* dos2unix '\n' convertor 0.5.0
|
||||
* based on Unix2Dos 0.9.0 by Peter Hanecak (made 19.2.1997)
|
||||
* Copyright 1997,.. by Peter Hanecak <hanecak@megaloman.sk>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* dos2unix filters reading input from stdin and writing output to stdout.
|
||||
* Without arguments it reverts the format (e.i. if source is in UNIX format,
|
||||
* output is in DOS format and vice versa).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* See the COPYING file for license information.
|
||||
*/
|
||||
|
||||
Redistribution and use of this source code, with or without modification, is
|
||||
permitted provided that the following condition is met:
|
||||
|
||||
1. Redistributions of this source code must retain the above copyright
|
||||
notice, this condition, and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int dos2unix_main( int argc, char **argv ) {
|
||||
int c;
|
||||
if (argc > 1) {
|
||||
c = *argv[1];
|
||||
if (c == '-') {
|
||||
usage(dos2unix_usage);
|
||||
}
|
||||
#define CT_AUTO 0
|
||||
#define CT_UNIX2DOS 1
|
||||
#define CT_DOS2UNIX 2
|
||||
|
||||
int convert(char *fn, int ConvType);
|
||||
|
||||
int dos2unix_main(int argc, char *argv[]) {
|
||||
int ConvType = CT_AUTO;
|
||||
int o;
|
||||
|
||||
// process parameters
|
||||
while ((o = getopt(argc, argv, "du")) != EOF) {
|
||||
switch (o) {
|
||||
case 'd':
|
||||
ConvType = CT_UNIX2DOS;
|
||||
break;
|
||||
case 'u':
|
||||
ConvType = CT_DOS2UNIX;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
c = getchar();
|
||||
while (c != EOF) {
|
||||
/* Eat any \r's... they shouldn't be here */
|
||||
while (c == '\r') c = getchar();
|
||||
if (c == EOF) break;
|
||||
putchar(c);
|
||||
c = getchar();
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
if (optind < argc) {
|
||||
while(optind < argc)
|
||||
if ((o = convert(argv[optind++], ConvType)) < 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
o = convert(NULL, ConvType);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
// if fn is NULL then input is stdin and output is stdout
|
||||
int convert(char *fn, int ConvType) {
|
||||
char c;
|
||||
char *tempFn = NULL;
|
||||
FILE *in = stdin, *out = stdout;
|
||||
|
||||
if (fn != NULL) {
|
||||
if ((in = fopen(fn, "r")) == NULL) {
|
||||
perror_msg(fn);
|
||||
return -1;
|
||||
}
|
||||
tempFn = tmpnam(NULL);
|
||||
if (tempFn == NULL || (out = fopen(tempFn, "w")) == NULL) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
while ((c = fgetc(in)) != EOF) {
|
||||
if (c == '\r') {
|
||||
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
|
||||
// file is alredy in DOS format so it is not necessery to touch it
|
||||
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (!ConvType)
|
||||
ConvType = CT_DOS2UNIX;
|
||||
break;
|
||||
}
|
||||
if (c == '\n') {
|
||||
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
|
||||
// file is alredy in UNIX format so it is not necessery to touch it
|
||||
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (!ConvType)
|
||||
ConvType = CT_UNIX2DOS;
|
||||
if (ConvType == CT_UNIX2DOS)
|
||||
fputc('\r', out);
|
||||
fputc('\n', out);
|
||||
break;
|
||||
}
|
||||
fputc(c, out);
|
||||
}
|
||||
if (c != EOF)
|
||||
while ((c = fgetc(in)) != EOF) {
|
||||
if (c == '\r')
|
||||
continue;
|
||||
if (c == '\n') {
|
||||
if (ConvType == CT_UNIX2DOS)
|
||||
fputc('\r', out);
|
||||
fputc('\n', out);
|
||||
continue;
|
||||
}
|
||||
fputc(c, out);
|
||||
}
|
||||
|
||||
if (fn != NULL) {
|
||||
if (fclose(in) < 0 || fclose(out) < 0 ||
|
||||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
|
||||
while ((c = fgetc(in)) != EOF)
|
||||
fputc(c, out);
|
||||
|
||||
if (fclose(in) < 0 || fclose(out) < 0 || remove(tempFn) < 0) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
+43
-11
@@ -3,7 +3,7 @@
|
||||
* Mini du implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,16 +22,23 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#include "messages.c"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
static unsigned long disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
typedef void (Display) (long, char *);
|
||||
|
||||
@@ -42,12 +49,28 @@ static Display *print;
|
||||
|
||||
static void print_normal(long size, char *filename)
|
||||
{
|
||||
fprintf(stdout, "%ld\t%s\n", size, filename);
|
||||
unsigned long base;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
switch (disp_hr) {
|
||||
case MEGABYTE:
|
||||
base = KILOBYTE;
|
||||
break;
|
||||
case KILOBYTE:
|
||||
base = 1;
|
||||
break;
|
||||
default:
|
||||
base = 0;
|
||||
}
|
||||
printf("%s\t%s\n", make_human_readable_str(size, base), filename);
|
||||
#else
|
||||
printf("%ld\t%s\n", size, filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void print_summary(long size, char *filename)
|
||||
{
|
||||
if (du_depth == 1) {
|
||||
printf("summary\n");
|
||||
print_normal(size, filename);
|
||||
}
|
||||
}
|
||||
@@ -132,7 +155,11 @@ int du_main(int argc, char **argv)
|
||||
print = print_normal;
|
||||
|
||||
/* parse argv[] */
|
||||
while ((c = getopt(argc, argv, "sl")) != EOF) {
|
||||
while ((c = getopt(argc, argv, "sl"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
"k")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
print = print_summary;
|
||||
@@ -140,8 +167,13 @@ int du_main(int argc, char **argv)
|
||||
case 'l':
|
||||
count_hardlinks = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h': disp_hr = 0; break;
|
||||
case 'm': disp_hr = MEGABYTE; break;
|
||||
#endif
|
||||
case 'k': break;
|
||||
default:
|
||||
usage(du_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +187,7 @@ int du_main(int argc, char **argv)
|
||||
for (i=optind; i < argc; i++) {
|
||||
if ((sum = du(argv[i])) == 0)
|
||||
status = EXIT_FAILURE;
|
||||
if (is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
print_normal(sum, argv[i]);
|
||||
}
|
||||
reset_ino_dev_hashtable();
|
||||
@@ -165,7 +197,7 @@ int du_main(int argc, char **argv)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* $Id: du.c,v 1.32 2000/12/12 23:17:26 andersen Exp $ */
|
||||
/* $Id: du.c,v 1.43 2001/03/09 14:36:42 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
|
||||
+3
-1
@@ -22,8 +22,10 @@
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
echo_main(int argc, char** argv)
|
||||
|
||||
+17
-13
@@ -33,11 +33,15 @@
|
||||
* One function can handle multiple operators all of equal precedence,
|
||||
* provided they all associate ((x op x) op x). */
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
/* no getopt needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <regex.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
enum valtype {
|
||||
@@ -74,14 +78,14 @@ int expr_main (int argc, char **argv)
|
||||
VALUE *v;
|
||||
|
||||
if (argc == 1) {
|
||||
error_msg_and_die("too few arguments\n");
|
||||
error_msg_and_die("too few arguments");
|
||||
}
|
||||
|
||||
args = argv + 1;
|
||||
|
||||
v = eval ();
|
||||
if (*args)
|
||||
error_msg_and_die ("syntax error\n");
|
||||
error_msg_and_die ("syntax error");
|
||||
|
||||
if (v->type == integer)
|
||||
printf ("%d\n", v->u.i);
|
||||
@@ -216,7 +220,7 @@ static \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ("non-numeric argument\n"); \
|
||||
error_msg_and_die ("non-numeric argument"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
@@ -224,9 +228,9 @@ int name (l, r) VALUE *l; VALUE *r; \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ( "non-numeric argument\n"); \
|
||||
error_msg_and_die ( "non-numeric argument"); \
|
||||
if (r->u.i == 0) \
|
||||
error_msg_and_die ( "division by zero\n"); \
|
||||
error_msg_and_die ( "division by zero"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
@@ -270,7 +274,7 @@ of a basic regular expression is not portable; it is being ignored",
|
||||
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
|
||||
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
|
||||
if (errmsg) {
|
||||
error_msg_and_die("%s\n", errmsg);
|
||||
error_msg_and_die("%s", errmsg);
|
||||
}
|
||||
|
||||
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
|
||||
@@ -301,19 +305,19 @@ static VALUE *eval7 (void)
|
||||
VALUE *v;
|
||||
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error");
|
||||
|
||||
if (nextarg ("(")) {
|
||||
args++;
|
||||
v = eval ();
|
||||
if (!nextarg (")"))
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error");
|
||||
args++;
|
||||
return v;
|
||||
}
|
||||
|
||||
if (nextarg (")"))
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error");
|
||||
|
||||
return str_value (*args++);
|
||||
}
|
||||
@@ -327,7 +331,7 @@ static VALUE *eval6 (void)
|
||||
if (nextarg ("quote")) {
|
||||
args++;
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error");
|
||||
return str_value (*args++);
|
||||
}
|
||||
else if (nextarg ("length")) {
|
||||
|
||||
+10
-7
@@ -3,7 +3,7 @@
|
||||
* Mini head implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,11 +22,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int head(int len, FILE *fp)
|
||||
static int head(int len, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
char *input;
|
||||
@@ -55,7 +58,7 @@ int head_main(int argc, char **argv)
|
||||
break;
|
||||
/* fallthrough */
|
||||
default:
|
||||
usage(head_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,16 +79,16 @@ int head_main(int argc, char **argv)
|
||||
}
|
||||
if (fp) {
|
||||
if (need_headers) {
|
||||
fprintf(stdout, "==> %s <==\n", argv[optind]);
|
||||
printf("==> %s <==\n", argv[optind]);
|
||||
}
|
||||
head(len, fp);
|
||||
if (errno) {
|
||||
error_msg("%s: %s\n", argv[optind], strerror(errno));
|
||||
perror_msg("%s", argv[optind]);
|
||||
status = EXIT_FAILURE;
|
||||
errno = 0;
|
||||
}
|
||||
if (optind < argc - 1)
|
||||
fprintf(stdout, "\n");
|
||||
putchar('\n');
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
+3
-1
@@ -20,8 +20,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int hostid_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
+21
-13
@@ -23,14 +23,14 @@
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
extern int id_main(int argc, char **argv)
|
||||
{
|
||||
int no_user = 0, no_group = 0, print_real = 0;
|
||||
int name_not_number = 0;
|
||||
char user[9], group[9];
|
||||
long gid;
|
||||
long pwnam, grnam;
|
||||
@@ -38,7 +38,7 @@ extern int id_main(int argc, char **argv)
|
||||
|
||||
gid = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ugr")) > 0) {
|
||||
while ((opt = getopt(argc, argv, "ugrn")) > 0) {
|
||||
switch (opt) {
|
||||
case 'u':
|
||||
no_group++;
|
||||
@@ -49,12 +49,15 @@ extern int id_main(int argc, char **argv)
|
||||
case 'r':
|
||||
print_real++;
|
||||
break;
|
||||
case 'n':
|
||||
name_not_number++;
|
||||
break;
|
||||
default:
|
||||
usage(id_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (no_user && no_group) usage(id_usage);
|
||||
if (no_user && no_group) show_usage();
|
||||
|
||||
if (argv[optind] == NULL) {
|
||||
if (print_real) {
|
||||
@@ -73,15 +76,20 @@ extern int id_main(int argc, char **argv)
|
||||
|
||||
pwnam=my_getpwnam(user);
|
||||
grnam=my_getgrnam(group);
|
||||
if (gid == -1 || pwnam==-1 || grnam==-1) {
|
||||
error_msg_and_die("%s: No such user\n", user);
|
||||
}
|
||||
if (no_group)
|
||||
printf("%ld\n", pwnam);
|
||||
else if (no_user)
|
||||
printf("%ld\n", grnam);
|
||||
else
|
||||
|
||||
if (no_group) {
|
||||
if(name_not_number && user)
|
||||
printf("%s\n",user);
|
||||
else
|
||||
printf("%ld\n", pwnam);
|
||||
} else if (no_user) {
|
||||
if(name_not_number && group)
|
||||
printf("%s\n", group);
|
||||
else
|
||||
printf("%ld\n", grnam);
|
||||
} else {
|
||||
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int length_main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2 || **(argv + 1) == '-')
|
||||
usage(length_usage);
|
||||
show_usage();
|
||||
printf("%lu\n", (long)strlen(argv[1]));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+42
-26
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini ln implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,59 +21,67 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_not_a_directory
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define LN_SYMLINK 1
|
||||
#define LN_FORCE 2
|
||||
#define LN_NODEREFERENCE 4
|
||||
static const int LN_SYMLINK = 1;
|
||||
static const int LN_FORCE = 2;
|
||||
static const int LN_NODEREFERENCE = 4;
|
||||
|
||||
/*
|
||||
* linkDestName is where the link points to,
|
||||
* linkSrcName is the name of the link to be created.
|
||||
*/
|
||||
static int fs_link(const char *link_DestName, const char *link_SrcName, const int flag)
|
||||
static int fs_link(const char *link_destname, const char *link_srcname,
|
||||
const int flag)
|
||||
{
|
||||
int status;
|
||||
int srcIsDir;
|
||||
char *srcName;
|
||||
int src_is_dir;
|
||||
char *src_name;
|
||||
|
||||
if (link_DestName==NULL)
|
||||
if (link_destname==NULL)
|
||||
return(FALSE);
|
||||
|
||||
srcName = (char *) malloc(strlen(link_SrcName)+strlen(link_DestName)+1);
|
||||
src_name = (char *) xmalloc(strlen(link_srcname)+strlen(link_destname)+1);
|
||||
|
||||
if (link_SrcName==NULL)
|
||||
strcpy(srcName, link_DestName);
|
||||
if (link_srcname==NULL)
|
||||
strcpy(src_name, link_destname);
|
||||
else
|
||||
strcpy(srcName, link_SrcName);
|
||||
strcpy(src_name, link_srcname);
|
||||
|
||||
if (flag&LN_NODEREFERENCE)
|
||||
srcIsDir = is_directory(srcName, TRUE, NULL);
|
||||
src_is_dir = is_directory(src_name, TRUE, NULL);
|
||||
else
|
||||
srcIsDir = is_directory(srcName, FALSE, NULL);
|
||||
src_is_dir = is_directory(src_name, FALSE, NULL);
|
||||
|
||||
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
|
||||
strcat(srcName, "/");
|
||||
strcat(srcName, link_DestName);
|
||||
if ((src_is_dir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
|
||||
char* srcdir_name;
|
||||
|
||||
srcdir_name = xstrdup(link_destname);
|
||||
strcat(src_name, "/");
|
||||
strcat(src_name, get_last_path_component(srcdir_name));
|
||||
free(srcdir_name);
|
||||
}
|
||||
|
||||
if (flag&LN_FORCE)
|
||||
unlink(srcName);
|
||||
unlink(src_name);
|
||||
|
||||
if (flag&LN_SYMLINK)
|
||||
status = symlink(link_DestName, srcName);
|
||||
status = symlink(link_destname, src_name);
|
||||
else
|
||||
status = link(link_DestName, srcName);
|
||||
status = link(link_destname, src_name);
|
||||
|
||||
if (status != 0) {
|
||||
perror(srcName);
|
||||
perror_msg(src_name);
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
@@ -98,15 +106,23 @@ extern int ln_main(int argc, char **argv)
|
||||
flag |= LN_NODEREFERENCE;
|
||||
break;
|
||||
default:
|
||||
usage(ln_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
if (optind > (argc-1)) {
|
||||
show_usage();
|
||||
}
|
||||
if (optind == (argc-1)) {
|
||||
if (fs_link(argv[optind],
|
||||
get_last_path_component(argv[optind]), flag)==FALSE)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
while(optind<(argc-1)) {
|
||||
if (fs_link(argv[optind], argv[argc-1], flag)==FALSE)
|
||||
status = EXIT_FAILURE;
|
||||
optind++;
|
||||
}
|
||||
return(status);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+5
-3
@@ -20,20 +20,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int logname_main(int argc, char **argv)
|
||||
{
|
||||
char user[9];
|
||||
|
||||
if (argc > 1)
|
||||
usage(logname_usage);
|
||||
show_usage();
|
||||
|
||||
my_getpwuid(user, geteuid());
|
||||
if (*user) {
|
||||
puts(user);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
error_msg_and_die("no login name\n");
|
||||
error_msg_and_die("no login name");
|
||||
}
|
||||
+143
-90
@@ -41,13 +41,15 @@
|
||||
* 1. requires lstat (BSD) - how do you do it without?
|
||||
*/
|
||||
|
||||
#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
|
||||
#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
|
||||
#define COLUMN_GAP 2 /* includes the file type char, if present */
|
||||
enum {
|
||||
TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */
|
||||
COLUMN_WIDTH = 14, /* default if AUTOWIDTH not defined */
|
||||
COLUMN_GAP = 2, /* includes the file type char */
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
@@ -55,21 +57,29 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#include <time.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#ifndef NAJOR
|
||||
#ifndef MAJOR
|
||||
#define MAJOR(dev) (((dev)>>8)&0xff)
|
||||
#define MINOR(dev) ((dev)&0xff)
|
||||
#endif
|
||||
|
||||
/* what is the overall style of the listing */
|
||||
#define STYLE_AUTO 0
|
||||
#define STYLE_LONG 1 /* one record per line, extended info */
|
||||
#define STYLE_SINGLE 2 /* one record per line */
|
||||
#define STYLE_COLUMNS 3 /* fill columns */
|
||||
enum {
|
||||
STYLE_AUTO = 0,
|
||||
STYLE_LONG = 1, /* one record per line, extended info */
|
||||
STYLE_SINGLE = 2, /* one record per line */
|
||||
STYLE_COLUMNS = 3 /* fill columns */
|
||||
};
|
||||
|
||||
/* 51306 lrwxrwxrwx 1 root root 2 May 11 01:43 /bin/view -> vi* */
|
||||
/* what file information will be listed */
|
||||
@@ -99,23 +109,23 @@
|
||||
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
/* how will the files be sorted */
|
||||
#define SORT_FORWARD 0 /* sort in reverse order */
|
||||
#define SORT_REVERSE 1 /* sort in reverse order */
|
||||
#define SORT_NAME 2 /* sort by file name */
|
||||
#define SORT_SIZE 3 /* sort by file size */
|
||||
#define SORT_ATIME 4 /* sort by last access time */
|
||||
#define SORT_CTIME 5 /* sort by last change time */
|
||||
#define SORT_MTIME 6 /* sort by last modification time */
|
||||
#define SORT_VERSION 7 /* sort by version */
|
||||
#define SORT_EXT 8 /* sort by file name extension */
|
||||
#define SORT_DIR 9 /* sort by file or directory */
|
||||
static const int SORT_FORWARD = 0; /* sort in reverse order */
|
||||
static const int SORT_REVERSE = 1; /* sort in reverse order */
|
||||
static const int SORT_NAME = 2; /* sort by file name */
|
||||
static const int SORT_SIZE = 3; /* sort by file size */
|
||||
static const int SORT_ATIME = 4; /* sort by last access time */
|
||||
static const int SORT_CTIME = 5; /* sort by last change time */
|
||||
static const int SORT_MTIME = 6; /* sort by last modification time */
|
||||
static const int SORT_VERSION = 7; /* sort by version */
|
||||
static const int SORT_EXT = 8; /* sort by file name extension */
|
||||
static const int SORT_DIR = 9; /* sort by file or directory */
|
||||
#endif
|
||||
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
/* which of the three times will be used */
|
||||
#define TIME_MOD 0
|
||||
#define TIME_CHANGE 1
|
||||
#define TIME_ACCESS 2
|
||||
static const int TIME_MOD = 0;
|
||||
static const int TIME_CHANGE = 1;
|
||||
static const int TIME_ACCESS = 2;
|
||||
#endif
|
||||
|
||||
#define LIST_SHORT (LIST_FILENAME)
|
||||
@@ -125,9 +135,9 @@
|
||||
LIST_SYMLINK)
|
||||
#define LIST_ILONG (LIST_INO | LIST_LONG)
|
||||
|
||||
#define SPLIT_DIR 0
|
||||
#define SPLIT_FILE 1
|
||||
#define SPLIT_SUBDIR 2
|
||||
static const int SPLIT_DIR = 0;
|
||||
static const int SPLIT_FILE = 1;
|
||||
static const int SPLIT_SUBDIR = 2;
|
||||
|
||||
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
|
||||
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
|
||||
@@ -146,19 +156,19 @@ struct dnode { /* the basic node */
|
||||
};
|
||||
typedef struct dnode dnode_t;
|
||||
|
||||
struct dnode **list_dir(char *);
|
||||
struct dnode **dnalloc(int);
|
||||
int list_single(struct dnode *);
|
||||
static struct dnode **list_dir(char *);
|
||||
static struct dnode **dnalloc(int);
|
||||
static int list_single(struct dnode *);
|
||||
|
||||
static unsigned int disp_opts= DISP_NORMAL;
|
||||
static unsigned int style_fmt= STYLE_AUTO ;
|
||||
static unsigned int list_fmt= LIST_SHORT ;
|
||||
static unsigned int disp_opts;
|
||||
static unsigned int style_fmt;
|
||||
static unsigned int list_fmt;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
static unsigned int sort_opts= SORT_FORWARD;
|
||||
static unsigned int sort_order= SORT_FORWARD;
|
||||
static unsigned int sort_opts;
|
||||
static unsigned int sort_order;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
static unsigned int time_fmt= TIME_MOD;
|
||||
static unsigned int time_fmt;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
static unsigned int follow_links=FALSE;
|
||||
@@ -168,20 +178,23 @@ static unsigned short column = 0;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
static unsigned short terminal_width = TERMINAL_WIDTH;
|
||||
static unsigned short column_width = COLUMN_WIDTH;
|
||||
static unsigned short tabstops = 8;
|
||||
static unsigned short tabstops = COLUMN_GAP;
|
||||
#else
|
||||
#define terminal_width TERMINAL_WIDTH
|
||||
#define column_width COLUMN_WIDTH
|
||||
static unsigned short column_width = COLUMN_WIDTH;
|
||||
#endif
|
||||
|
||||
static int status = EXIT_SUCCESS;
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
static unsigned long ls_disp_hr = 0;
|
||||
#endif
|
||||
|
||||
static int my_stat(struct dnode *cur)
|
||||
{
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
if (follow_links == TRUE) {
|
||||
if (stat(cur->fullname, &cur->dstat)) {
|
||||
error_msg("%s: %s\n", cur->fullname, strerror(errno));
|
||||
perror_msg("%s", cur->fullname);
|
||||
status = EXIT_FAILURE;
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
@@ -190,7 +203,7 @@ static int my_stat(struct dnode *cur)
|
||||
} else
|
||||
#endif
|
||||
if (lstat(cur->fullname, &cur->dstat)) {
|
||||
error_msg("%s: %s\n", cur->fullname, strerror(errno));
|
||||
perror_msg("%s", cur->fullname);
|
||||
status = EXIT_FAILURE;
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
@@ -202,7 +215,7 @@ static int my_stat(struct dnode *cur)
|
||||
static void newline(void)
|
||||
{
|
||||
if (column > 0) {
|
||||
fprintf(stdout, "\n");
|
||||
putchar('\n');
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
@@ -229,11 +242,11 @@ static void nexttabstop( void )
|
||||
n= nexttab - column;
|
||||
if (n < 1) n= 1;
|
||||
while (n--) {
|
||||
fprintf(stdout, " ");
|
||||
putchar(' ');
|
||||
column++;
|
||||
}
|
||||
}
|
||||
nexttab= column + column_width + COLUMN_GAP ;
|
||||
nexttab= column + column_width + COLUMN_GAP;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -243,7 +256,7 @@ static int is_subdir(struct dnode *dn)
|
||||
strcmp(dn->name, "..") != 0);
|
||||
}
|
||||
|
||||
int countdirs(struct dnode **dn, int nfiles)
|
||||
static int countdirs(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, dirs;
|
||||
|
||||
@@ -255,7 +268,7 @@ int countdirs(struct dnode **dn, int nfiles)
|
||||
return(dirs);
|
||||
}
|
||||
|
||||
int countsubdirs(struct dnode **dn, int nfiles)
|
||||
static int countsubdirs(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, subdirs;
|
||||
|
||||
@@ -267,7 +280,7 @@ int countsubdirs(struct dnode **dn, int nfiles)
|
||||
return subdirs;
|
||||
}
|
||||
|
||||
int countfiles(struct dnode **dnp)
|
||||
static int countfiles(struct dnode **dnp)
|
||||
{
|
||||
int nfiles;
|
||||
struct dnode *cur;
|
||||
@@ -280,7 +293,7 @@ int countfiles(struct dnode **dnp)
|
||||
}
|
||||
|
||||
/* get memory to hold an array of pointers */
|
||||
struct dnode **dnalloc(int num)
|
||||
static struct dnode **dnalloc(int num)
|
||||
{
|
||||
struct dnode **p;
|
||||
|
||||
@@ -290,7 +303,7 @@ struct dnode **dnalloc(int num)
|
||||
return(p);
|
||||
}
|
||||
|
||||
void dfree(struct dnode **dnp)
|
||||
static void dfree(struct dnode **dnp)
|
||||
{
|
||||
struct dnode *cur, *next;
|
||||
|
||||
@@ -306,7 +319,7 @@ void dfree(struct dnode **dnp)
|
||||
free(dnp); /* free the array holding the dnode pointers */
|
||||
}
|
||||
|
||||
struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
{
|
||||
int dncnt, i, d;
|
||||
struct dnode **dnp;
|
||||
@@ -346,7 +359,7 @@ struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
int sortcmp(struct dnode *d1, struct dnode *d2)
|
||||
static int sortcmp(struct dnode *d1, struct dnode *d2)
|
||||
{
|
||||
int cmp, dif;
|
||||
|
||||
@@ -383,7 +396,7 @@ int sortcmp(struct dnode *d1, struct dnode *d2)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void shellsort(struct dnode **dn, int size)
|
||||
static void shellsort(struct dnode **dn, int size)
|
||||
{
|
||||
struct dnode *temp;
|
||||
int gap, i, j;
|
||||
@@ -407,7 +420,7 @@ void shellsort(struct dnode **dn, int size)
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void showfiles(struct dnode **dn, int nfiles)
|
||||
static void showfiles(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, ncols, nrows, row, nc;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
@@ -424,10 +437,18 @@ void showfiles(struct dnode **dn, int nfiles)
|
||||
((list_fmt & LIST_INO) ? 8 : 0) +
|
||||
((list_fmt & LIST_BLOCKS) ? 5 : 0)
|
||||
;
|
||||
if (column_width < len) column_width= len;
|
||||
if (column_width < len)
|
||||
column_width= len;
|
||||
}
|
||||
if (column_width >= 6)
|
||||
ncols = (int)(terminal_width / (column_width + COLUMN_GAP));
|
||||
else {
|
||||
ncols = 1;
|
||||
column_width = COLUMN_WIDTH;
|
||||
}
|
||||
#else
|
||||
ncols= TERMINAL_WIDTH;
|
||||
#endif
|
||||
ncols= (int)(terminal_width / (column_width + COLUMN_GAP));
|
||||
switch (style_fmt) {
|
||||
case STYLE_LONG: /* one record per line, extended info */
|
||||
case STYLE_SINGLE: /* one record per line */
|
||||
@@ -435,7 +456,12 @@ void showfiles(struct dnode **dn, int nfiles)
|
||||
break;
|
||||
}
|
||||
|
||||
nrows= nfiles / ncols;
|
||||
if (ncols > 1) {
|
||||
nrows = nfiles / ncols;
|
||||
} else {
|
||||
nrows = nfiles;
|
||||
ncols = 1;
|
||||
}
|
||||
if ((nrows * ncols) < nfiles) nrows++; /* round up fractionals */
|
||||
|
||||
if (nrows > nfiles) nrows= nfiles;
|
||||
@@ -455,7 +481,7 @@ void showfiles(struct dnode **dn, int nfiles)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void showdirs(struct dnode **dn, int ndirs)
|
||||
static void showdirs(struct dnode **dn, int ndirs)
|
||||
{
|
||||
int i, nfiles;
|
||||
struct dnode **subdnp;
|
||||
@@ -468,7 +494,7 @@ void showdirs(struct dnode **dn, int ndirs)
|
||||
|
||||
for (i=0; i<ndirs; i++) {
|
||||
if (disp_opts & (DISP_DIRNAME | DISP_RECURSIVE)) {
|
||||
fprintf(stdout, "\n%s:\n", dn[i]->fullname);
|
||||
printf("\n%s:\n", dn[i]->fullname);
|
||||
}
|
||||
subdnp= list_dir(dn[i]->fullname);
|
||||
nfiles= countfiles(subdnp);
|
||||
@@ -498,7 +524,7 @@ void showdirs(struct dnode **dn, int ndirs)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
struct dnode **list_dir(char *path)
|
||||
static struct dnode **list_dir(char *path)
|
||||
{
|
||||
struct dnode *dn, *cur, **dnp;
|
||||
struct dirent *entry;
|
||||
@@ -511,7 +537,7 @@ struct dnode **list_dir(char *path)
|
||||
nfiles= 0;
|
||||
dir = opendir(path);
|
||||
if (dir == NULL) {
|
||||
error_msg("%s: %s\n", path, strerror(errno));
|
||||
perror_msg("%s", path);
|
||||
status = EXIT_FAILURE;
|
||||
return(NULL); /* could not open the dir */
|
||||
}
|
||||
@@ -549,7 +575,7 @@ struct dnode **list_dir(char *path)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int list_single(struct dnode *dn)
|
||||
static int list_single(struct dnode *dn)
|
||||
{
|
||||
int i, len;
|
||||
char scratch[BUFSIZ + 1];
|
||||
@@ -579,53 +605,57 @@ int list_single(struct dnode *dn)
|
||||
for (i=0; i<=31; i++) {
|
||||
switch (list_fmt & (1<<i)) {
|
||||
case LIST_INO:
|
||||
fprintf(stdout, "%7ld ", dn->dstat.st_ino);
|
||||
printf("%7ld ", dn->dstat.st_ino);
|
||||
column += 8;
|
||||
break;
|
||||
case LIST_BLOCKS:
|
||||
#if _FILE_OFFSET_BITS == 64
|
||||
fprintf(stdout, "%4lld ", dn->dstat.st_blocks>>1);
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
fprintf(stdout, "%5s ", make_human_readable_str(dn->dstat.st_blocks>>1,
|
||||
(ls_disp_hr==TRUE)? 0: 1));
|
||||
#else
|
||||
fprintf(stdout, "%4ld ", dn->dstat.st_blocks>>1);
|
||||
#if _FILE_OFFSET_BITS == 64
|
||||
printf("%4lld ", dn->dstat.st_blocks>>1);
|
||||
#else
|
||||
printf("%4ld ", dn->dstat.st_blocks>>1);
|
||||
#endif
|
||||
#endif
|
||||
column += 5;
|
||||
break;
|
||||
case LIST_MODEBITS:
|
||||
fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
|
||||
printf("%10s", (char *)mode_string(dn->dstat.st_mode));
|
||||
column += 10;
|
||||
break;
|
||||
case LIST_NLINKS:
|
||||
fprintf(stdout, "%4d ", dn->dstat.st_nlink);
|
||||
printf("%4d ", dn->dstat.st_nlink);
|
||||
column += 10;
|
||||
break;
|
||||
case LIST_ID_NAME:
|
||||
#ifdef BB_FEATURE_LS_USERNAME
|
||||
my_getpwuid(scratch, dn->dstat.st_uid);
|
||||
if (*scratch)
|
||||
fprintf(stdout, "%-8.8s ", scratch);
|
||||
else
|
||||
fprintf(stdout, "%-8d ", dn->dstat.st_uid);
|
||||
printf("%-8.8s ", scratch);
|
||||
my_getgrgid(scratch, dn->dstat.st_gid);
|
||||
if (*scratch)
|
||||
fprintf(stdout, "%-8.8s", scratch);
|
||||
else
|
||||
fprintf(stdout, "%-8d", dn->dstat.st_gid);
|
||||
printf("%-8.8s", scratch);
|
||||
column += 17;
|
||||
break;
|
||||
#endif
|
||||
case LIST_ID_NUMERIC:
|
||||
fprintf(stdout, "%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
|
||||
printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
|
||||
column += 17;
|
||||
break;
|
||||
case LIST_SIZE:
|
||||
case LIST_DEV:
|
||||
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
|
||||
fprintf(stdout, "%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
|
||||
printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
|
||||
} else {
|
||||
#if _FILE_OFFSET_BITS == 64
|
||||
fprintf(stdout, "%9lld ", dn->dstat.st_size);
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
fprintf(stdout, "%9s ", make_human_readable_str(dn->dstat.st_size,
|
||||
(ls_disp_hr==TRUE)? 0: 1));
|
||||
#else
|
||||
fprintf(stdout, "%9ld ", dn->dstat.st_size);
|
||||
#if _FILE_OFFSET_BITS == 64
|
||||
printf("%9lld ", dn->dstat.st_size>>1);
|
||||
#else
|
||||
printf("%9ld ", dn->dstat.st_size>>1);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
column += 10;
|
||||
@@ -634,23 +664,23 @@ int list_single(struct dnode *dn)
|
||||
case LIST_FULLTIME:
|
||||
case LIST_DATE_TIME:
|
||||
if (list_fmt & LIST_FULLTIME) {
|
||||
fprintf(stdout, "%24.24s ", filetime);
|
||||
printf("%24.24s ", filetime);
|
||||
column += 25;
|
||||
break;
|
||||
}
|
||||
age = time(NULL) - ttime;
|
||||
fprintf(stdout, "%6.6s ", filetime+4);
|
||||
printf("%6.6s ", filetime+4);
|
||||
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
|
||||
/* hh:mm if less than 6 months old */
|
||||
fprintf(stdout, "%5.5s ", filetime+11);
|
||||
printf("%5.5s ", filetime+11);
|
||||
} else {
|
||||
fprintf(stdout, " %4.4s ", filetime+20);
|
||||
printf(" %4.4s ", filetime+20);
|
||||
}
|
||||
column += 13;
|
||||
break;
|
||||
#endif
|
||||
case LIST_FILENAME:
|
||||
fprintf(stdout, "%s", dn->name);
|
||||
printf("%s", dn->name);
|
||||
column += strlen(dn->name);
|
||||
break;
|
||||
case LIST_SYMLINK:
|
||||
@@ -658,7 +688,7 @@ int list_single(struct dnode *dn)
|
||||
len= readlink(dn->fullname, scratch, (sizeof scratch)-1);
|
||||
if (len > 0) {
|
||||
scratch[len]= '\0';
|
||||
fprintf(stdout, " -> %s", scratch);
|
||||
printf(" -> %s", scratch);
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
if (!stat(dn->fullname, &info)) {
|
||||
append = append_char(info.st_mode);
|
||||
@@ -671,7 +701,7 @@ int list_single(struct dnode *dn)
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
case LIST_FILETYPE:
|
||||
if (append != '\0') {
|
||||
fprintf(stdout, "%1c", append);
|
||||
printf("%1c", append);
|
||||
column++;
|
||||
}
|
||||
break;
|
||||
@@ -692,15 +722,26 @@ extern int ls_main(int argc, char **argv)
|
||||
int opt;
|
||||
int oi, ac;
|
||||
char **av;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
struct winsize win = { 0, 0, 0, 0 };
|
||||
#endif
|
||||
|
||||
disp_opts= DISP_NORMAL;
|
||||
style_fmt= STYLE_AUTO;
|
||||
list_fmt= LIST_SHORT;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_NAME;
|
||||
sort_order= SORT_FORWARD;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
time_fmt= TIME_MOD;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
ioctl(fileno(stdout), TIOCGWINSZ, &win);
|
||||
if (win.ws_row > 4)
|
||||
column_width = win.ws_row - 2;
|
||||
if (win.ws_col > 0)
|
||||
terminal_width = win.ws_col - 1;
|
||||
#endif
|
||||
nfiles=0;
|
||||
|
||||
@@ -724,7 +765,10 @@ extern int ls_main(int argc, char **argv)
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
"L"
|
||||
#endif
|
||||
)) > 0) {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"h"
|
||||
#endif
|
||||
"k")) > 0) {
|
||||
switch (opt) {
|
||||
case '1': style_fmt = STYLE_SINGLE; break;
|
||||
case 'A': disp_opts |= DISP_HIDDEN; break;
|
||||
@@ -733,7 +777,13 @@ extern int ls_main(int argc, char **argv)
|
||||
case 'd': disp_opts |= DISP_NOLIST; break;
|
||||
case 'g': /* ignore -- for ftp servers */ break;
|
||||
case 'i': list_fmt |= LIST_INO; break;
|
||||
case 'l': style_fmt = STYLE_LONG; list_fmt |= LIST_LONG; break;
|
||||
case 'l':
|
||||
style_fmt = STYLE_LONG;
|
||||
list_fmt |= LIST_LONG;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
ls_disp_hr = FALSE;
|
||||
#endif
|
||||
break;
|
||||
case 'n': list_fmt |= LIST_ID_NUMERIC; break;
|
||||
case 's': list_fmt |= LIST_BLOCKS; break;
|
||||
case 'x': disp_opts = DISP_ROWS; break;
|
||||
@@ -777,6 +827,10 @@ extern int ls_main(int argc, char **argv)
|
||||
case 'T': tabstops= atoi(optarg); break;
|
||||
case 'w': terminal_width= atoi(optarg); break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h': ls_disp_hr = TRUE; break;
|
||||
#endif
|
||||
case 'k': break;
|
||||
default:
|
||||
goto print_usage_message;
|
||||
}
|
||||
@@ -871,9 +925,8 @@ extern int ls_main(int argc, char **argv)
|
||||
showdirs(dnd, dndirs);
|
||||
}
|
||||
}
|
||||
|
||||
return(status);
|
||||
|
||||
print_usage_message:
|
||||
usage(ls_usage);
|
||||
show_usage();
|
||||
}
|
||||
+38
-48
@@ -20,18 +20,17 @@
|
||||
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* It turns out that libc5 doesn't have this in its headers
|
||||
* even though it is actually in the lib. Force it to work */
|
||||
#if ! defined __GLIBC__ && ! defined __UCLIBC__
|
||||
#define getline __getline
|
||||
extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
|
||||
#endif
|
||||
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#define FALSE ((int) 1)
|
||||
#define TRUE ((int) 0)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//--------md5.c
|
||||
@@ -92,7 +91,7 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _MD5_H
|
||||
#define _MD5_H 1
|
||||
static const int _MD5_H = 1;
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -252,7 +251,7 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
|
||||
int md5_stream(FILE *stream, void *resblock)
|
||||
{
|
||||
/* Important: BLOCKSIZE must be a multiple of 64. */
|
||||
#define BLOCKSIZE 4096
|
||||
static const int BLOCKSIZE = 4096;
|
||||
struct md5_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
@@ -530,7 +529,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
/* The minimum length of a valid digest line in a file produced
|
||||
by `md5sum FILE' and read by `md5sum -c'. This length does
|
||||
not include any newline character at the end of a line. */
|
||||
#define MIN_DIGEST_LINE_LENGTH 35 /* 32 - message digest length
|
||||
static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
|
||||
2 - blank and binary indicator
|
||||
1 - minimum filename length */
|
||||
|
||||
@@ -651,13 +650,13 @@ static int md5_file(const char *filename,
|
||||
} else {
|
||||
fp = fopen(filename, OPENOPTS(binary));
|
||||
if (fp == NULL) {
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (md5_stream(fp, md5_result)) {
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
@@ -665,7 +664,7 @@ static int md5_file(const char *filename,
|
||||
}
|
||||
|
||||
if (fp != stdin && fclose(fp) == EOF) {
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -680,8 +679,7 @@ static int md5_check(const char *checkfile_name)
|
||||
int n_open_or_read_failures = 0;
|
||||
unsigned char md5buffer[16];
|
||||
size_t line_number;
|
||||
char *line;
|
||||
size_t line_chars_allocated;
|
||||
char line[BUFSIZ];
|
||||
|
||||
if (STREQ(checkfile_name, "-")) {
|
||||
have_read_stdin = 1;
|
||||
@@ -689,14 +687,12 @@ static int md5_check(const char *checkfile_name)
|
||||
} else {
|
||||
checkfile_stream = fopen(checkfile_name, "r");
|
||||
if (checkfile_stream == NULL) {
|
||||
error_msg("%s: %s\n", checkfile_name, strerror(errno));
|
||||
perror_msg("%s", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
line_number = 0;
|
||||
line = 0;
|
||||
line_chars_allocated = 0;
|
||||
|
||||
do {
|
||||
char *filename;
|
||||
@@ -706,9 +702,10 @@ static int md5_check(const char *checkfile_name)
|
||||
|
||||
++line_number;
|
||||
|
||||
line_length = getline(&line, &line_chars_allocated, checkfile_stream);
|
||||
fgets(line, BUFSIZ-1, checkfile_stream);
|
||||
line_length = strlen(line);
|
||||
|
||||
if (line_length <= 0)
|
||||
if (line_length <= 0 || line==NULL)
|
||||
break;
|
||||
|
||||
/* Ignore comment lines, which begin with a '#' character. */
|
||||
@@ -722,7 +719,7 @@ static int md5_check(const char *checkfile_name)
|
||||
if (split_3(line, line_length, &md5num, &binary, &filename)
|
||||
|| !hex_digits(md5num)) {
|
||||
if (warn) {
|
||||
error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
|
||||
error_msg("%s: %lu: improperly formatted MD5 checksum line",
|
||||
checkfile_name, (unsigned long) line_number);
|
||||
}
|
||||
} else {
|
||||
@@ -766,22 +763,19 @@ static int md5_check(const char *checkfile_name)
|
||||
|
||||
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
|
||||
|
||||
if (line)
|
||||
free(line);
|
||||
|
||||
if (ferror(checkfile_stream)) {
|
||||
error_msg("%s: read error\n", checkfile_name); /* */
|
||||
error_msg("%s: read error", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
|
||||
error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
|
||||
perror_msg("md5sum: %s", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_properly_formated_lines == 0) {
|
||||
/* Warn if no tests are found. */
|
||||
error_msg("%s: no properly formatted MD5 checksum lines found\n",
|
||||
error_msg("%s: no properly formatted MD5 checksum lines found",
|
||||
checkfile_name);
|
||||
return FALSE;
|
||||
} else {
|
||||
@@ -790,13 +784,13 @@ static int md5_check(const char *checkfile_name)
|
||||
- n_open_or_read_failures);
|
||||
|
||||
if (n_open_or_read_failures > 0) {
|
||||
error_msg("WARNING: %d of %d listed files could not be read\n",
|
||||
error_msg("WARNING: %d of %d listed files could not be read",
|
||||
n_open_or_read_failures, n_properly_formated_lines);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_mismatched_checksums > 0) {
|
||||
error_msg("WARNING: %d of %d computed checksums did NOT match\n",
|
||||
error_msg("WARNING: %d of %d computed checksums did NOT match",
|
||||
n_mismatched_checksums, n_computed_checkums);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -825,8 +819,6 @@ int md5sum_main(int argc,
|
||||
if (string == NULL)
|
||||
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
|
||||
|
||||
if (optarg == NULL)
|
||||
optarg = "";
|
||||
string[n_strings++] = optarg;
|
||||
break;
|
||||
}
|
||||
@@ -856,36 +848,31 @@ int md5sum_main(int argc,
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(md5sum_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (file_type_specified && do_check) {
|
||||
error_msg("the -b and -t options are meaningless when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("the -b and -t options are meaningless when verifying checksums");
|
||||
}
|
||||
|
||||
if (n_strings > 0 && do_check) {
|
||||
error_msg("the -g and -c options are mutually exclusive\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("the -g and -c options are mutually exclusive");
|
||||
}
|
||||
|
||||
if (status_only && !do_check) {
|
||||
error_msg("the -s option is meaningful only when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("the -s option is meaningful only when verifying checksums");
|
||||
}
|
||||
|
||||
if (warn && !do_check) {
|
||||
error_msg("the -w option is meaningful only when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("the -w option is meaningful only when verifying checksums");
|
||||
}
|
||||
|
||||
if (n_strings > 0) {
|
||||
size_t i;
|
||||
|
||||
if (optind < argc) {
|
||||
error_msg("no files may be specified when using -g\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("no files may be specified when using -g");
|
||||
}
|
||||
for (i = 0; i < n_strings; ++i) {
|
||||
size_t cnt;
|
||||
@@ -898,7 +885,7 @@ int md5sum_main(int argc,
|
||||
}
|
||||
} else if (do_check) {
|
||||
if (optind + 1 < argc) {
|
||||
error_msg("only one argument may be specified when using -c\n");
|
||||
error_msg("only one argument may be specified when using -c");
|
||||
}
|
||||
|
||||
err = md5_check ((optind == argc) ? "-" : argv[optind]);
|
||||
@@ -912,7 +899,12 @@ int md5sum_main(int argc,
|
||||
|
||||
fail = md5_file (file, binary, md5buffer);
|
||||
err |= fail;
|
||||
if (!fail) {
|
||||
if (!fail && STREQ(file, "-")) {
|
||||
size_t i;
|
||||
for (i = 0; i < 16; ++i)
|
||||
printf ("%02x", md5buffer[i]);
|
||||
putchar ('\n');
|
||||
} else if (!fail) {
|
||||
size_t i;
|
||||
/* Output a leading backslash if the file name contains
|
||||
a newline or backslash. */
|
||||
@@ -951,13 +943,11 @@ int md5sum_main(int argc,
|
||||
}
|
||||
|
||||
if (fclose (stdout) == EOF) {
|
||||
error_msg("write error\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("write error");
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF) {
|
||||
error_msg("standard input\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("standard input");
|
||||
}
|
||||
|
||||
if (err == 0)
|
||||
|
||||
+12
-14
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini mkdir implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,13 +21,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#define bb_need_name_too_long
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int parentFlag = FALSE;
|
||||
static mode_t mode = 0777;
|
||||
@@ -46,12 +48,11 @@ extern int mkdir_main(int argc, char **argv)
|
||||
switch (**argv) {
|
||||
case 'm':
|
||||
if (--argc == 0)
|
||||
usage(mkdir_usage);
|
||||
show_usage();
|
||||
/* Find the specified modes */
|
||||
mode = 0;
|
||||
if (parse_mode(*(++argv), &mode) == FALSE) {
|
||||
error_msg("Unknown mode: %s\n", *argv);
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("Unknown mode: %s", *argv);
|
||||
}
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up whatever the user just entered. */
|
||||
@@ -62,7 +63,7 @@ extern int mkdir_main(int argc, char **argv)
|
||||
parentFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage(mkdir_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
@@ -70,7 +71,7 @@ extern int mkdir_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (argc < 1) {
|
||||
usage(mkdir_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
while (argc > 0) {
|
||||
@@ -79,22 +80,19 @@ extern int mkdir_main(int argc, char **argv)
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if (strlen(*argv) > BUFSIZ - 1) {
|
||||
error_msg(name_too_long);
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die(name_too_long);
|
||||
}
|
||||
strcpy(buf, *argv);
|
||||
status = stat(buf, &statBuf);
|
||||
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
|
||||
error_msg("%s: File exists\n", buf);
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("%s: File exists", buf);
|
||||
}
|
||||
if (parentFlag == TRUE) {
|
||||
strcat(buf, "/");
|
||||
create_path(buf, mode);
|
||||
} else {
|
||||
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
|
||||
perror(buf);
|
||||
return EXIT_FAILURE;
|
||||
perror_msg_and_die(buf);
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
|
||||
+7
-8
@@ -20,10 +20,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int mkfifo_main(int argc, char **argv)
|
||||
{
|
||||
@@ -36,7 +37,7 @@ extern int mkfifo_main(int argc, char **argv)
|
||||
/* Parse any options */
|
||||
while (argc > 1) {
|
||||
if (**argv != '-')
|
||||
usage(mkfifo_usage);
|
||||
show_usage();
|
||||
thisarg = *argv;
|
||||
thisarg++;
|
||||
switch (*thisarg) {
|
||||
@@ -46,16 +47,14 @@ extern int mkfifo_main(int argc, char **argv)
|
||||
parse_mode(*argv, &mode);
|
||||
break;
|
||||
default:
|
||||
usage(mkfifo_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc < 1 || *argv[0] == '-')
|
||||
usage(mkfifo_usage);
|
||||
if (mkfifo(*argv, mode) < 0) {
|
||||
perror("mkfifo");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
show_usage();
|
||||
if (mkfifo(*argv, mode) < 0)
|
||||
perror_msg_and_die("mkfifo");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+9
-7
@@ -20,12 +20,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int mknod_main(int argc, char **argv)
|
||||
{
|
||||
@@ -51,13 +53,13 @@ int mknod_main(int argc, char **argv)
|
||||
umask(0);
|
||||
break;
|
||||
default:
|
||||
usage(mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc != 4 && argc != 2) {
|
||||
usage(mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
switch (argv[1][0]) {
|
||||
case 'c':
|
||||
@@ -70,11 +72,11 @@ int mknod_main(int argc, char **argv)
|
||||
case 'p':
|
||||
mode = S_IFIFO;
|
||||
if (argc!=2) {
|
||||
usage(mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage(mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (mode == S_IFCHR || mode == S_IFBLK) {
|
||||
@@ -84,7 +86,7 @@ int mknod_main(int argc, char **argv)
|
||||
mode |= perm;
|
||||
|
||||
if (mknod(argv[0], mode, dev) != 0)
|
||||
error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
|
||||
perror_msg_and_die("%s", argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+3
-3
@@ -47,7 +47,6 @@
|
||||
|
||||
// 19990508 Busy Boxed! Dave Cinege
|
||||
|
||||
#include "busybox.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
@@ -56,10 +55,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
#ifndef S_IFMT
|
||||
# define S_IFMT 0170000
|
||||
static const int S_IFMT = 0170000;
|
||||
#endif
|
||||
#if !defined(S_ISBLK) && defined(S_IFBLK)
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
@@ -143,7 +143,7 @@ int printf_main(int argc, char **argv)
|
||||
|
||||
exit_status = 0;
|
||||
if (argc <= 1 || **(argv + 1) == '-') {
|
||||
usage(printf_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
format = argv[1];
|
||||
|
||||
+7
-3
@@ -21,18 +21,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int pwd_main(int argc, char **argv)
|
||||
{
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if (getcwd(buf, sizeof(buf)) == NULL)
|
||||
error_msg_and_die("%s\n", strerror(errno));
|
||||
perror_msg_and_die("getcwd");
|
||||
|
||||
printf("%s\n", buf);
|
||||
puts(buf);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+35
-4
@@ -3,9 +3,13 @@
|
||||
* Mini rm implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* INTERACTIVE feature Copyright (C) 2001 by Alcove
|
||||
* written by Christophe Boyanique <Christophe.Boyanique@fr.alcove.com>
|
||||
* for Ipanema Technologies
|
||||
*
|
||||
* 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
|
||||
@@ -22,20 +26,32 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int recursiveFlag = FALSE;
|
||||
static int forceFlag = FALSE;
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
static int interactiveFlag = FALSE;
|
||||
#endif
|
||||
static const char *srcName;
|
||||
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
if (interactiveFlag == TRUE) {
|
||||
printf("rm: remove `%s'? ", fileName);
|
||||
if (ask_confirmation() == 0)
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
if (unlink(fileName) < 0) {
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
@@ -50,6 +66,13 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
if (interactiveFlag == TRUE) {
|
||||
printf("rm: remove directory `%s'? ", fileName);
|
||||
if (ask_confirmation() == 0)
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
if (rmdir(fileName) < 0) {
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
@@ -77,12 +100,20 @@ extern int rm_main(int argc, char **argv)
|
||||
break;
|
||||
case 'f':
|
||||
forceFlag = TRUE;
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
interactiveFlag = FALSE;
|
||||
#endif
|
||||
break;
|
||||
case 'i':
|
||||
#ifdef BB_FEATURE_RM_INTERACTIVE
|
||||
interactiveFlag = TRUE;
|
||||
#endif
|
||||
break;
|
||||
case '-':
|
||||
stopIt = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage(rm_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
@@ -92,7 +123,7 @@ extern int rm_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (argc < 1 && forceFlag == FALSE) {
|
||||
usage(rm_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
while (argc-- > 0) {
|
||||
|
||||
+5
-3
@@ -3,7 +3,7 @@
|
||||
* Mini rmdir implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,16 +22,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
usage(rmdir_usage);
|
||||
show_usage();
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
|
||||
+6
-6
@@ -21,18 +21,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int sleep_main(int argc, char **argv)
|
||||
{
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(sleep_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (sleep(atoi(*(++argv))) != 0) {
|
||||
perror("sleep");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (sleep(atoi(*(++argv))) != 0)
|
||||
perror_msg_and_die("sleep");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+41
-240
@@ -3,8 +3,7 @@
|
||||
* Mini sort implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,268 +21,70 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
|
||||
static int reverse = 0;
|
||||
#else
|
||||
#define APPLY_REVERSE(x) (x)
|
||||
#endif
|
||||
|
||||
/* typedefs _______________________________________________________________ */
|
||||
|
||||
/* line node */
|
||||
typedef struct Line {
|
||||
char *data; /* line data */
|
||||
struct Line *next; /* pointer to next line node */
|
||||
} Line;
|
||||
|
||||
/* singly-linked list of lines */
|
||||
typedef struct {
|
||||
int len; /* number of Lines */
|
||||
Line **sorted; /* array fed to qsort */
|
||||
Line *head; /* head of List */
|
||||
Line *current; /* current Line */
|
||||
} List;
|
||||
|
||||
/* comparison function */
|
||||
typedef int (Compare) (const void *, const void *);
|
||||
|
||||
|
||||
/* methods ________________________________________________________________ */
|
||||
|
||||
static const int max = 1024;
|
||||
|
||||
/* mallocate Line */
|
||||
static Line *line_alloc()
|
||||
static int compare_ascii(const void *x, const void *y)
|
||||
{
|
||||
Line *self;
|
||||
self = xmalloc(1 * sizeof(Line));
|
||||
return self;
|
||||
return strcmp(*(char **)x, *(char **)y);
|
||||
}
|
||||
|
||||
/* Construct Line from FILE* */
|
||||
static Line *line_newFromFile(FILE * src)
|
||||
static int compare_numeric(const void *x, const void *y)
|
||||
{
|
||||
Line *self;
|
||||
char *cstring = NULL;
|
||||
|
||||
if ((cstring = get_line_from_file(src))) {
|
||||
self = line_alloc();
|
||||
self->data = cstring;
|
||||
self->next = NULL;
|
||||
return self;
|
||||
}
|
||||
return NULL;
|
||||
return atoi(*(char **)x) - atoi(*(char **)y);
|
||||
}
|
||||
|
||||
/* Line destructor */
|
||||
static Line *line_release(Line * self)
|
||||
{
|
||||
if (self->data) {
|
||||
free(self->data);
|
||||
free(self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/* Comparison */
|
||||
|
||||
/* ascii order */
|
||||
static int compare_ascii(const void *a, const void *b)
|
||||
{
|
||||
Line **val;
|
||||
Line *x, *y;
|
||||
|
||||
val = (Line **) a;
|
||||
x = *val;
|
||||
val = (Line **) b;
|
||||
y = *val;
|
||||
|
||||
// fprintf(stdout, "> %p: %s< %p: %s", x, x->data, y, y->data);
|
||||
return APPLY_REVERSE(strcmp(x->data, y->data));
|
||||
}
|
||||
|
||||
/* numeric order */
|
||||
static int compare_numeric(const void *a, const void *b)
|
||||
{
|
||||
Line **val;
|
||||
Line *x, *y;
|
||||
int xint, yint;
|
||||
|
||||
val = (Line **) a;
|
||||
x = *val;
|
||||
val = (Line **) b;
|
||||
y = *val;
|
||||
|
||||
xint = strtoul(x->data, NULL, 10);
|
||||
yint = strtoul(y->data, NULL, 10);
|
||||
|
||||
return APPLY_REVERSE(xint - yint);
|
||||
}
|
||||
|
||||
|
||||
/* List */
|
||||
|
||||
/* */
|
||||
static List *list_init(List * self)
|
||||
{
|
||||
self->len = 0;
|
||||
self->sorted = NULL;
|
||||
self->head = NULL;
|
||||
self->current = NULL;
|
||||
return self;
|
||||
}
|
||||
|
||||
/* for simplicity, the List gains ownership of the line */
|
||||
static List *list_insert(List * self, Line * line)
|
||||
{
|
||||
if (line == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* first insertion */
|
||||
if (self->head == NULL) {
|
||||
self->head = line;
|
||||
self->current = line;
|
||||
|
||||
/* all subsequent insertions */
|
||||
} else {
|
||||
self->current->next = line;
|
||||
self->current = line;
|
||||
}
|
||||
self->len++;
|
||||
return self;
|
||||
}
|
||||
|
||||
/* order the list according to compare() */
|
||||
static List *list_sort(List * self, Compare * compare)
|
||||
{
|
||||
int i;
|
||||
Line *line;
|
||||
|
||||
/* mallocate array of Line*s */
|
||||
self->sorted = (Line **) xmalloc(self->len * sizeof(Line *));
|
||||
|
||||
/* fill array w/ List's contents */
|
||||
i = 0;
|
||||
line = self->head;
|
||||
while (line) {
|
||||
self->sorted[i++] = line;
|
||||
line = line->next;
|
||||
}
|
||||
|
||||
/* apply qsort */
|
||||
qsort(self->sorted, self->len, sizeof(Line *), compare);
|
||||
return self;
|
||||
}
|
||||
|
||||
/* precondition: list must be sorted */
|
||||
static List *list_writeToFile(List * self, FILE * dst)
|
||||
{
|
||||
int i;
|
||||
Line **line = self->sorted;
|
||||
|
||||
if (self->sorted == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < self->len; i++) {
|
||||
fprintf(dst, "%s", line[i]->data);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/* deallocate */
|
||||
static void list_release(List * self)
|
||||
{
|
||||
Line *i;
|
||||
Line *die;
|
||||
|
||||
i = self->head;
|
||||
while (i) {
|
||||
die = i;
|
||||
i = die->next;
|
||||
line_release(die);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int sort_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char opt;
|
||||
List list;
|
||||
Line *l;
|
||||
Compare *compare;
|
||||
FILE *fp;
|
||||
char *line, **lines = NULL;
|
||||
int i, opt, nlines = 0;
|
||||
int (*compare)(const void *, const void *) = compare_ascii;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
int reverse = FALSE;
|
||||
#endif
|
||||
|
||||
/* init */
|
||||
compare = compare_ascii;
|
||||
list_init(&list);
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
usage(sort_usage);
|
||||
break;
|
||||
while ((opt = getopt(argc, argv, "nr")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
/* numeric comparison */
|
||||
compare = compare_numeric;
|
||||
break;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
case 'r':
|
||||
/* reverse */
|
||||
reverse = 1;
|
||||
reverse = TRUE;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
error_msg("invalid option -- %c\n", opt);
|
||||
usage(sort_usage);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= argc) {
|
||||
/* read the input */
|
||||
for (i = optind; i == optind || i < argc; i++) {
|
||||
if (argv[i] == NULL)
|
||||
fp = stdin;
|
||||
else
|
||||
fp = xfopen(argv[i], "r");
|
||||
|
||||
/* work w/ stdin */
|
||||
while ((l = line_newFromFile(stdin))) {
|
||||
list_insert(&list, l);
|
||||
while ((line = get_line_from_file(fp)) != NULL) {
|
||||
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
|
||||
lines[nlines++] = line;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* work w/ what's left in argv[] */
|
||||
FILE *src;
|
||||
|
||||
for (; i < argc; i++) {
|
||||
src = fopen(argv[i], "r");
|
||||
if (src == NULL) {
|
||||
break;
|
||||
}
|
||||
while ((l = line_newFromFile(src))) {
|
||||
list_insert(&list, l);
|
||||
}
|
||||
fclose(src);
|
||||
}
|
||||
|
||||
}
|
||||
list_sort(&list, compare);
|
||||
list_writeToFile(&list, stdout);
|
||||
list_release(&list);
|
||||
|
||||
return(0);
|
||||
/* sort it */
|
||||
qsort(lines, nlines, sizeof(char *), compare);
|
||||
|
||||
/* print it */
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
if (reverse)
|
||||
for (i = nlines - 1; 0 <= i; i--)
|
||||
fputs(lines[i], stdout);
|
||||
else
|
||||
#endif
|
||||
for (i = 0; i < nlines; i++)
|
||||
fputs(lines[i], stdout);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* $Id: sort.c,v 1.24 2000/12/07 19:56:48 markw Exp $ */
|
||||
+1443
File diff suppressed because it is too large.
Load diff
+6
-3
@@ -21,12 +21,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int sync_main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage(sync_usage);
|
||||
return(sync());
|
||||
show_usage();
|
||||
sync();
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
+214
-286
@@ -1,319 +1,247 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/* tail -- output the last part of file(s)
|
||||
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Original version by Paul Rubin <phr@ocf.berkeley.edu>.
|
||||
Extensions by David MacKenzie <djm@gnu.ai.mit.edu>.
|
||||
tail -f for multiple files by Ian Lance Taylor <ian@airs.com>.
|
||||
|
||||
Rewrote the option parser, removed locales support,
|
||||
and generally busyboxed, Erik Andersen <andersen@lineo.com>
|
||||
|
||||
Removed superfluous options and associated code ("-c", "-n", "-q").
|
||||
Removed "tail -f" support for multiple files.
|
||||
Both changes by Friedrich Vedder <fwv@myrtle.lahn.de>.
|
||||
|
||||
Compleate Rewrite to correctly support "-NUM", "+NUM", and "-s" by
|
||||
E.Allen Soard (esp@espsw.net).
|
||||
|
||||
/*
|
||||
* Mini tail implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define STDIN "standard input"
|
||||
#define LINES 0
|
||||
#define BYTES 1
|
||||
static const struct suffix_mult tail_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1048576 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static int n_files = 0;
|
||||
static char **files = NULL;
|
||||
static char * buffer;
|
||||
static ssize_t bytes_read=0;
|
||||
static ssize_t bs;
|
||||
static ssize_t filelocation=0;
|
||||
static char pip;
|
||||
static const int BYTES = 0;
|
||||
static const int LINES = 1;
|
||||
|
||||
#ifdef BB_FEATURE_SIMPLE_TAIL
|
||||
static const char unit_type=LINES;
|
||||
#else
|
||||
static char unit_type=LINES;
|
||||
static char verbose = 0;
|
||||
#endif
|
||||
static char *tailbuf;
|
||||
static int taillen;
|
||||
static int newline;
|
||||
|
||||
static off_t units=0;
|
||||
|
||||
static int tail_stream(int fd)
|
||||
static void tailbuf_append(char *buf, int len)
|
||||
{
|
||||
ssize_t startpoint;
|
||||
ssize_t endpoint=0;
|
||||
ssize_t count=0;
|
||||
ssize_t filesize=0;
|
||||
int direction=1;
|
||||
|
||||
filelocation=0;
|
||||
startpoint=bs=BUFSIZ;
|
||||
|
||||
filesize=lseek(fd, -1, SEEK_END)+1;
|
||||
pip=(filesize<=0);
|
||||
|
||||
if(units>=0)
|
||||
lseek(fd,0,SEEK_SET);
|
||||
else {
|
||||
direction=-1;
|
||||
count=1;
|
||||
}
|
||||
while(units != 0) {
|
||||
if (pip) {
|
||||
char * line;
|
||||
ssize_t f_size=0;
|
||||
|
||||
bs=BUFSIZ;
|
||||
line=xmalloc(bs);
|
||||
while(1) {
|
||||
bytes_read=read(fd,line,bs);
|
||||
if(bytes_read<=0)
|
||||
break;
|
||||
buffer=xrealloc(buffer,f_size+bytes_read);
|
||||
memcpy(&buffer[f_size],line,bytes_read);
|
||||
filelocation=f_size+=bytes_read;
|
||||
}
|
||||
bs=f_size;
|
||||
if(direction<0)
|
||||
bs--;
|
||||
if (line)
|
||||
free(line);
|
||||
} else {
|
||||
filelocation = lseek(fd, 0, SEEK_CUR);
|
||||
if(direction<0) {
|
||||
if(filelocation<bs)
|
||||
bs=filelocation;
|
||||
filelocation = lseek(fd, -bs, SEEK_CUR);
|
||||
}
|
||||
bytes_read = read(fd, buffer, bs);
|
||||
if (bytes_read <= 0)
|
||||
break;
|
||||
bs=bytes_read;
|
||||
}
|
||||
startpoint=bs;
|
||||
if(direction>0) {
|
||||
endpoint=startpoint;
|
||||
startpoint=0;
|
||||
}
|
||||
for(;startpoint!=endpoint;startpoint+=direction) {
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if(unit_type==BYTES)
|
||||
count++;
|
||||
else
|
||||
#endif
|
||||
if(buffer[startpoint-1]=='\n')
|
||||
count++;
|
||||
if (!pip)
|
||||
filelocation=lseek(fd,0,SEEK_CUR);
|
||||
if(count==units*direction)
|
||||
break;
|
||||
}
|
||||
if((count==units*direction) | pip)
|
||||
break;
|
||||
if(direction<0){
|
||||
filelocation = lseek(fd, -bytes_read, SEEK_CUR);
|
||||
if(filelocation==0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(pip && (direction<0))
|
||||
bs++;
|
||||
bytes_read=bs-startpoint;
|
||||
memcpy(&buffer[0],&buffer[startpoint],bytes_read);
|
||||
|
||||
return 0;
|
||||
tailbuf = xrealloc(tailbuf, taillen + len);
|
||||
memcpy(tailbuf + taillen, buf, len);
|
||||
taillen += len;
|
||||
}
|
||||
|
||||
void add_file(char *name)
|
||||
static void tailbuf_trunc()
|
||||
{
|
||||
++n_files;
|
||||
files = xrealloc(files, n_files);
|
||||
files[n_files - 1] = (char *) xmalloc(strlen(name) + 1);
|
||||
strcpy(files[n_files - 1], name);
|
||||
char *s;
|
||||
s = memchr(tailbuf, '\n', taillen);
|
||||
memmove(tailbuf, s + 1, taillen - ((s + 1) - tailbuf));
|
||||
taillen -= (s + 1) - tailbuf;
|
||||
newline = 0;
|
||||
}
|
||||
|
||||
int tail_main(int argc, char **argv)
|
||||
{
|
||||
int show_headers = 1;
|
||||
int test;
|
||||
int opt;
|
||||
char follow=0;
|
||||
int sleep_int=1;
|
||||
int *fd;
|
||||
|
||||
opterr = 0;
|
||||
|
||||
while ((opt=getopt(argc,argv,"c:fhn:s:q:v")) >0) {
|
||||
int from_top = 0, units = LINES, count = 10, sleep_period = 1;
|
||||
int show_headers = 0, hide_headers = 0, follow = 0;
|
||||
int *fds, nfiles = 0, status = EXIT_SUCCESS, nread, nwrite, seen = 0;
|
||||
char *s, *start, *end, buf[BUFSIZ];
|
||||
int i, opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "c:fhn:q:s:v")) > 0) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
follow = 1;
|
||||
break;
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
case 'c':
|
||||
unit_type = BYTES;
|
||||
test = atoi(optarg);
|
||||
if(test==0)
|
||||
usage(tail_usage);
|
||||
if(optarg[strlen(optarg)-1]>'9') {
|
||||
switch (optarg[strlen(optarg)-1]) {
|
||||
case 'b':
|
||||
test *= 512;
|
||||
break;
|
||||
case 'k':
|
||||
test *= 1024;
|
||||
break;
|
||||
case 'm':
|
||||
test *= (1024 * 1024);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Size must be b,k, or m.");
|
||||
usage(tail_usage);
|
||||
}
|
||||
}
|
||||
if(optarg[0]=='+')
|
||||
units=test+1;
|
||||
else
|
||||
units=-(test+1);
|
||||
break;
|
||||
case 'q':
|
||||
show_headers = 0;
|
||||
break;
|
||||
case 's':
|
||||
sleep_int = atoi(optarg);
|
||||
if(sleep_int<1)
|
||||
sleep_int=1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'c':
|
||||
units = BYTES;
|
||||
/* FALLS THROUGH */
|
||||
#endif
|
||||
case 'f':
|
||||
follow = 1;
|
||||
break;
|
||||
case 'h':
|
||||
usage(tail_usage);
|
||||
break;
|
||||
case 'n':
|
||||
test = atoi(optarg);
|
||||
if (test) {
|
||||
case 'n':
|
||||
count = parse_number(optarg, tail_suffixes);
|
||||
if (count < 0)
|
||||
count = -count;
|
||||
if (optarg[0] == '+')
|
||||
units = test;
|
||||
else
|
||||
units = -(test+1);
|
||||
} else
|
||||
usage(tail_usage);
|
||||
break;
|
||||
default:
|
||||
error_msg("\nUnknown arg: %c.\n\n",optopt);
|
||||
usage(tail_usage);
|
||||
}
|
||||
}
|
||||
while (optind <= argc) {
|
||||
if(optind==argc) {
|
||||
if (n_files==0)
|
||||
add_file(STDIN);
|
||||
else
|
||||
from_top = 1;
|
||||
break;
|
||||
}else {
|
||||
if (!strcmp(argv[optind], "-")) {
|
||||
add_file(STDIN);
|
||||
} else {
|
||||
add_file(argv[optind]);
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
}
|
||||
if(units==0)
|
||||
units=-11;
|
||||
if(units>0)
|
||||
units--;
|
||||
fd=xmalloc(sizeof(int)*n_files);
|
||||
if (n_files == 1)
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if (!verbose)
|
||||
#endif
|
||||
show_headers = 0;
|
||||
buffer=xmalloc(BUFSIZ);
|
||||
for (test = 0; test < n_files; test++) {
|
||||
if (show_headers)
|
||||
printf("==> %s <==\n", files[test]);
|
||||
if (!strcmp(files[test], STDIN))
|
||||
fd[test] = 0;
|
||||
else
|
||||
fd[test] = open(files[test], O_RDONLY);
|
||||
if (fd[test] == -1)
|
||||
error_msg_and_die("Unable to open file %s.\n", files[test]);
|
||||
tail_stream(fd[test]);
|
||||
|
||||
bs=BUFSIZ;
|
||||
while (1) {
|
||||
if((filelocation>0 || pip)){
|
||||
write(1,buffer,bytes_read);
|
||||
}
|
||||
bytes_read = read(fd[test], buffer, bs);
|
||||
filelocation+=bytes_read;
|
||||
if (bytes_read <= 0) {
|
||||
case 'q':
|
||||
hide_headers = 1;
|
||||
break;
|
||||
}
|
||||
usleep(sleep_int * 1000);
|
||||
case 's':
|
||||
sleep_period = parse_number(optarg, 0);
|
||||
break;
|
||||
case 'v':
|
||||
show_headers = 1;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
if(n_files>1)
|
||||
printf("\n");
|
||||
}
|
||||
while(1){
|
||||
for (test = 0; test < n_files; test++) {
|
||||
if(!follow){
|
||||
close(fd[test]);
|
||||
continue;
|
||||
|
||||
/* open all the files */
|
||||
fds = (int *)xmalloc(sizeof(int) * (argc - optind + 1));
|
||||
if (argc == optind) {
|
||||
fds[nfiles++] = STDIN_FILENO;
|
||||
argv[optind] = "standard input";
|
||||
} else {
|
||||
for (i = optind; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-") == 0) {
|
||||
fds[nfiles++] = STDIN_FILENO;
|
||||
argv[i] = "standard input";
|
||||
} else if ((fds[nfiles++] = open(argv[i], O_RDONLY)) < 0) {
|
||||
perror_msg("%s", argv[i]);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
/* tail the files */
|
||||
if (!from_top && units == BYTES)
|
||||
tailbuf = xmalloc(count);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
if (fds[i] == -1)
|
||||
continue;
|
||||
seen = 0;
|
||||
if (show_headers || (!hide_headers && nfiles > 1))
|
||||
printf("%s==> %s <==\n", i == 0 ? "" : "\n", argv[optind + i]);
|
||||
while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
|
||||
if (from_top) {
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if (units == BYTES) {
|
||||
if (count - 1 <= seen)
|
||||
nwrite = nread;
|
||||
else if (count - 1 <= seen + nread)
|
||||
nwrite = nread + seen - (count - 1);
|
||||
else
|
||||
nwrite = 0;
|
||||
seen += nread;
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
if (count - 1 <= seen)
|
||||
nwrite = nread;
|
||||
else {
|
||||
nwrite = 0;
|
||||
for (s = memchr(buf, '\n', nread); s != NULL;
|
||||
s = memchr(s+1, '\n', nread - (s + 1 - buf))) {
|
||||
if (count - 1 <= ++seen) {
|
||||
nwrite = nread - (s + 1 - buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (full_write(STDOUT_FILENO, buf + nread - nwrite,
|
||||
nwrite) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sleep(sleep_int);
|
||||
bytes_read = read(fd[test], buffer, bs);
|
||||
if(bytes_read>0) {
|
||||
if (show_headers)
|
||||
printf("==> %s <==\n", files[test]);
|
||||
write(1,buffer,bytes_read);
|
||||
if(n_files>1)
|
||||
printf("\n");
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if (units == BYTES) {
|
||||
if (nread < count) {
|
||||
memmove(tailbuf, tailbuf + nread, count - nread);
|
||||
memcpy(tailbuf + count - nread, buf, nread);
|
||||
} else {
|
||||
memcpy(tailbuf, buf + nread - count, count);
|
||||
}
|
||||
seen += nread;
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
for (start = buf, end = memchr(buf, '\n', nread);
|
||||
end != NULL; start = end+1,
|
||||
end = memchr(start, '\n', nread - (start - buf))) {
|
||||
if (newline && count <= seen)
|
||||
tailbuf_trunc();
|
||||
tailbuf_append(start, end - start + 1);
|
||||
seen++;
|
||||
newline = 1;
|
||||
}
|
||||
if (newline && count <= seen && nread - (start - buf) > 0)
|
||||
tailbuf_trunc();
|
||||
tailbuf_append(start, nread - (start - buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!follow)
|
||||
break;
|
||||
}
|
||||
if (fd)
|
||||
free(fd);
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
if(files)
|
||||
free(files);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
if (nread < 0) {
|
||||
perror_msg("read");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if (!from_top && units == BYTES) {
|
||||
if (count < seen)
|
||||
seen = count;
|
||||
if (full_write(STDOUT_FILENO, tailbuf + count - seen, seen) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!from_top && units == LINES) {
|
||||
if (full_write(STDOUT_FILENO, tailbuf, taillen) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
taillen = 0;
|
||||
}
|
||||
|
||||
while (follow) {
|
||||
sleep(sleep_period);
|
||||
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
if (fds[i] == -1)
|
||||
continue;
|
||||
|
||||
if ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
|
||||
if (show_headers || (!hide_headers && nfiles > 1))
|
||||
printf("\n==> %s <==\n", argv[optind + i]);
|
||||
|
||||
do {
|
||||
full_write(STDOUT_FILENO, buf, nread);
|
||||
} while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0);
|
||||
}
|
||||
|
||||
if (nread < 0) {
|
||||
perror_msg("read");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini tee implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -38,7 +38,7 @@ tee_main(int argc, char **argv)
|
||||
mode = "a";
|
||||
break;
|
||||
default:
|
||||
usage(tee_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
|
||||
while (optind < argc) {
|
||||
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
|
||||
nfiles--;
|
||||
error_msg("%s: %s\n", argv[optind-1], strerror(errno));
|
||||
perror_msg("%s", argv[optind-1]);
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -31,13 +31,13 @@
|
||||
* "This program is in the Public Domain."
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_help
|
||||
#include "messages.c"
|
||||
@@ -156,8 +156,8 @@ struct t_op {
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
char **t_wp;
|
||||
struct t_op const *t_wp_op;
|
||||
static char **t_wp;
|
||||
static struct t_op const *t_wp_op;
|
||||
static gid_t *group_array = NULL;
|
||||
static int ngroups;
|
||||
|
||||
@@ -184,7 +184,7 @@ test_main(int argc, char** argv)
|
||||
|
||||
if (strcmp(applet_name, "[") == 0) {
|
||||
if (strcmp(argv[--argc], "]"))
|
||||
error_msg_and_die("missing ]\n");
|
||||
error_msg_and_die("missing ]");
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
/* Implement special cases from POSIX.2, section 4.62.4 */
|
||||
@@ -233,9 +233,9 @@ syntax(op, msg)
|
||||
char *msg;
|
||||
{
|
||||
if (op && *op)
|
||||
error_msg_and_die("%s: %s\n", op, msg);
|
||||
error_msg_and_die("%s: %s", op, msg);
|
||||
else
|
||||
error_msg_and_die("%s\n", msg);
|
||||
error_msg_and_die("%s", msg);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -470,13 +470,13 @@ getn(s)
|
||||
r = strtol(s, &p, 10);
|
||||
|
||||
if (errno != 0)
|
||||
error_msg_and_die("%s: out of range\n", s);
|
||||
error_msg_and_die("%s: out of range", s);
|
||||
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
|
||||
if (*p)
|
||||
error_msg_and_die("%s: bad number\n", s);
|
||||
error_msg_and_die("%s: bad number", s);
|
||||
|
||||
return (int) r;
|
||||
}
|
||||
|
||||
+8
-6
@@ -3,7 +3,7 @@
|
||||
* Mini touch implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,12 +22,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <utime.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int touch_main(int argc, char **argv)
|
||||
{
|
||||
@@ -42,13 +44,13 @@ extern int touch_main(int argc, char **argv)
|
||||
create = FALSE;
|
||||
break;
|
||||
default:
|
||||
usage(touch_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argc < 1) {
|
||||
usage(touch_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
while (argc > 0) {
|
||||
@@ -58,12 +60,12 @@ extern int touch_main(int argc, char **argv)
|
||||
if (create == FALSE && errno == ENOENT)
|
||||
return EXIT_SUCCESS;
|
||||
else {
|
||||
error_msg_and_die("%s", strerror(errno));
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
if (utime(*argv, NULL)) {
|
||||
error_msg_and_die("%s", strerror(errno));
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
+32
-19
@@ -24,24 +24,25 @@
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_write_error
|
||||
#include "messages.c"
|
||||
|
||||
#define ASCII 0377
|
||||
static const int ASCII = 0377;
|
||||
|
||||
/* some glabals shared across this file */
|
||||
static char com_fl, del_fl, sq_fl;
|
||||
static unsigned char output[BUFSIZ], input[BUFSIZ];
|
||||
static unsigned char vector[ASCII + 1];
|
||||
static char invec[ASCII + 1], outvec[ASCII + 1];
|
||||
static short in_index, out_index;
|
||||
/* these last are pointers to static buffers declared in tr_main */
|
||||
static unsigned char *poutput, *pinput;
|
||||
static unsigned char *pvector;
|
||||
static char *pinvec, *poutvec;
|
||||
|
||||
|
||||
static void convert()
|
||||
@@ -52,22 +53,22 @@ static void convert()
|
||||
|
||||
for (;;) {
|
||||
if (in_index == read_chars) {
|
||||
if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) {
|
||||
if (write(1, (char *) output, out_index) != out_index)
|
||||
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
|
||||
if (write(1, (char *) poutput, out_index) != out_index)
|
||||
write(2, write_error, strlen(write_error));
|
||||
exit(0);
|
||||
}
|
||||
in_index = 0;
|
||||
}
|
||||
c = input[in_index++];
|
||||
coded = vector[c];
|
||||
if (del_fl && invec[c])
|
||||
c = pinput[in_index++];
|
||||
coded = pvector[c];
|
||||
if (del_fl && pinvec[c])
|
||||
continue;
|
||||
if (sq_fl && last == coded && (invec[c] || outvec[coded]))
|
||||
if (sq_fl && last == coded && (pinvec[c] || poutvec[coded]))
|
||||
continue;
|
||||
output[out_index++] = last = coded;
|
||||
poutput[out_index++] = last = coded;
|
||||
if (out_index == BUFSIZ) {
|
||||
if (write(1, (char *) output, out_index) != out_index) {
|
||||
if (write(1, (char *) poutput, out_index) != out_index) {
|
||||
write(2, write_error, strlen(write_error));
|
||||
exit(1);
|
||||
}
|
||||
@@ -86,9 +87,9 @@ static void map(register unsigned char *string1, unsigned int string1_len,
|
||||
|
||||
for (j = 0, i = 0; i < string1_len; i++) {
|
||||
if (string2_len <= j)
|
||||
vector[string1[i]] = last;
|
||||
pvector[string1[i]] = last;
|
||||
else
|
||||
vector[string1[i]] = last = string2[j++];
|
||||
pvector[string1[i]] = last = string2[j++];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +144,18 @@ extern int tr_main(int argc, char **argv)
|
||||
int output_length=0, input_length;
|
||||
int index = 1;
|
||||
int i;
|
||||
RESERVE_BB_BUFFER(output, BUFSIZ);
|
||||
RESERVE_BB_BUFFER(input, BUFSIZ);
|
||||
RESERVE_BB_UBUFFER(vector, ASCII+1);
|
||||
RESERVE_BB_BUFFER(invec, ASCII+1);
|
||||
RESERVE_BB_BUFFER(outvec, ASCII+1);
|
||||
|
||||
/* ... but make them available globally */
|
||||
poutput = output;
|
||||
pinput = input;
|
||||
pvector = vector;
|
||||
pinvec = invec;
|
||||
poutvec = outvec;
|
||||
|
||||
if (argc > 1 && argv[index][0] == '-') {
|
||||
for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
|
||||
@@ -157,7 +170,7 @@ extern int tr_main(int argc, char **argv)
|
||||
sq_fl = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage(tr_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
index++;
|
||||
@@ -173,14 +186,14 @@ extern int tr_main(int argc, char **argv)
|
||||
input_length = complement(input, input_length);
|
||||
if (argv[index] != NULL) {
|
||||
if (*argv[index] == '\0')
|
||||
error_msg_and_die("STRING2 cannot be empty\n");
|
||||
error_msg_and_die("STRING2 cannot be empty");
|
||||
output_length = expand(argv[index], output);
|
||||
map(input, input_length, output, output_length);
|
||||
}
|
||||
for (i = 0; i < input_length; i++)
|
||||
invec[input[i]] = TRUE;
|
||||
invec[(int)input[i]] = TRUE;
|
||||
for (i = 0; i < output_length; i++)
|
||||
outvec[output[i]] = TRUE;
|
||||
outvec[(int)output[i]] = TRUE;
|
||||
}
|
||||
convert();
|
||||
return (0);
|
||||
|
||||
+4
-2
@@ -20,9 +20,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int tty_main(int argc, char **argv)
|
||||
{
|
||||
@@ -30,7 +32,7 @@ extern int tty_main(int argc, char **argv)
|
||||
|
||||
if (argc > 1) {
|
||||
if (argv[1][0] != '-' || argv[1][1] != 's')
|
||||
usage(tty_usage);
|
||||
show_usage();
|
||||
} else {
|
||||
tty = ttyname(0);
|
||||
if (tty)
|
||||
|
||||
+12
-10
@@ -31,35 +31,37 @@
|
||||
|
||||
/* Busyboxed by Erik Andersen */
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#if defined (HAVE_SYSINFO) && defined (HAVE_SYS_SYSTEMINFO_H)
|
||||
# include <sys/systeminfo.h>
|
||||
#endif
|
||||
#include "busybox.h"
|
||||
|
||||
static void print_element(unsigned int mask, char *element);
|
||||
|
||||
/* Values that are bitwise or'd into `toprint'. */
|
||||
/* Operating system name. */
|
||||
#define PRINT_SYSNAME 1
|
||||
static const int PRINT_SYSNAME = 1;
|
||||
|
||||
/* Node name on a communications network. */
|
||||
#define PRINT_NODENAME 2
|
||||
static const int PRINT_NODENAME = 2;
|
||||
|
||||
/* Operating system release. */
|
||||
#define PRINT_RELEASE 4
|
||||
static const int PRINT_RELEASE = 4;
|
||||
|
||||
/* Operating system version. */
|
||||
#define PRINT_VERSION 8
|
||||
static const int PRINT_VERSION = 8;
|
||||
|
||||
/* Machine hardware name. */
|
||||
#define PRINT_MACHINE 16
|
||||
static const int PRINT_MACHINE = 16;
|
||||
|
||||
/* Host processor type. */
|
||||
#define PRINT_PROCESSOR 32
|
||||
static const int PRINT_PROCESSOR = 32;
|
||||
|
||||
/* Mask indicating which elements of the name to print. */
|
||||
static unsigned char toprint;
|
||||
@@ -105,7 +107,7 @@ int uname_main(int argc, char **argv)
|
||||
PRINT_MACHINE);
|
||||
break;
|
||||
default:
|
||||
usage(uname_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,11 +116,11 @@ int uname_main(int argc, char **argv)
|
||||
toprint = PRINT_SYSNAME;
|
||||
|
||||
if (uname(&name) == -1)
|
||||
perror("cannot get system name");
|
||||
perror_msg("cannot get system name");
|
||||
|
||||
#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE)
|
||||
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
|
||||
perror("cannot get processor type");
|
||||
perror_msg("cannot get processor type");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
+4
-2
@@ -3,7 +3,7 @@
|
||||
* Mini uniq implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Rewritten by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
@@ -23,10 +23,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int print_count;
|
||||
static int print_uniq = 1;
|
||||
|
||||
+2
-2
@@ -21,14 +21,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int usleep_main(int argc, char **argv)
|
||||
{
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(usleep_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
usleep(atoi(*(++argv))); /* return void */
|
||||
|
||||
+18
-15
@@ -22,12 +22,15 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <pwd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include "pwd_grp/pwd.h"
|
||||
#include "pwd_grp/grp.h"
|
||||
|
||||
/*struct passwd *getpwnam();*/
|
||||
|
||||
@@ -43,7 +46,7 @@ static int read_stduu (const char *inname)
|
||||
char *p;
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL) {
|
||||
error_msg("%s: Short file\n", inname);
|
||||
error_msg("%s: Short file", inname);
|
||||
return FALSE;
|
||||
}
|
||||
p = buf;
|
||||
@@ -78,7 +81,7 @@ static int read_stduu (const char *inname)
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL
|
||||
|| strcmp (buf, "end\n")) {
|
||||
error_msg("%s: No `end' line\n", inname);
|
||||
error_msg("%s: No `end' line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -128,7 +131,7 @@ static int read_base64 (const char *inname)
|
||||
unsigned char *p;
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL) {
|
||||
error_msg("%s: Short file\n", inname);
|
||||
error_msg("%s: Short file", inname);
|
||||
return FALSE;
|
||||
}
|
||||
p = buf;
|
||||
@@ -136,7 +139,7 @@ static int read_base64 (const char *inname)
|
||||
if (memcmp (buf, "====", 4) == 0)
|
||||
break;
|
||||
if (last_data != 0) {
|
||||
error_msg("%s: data following `=' padding character\n", inname);
|
||||
error_msg("%s: data following `=' padding character", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -158,14 +161,14 @@ static int read_base64 (const char *inname)
|
||||
|
||||
while ((b64_tab[*p] & '\100') != 0)
|
||||
if (*p == '\n' || *p++ == '=') {
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
c2 = b64_tab[*p++];
|
||||
|
||||
while (b64_tab[*p] == '\177')
|
||||
if (*p++ == '\n') {
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
if (*p == '=') {
|
||||
@@ -177,7 +180,7 @@ static int read_base64 (const char *inname)
|
||||
|
||||
while (b64_tab[*p] == '\177')
|
||||
if (*p++ == '\n') {
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
putchar (c1 << 2 | c2 >> 4);
|
||||
@@ -209,7 +212,7 @@ static int decode (const char *inname,
|
||||
|
||||
while (1) {
|
||||
if (fgets (buf, sizeof (buf), stdin) == NULL) {
|
||||
error_msg("%s: No `begin' line\n", inname);
|
||||
error_msg("%s: No `begin' line", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -234,13 +237,13 @@ static int decode (const char *inname,
|
||||
while (*p != '/')
|
||||
++p;
|
||||
if (*p == '\0') {
|
||||
error_msg("%s: Illegal ~user\n", inname);
|
||||
error_msg("%s: Illegal ~user", inname);
|
||||
return FALSE;
|
||||
}
|
||||
*p++ = '\0';
|
||||
pw = getpwnam (buf + 1);
|
||||
if (pw == NULL) {
|
||||
error_msg("%s: No user `%s'\n", inname, buf + 1);
|
||||
error_msg("%s: No user `%s'", inname, buf + 1);
|
||||
return FALSE;
|
||||
}
|
||||
n = strlen (pw->pw_dir);
|
||||
@@ -257,7 +260,7 @@ static int decode (const char *inname,
|
||||
&& (freopen (outname, "w", stdout) == NULL
|
||||
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
|
||||
)) {
|
||||
error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
|
||||
perror_msg("%s", outname); /* */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -289,7 +292,7 @@ int uudecode_main (int argc,
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(uudecode_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +305,7 @@ int uudecode_main (int argc,
|
||||
if (decode (argv[optind], outname) != 0)
|
||||
exit_status = FALSE;
|
||||
} else {
|
||||
error_msg("%s: %s\n", argv[optind], strerror(errno));
|
||||
perror_msg("%s", argv[optind]);
|
||||
exit_status = EXIT_FAILURE;
|
||||
}
|
||||
optind++;
|
||||
|
||||
+11
-14
@@ -22,23 +22,23 @@
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt */
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <pwd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
|
||||
|
||||
static void encode __P ((void));
|
||||
|
||||
/* Pointer to the translation table we currently use. */
|
||||
const char *trans_ptr;
|
||||
static const char *trans_ptr;
|
||||
|
||||
/* The two currently defined translation tables. The first is the
|
||||
standard uuencoding, the second is base64 encoding. */
|
||||
const char uu_std[64] = {
|
||||
static const char uu_std[64] = {
|
||||
'`', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
@@ -49,7 +49,7 @@ const char uu_std[64] = {
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
|
||||
};
|
||||
|
||||
const char uu_base64[64] = {
|
||||
static const char uu_base64[64] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
@@ -142,7 +142,7 @@ static void encode()
|
||||
}
|
||||
|
||||
if (ferror (stdin))
|
||||
error_msg("Read error\n");
|
||||
error_msg("Read error");
|
||||
|
||||
if (trans_ptr == uu_std) {
|
||||
putchar (ENC ('\0'));
|
||||
@@ -160,17 +160,14 @@ int uuencode_main (int argc,
|
||||
trans_ptr = uu_std; /* Standard encoding is old uu format */
|
||||
|
||||
/* Parse any options */
|
||||
while ((opt = getopt (argc, argv, "m")) != EOF) {
|
||||
while ((opt = getopt (argc, argv, "m")) > 0) {
|
||||
switch (opt) {
|
||||
case 'm':
|
||||
trans_ptr = uu_base64;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(uuencode_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +175,7 @@ int uuencode_main (int argc,
|
||||
case 2:
|
||||
/* Optional first argument is input file. */
|
||||
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
|
||||
error_msg("%s: %s\n", argv[optind], strerror(errno));
|
||||
perror_msg("%s", argv[optind]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
@@ -191,7 +188,7 @@ int uuencode_main (int argc,
|
||||
|
||||
case 0:
|
||||
default:
|
||||
usage(uuencode_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
printf("begin%s %o %s\n", trans_ptr == uu_std ? "" : "-base64",
|
||||
@@ -199,7 +196,7 @@ int uuencode_main (int argc,
|
||||
encode();
|
||||
printf(trans_ptr == uu_std ? "end\n" : "====\n");
|
||||
if (ferror (stdout)) {
|
||||
error_msg("Write error\n");
|
||||
error_msg("Write error");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+6
-4
@@ -20,15 +20,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int total_lines, total_words, total_chars, max_length;
|
||||
static int print_lines, print_words, print_chars, print_length;
|
||||
|
||||
void print_counts(int lines, int words, int chars, int length,
|
||||
const char *name)
|
||||
static void print_counts(int lines, int words, int chars, int length,
|
||||
const char *name)
|
||||
{
|
||||
char const *space = "";
|
||||
|
||||
@@ -125,7 +127,7 @@ int wc_main(int argc, char **argv)
|
||||
print_words = 1;
|
||||
break;
|
||||
default:
|
||||
usage(wc_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -20,9 +20,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int whoami_main(int argc, char **argv)
|
||||
{
|
||||
@@ -30,12 +33,12 @@ extern int whoami_main(int argc, char **argv)
|
||||
uid_t uid = geteuid();
|
||||
|
||||
if (argc > 1)
|
||||
usage(whoami_usage);
|
||||
show_usage();
|
||||
|
||||
my_getpwuid(user, uid);
|
||||
if (*user) {
|
||||
puts(user);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
error_msg_and_die("cannot find username for UID %u\n", (unsigned) uid);
|
||||
error_msg_and_die("cannot find username for UID %u", (unsigned) uid);
|
||||
}
|
||||
+5
-2
@@ -20,15 +20,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int yes_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc >= 2 && *argv[1] == '-')
|
||||
usage(yes_usage);
|
||||
show_usage();
|
||||
|
||||
if (argc == 1) {
|
||||
while (1)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini `cp' and `mv' implementation for BusyBox.
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Copyright (C) 2000 by BitterSweet Enterprises, LLC. (GPL)
|
||||
@@ -25,13 +25,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#define bb_need_omitting_directory
|
||||
#define bb_need_not_a_directory
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
@@ -42,16 +35,19 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#define bb_need_omitting_directory
|
||||
#define bb_need_not_a_directory
|
||||
#include "messages.c"
|
||||
|
||||
#define is_cp 0
|
||||
#define is_mv 1
|
||||
|
||||
static const int is_cp = 0;
|
||||
static const int is_mv = 1;
|
||||
static int dz_i; /* index into cp_mv_usage */
|
||||
|
||||
static const char *cp_mv_usage[] = /* .rodata */
|
||||
{
|
||||
cp_usage,
|
||||
mv_usage
|
||||
};
|
||||
|
||||
static int recursiveFlag;
|
||||
static int followLinks;
|
||||
@@ -62,7 +58,7 @@ static const char *baseSrcName;
|
||||
static int srcDirFlag;
|
||||
static struct stat srcStatBuf;
|
||||
|
||||
static char baseDestName[BUFSIZ + 1];
|
||||
static char *pBaseDestName;
|
||||
static size_t baseDestLen;
|
||||
static int destDirFlag;
|
||||
static struct stat destStatBuf;
|
||||
@@ -104,7 +100,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
const char *srcBasename;
|
||||
char *name;
|
||||
|
||||
strcpy(destName, baseDestName);
|
||||
strcpy(destName, pBaseDestName);
|
||||
destLen = strlen(destName);
|
||||
|
||||
if (srcDirFlag == TRUE) {
|
||||
@@ -130,8 +126,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
if (mv_Action_first_time && (dz_i == is_mv)) {
|
||||
mv_Action_first_time = errno = 0;
|
||||
if (rename(fileName, destName) < 0 && errno != EXDEV) {
|
||||
error_msg("rename(%s, %s): %s\n", fileName, destName,
|
||||
strerror(errno));
|
||||
perror_msg("rename(%s, %s)", fileName, destName);
|
||||
goto do_copyFile; /* Try anyway... */
|
||||
}
|
||||
else if (errno == EXDEV)
|
||||
@@ -143,7 +138,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
|
||||
if (is_in_ino_dev_hashtable(statbuf, &name)) {
|
||||
if (link(name, destName) < 0) {
|
||||
error_msg("link(%s, %s): %s\n", name, destName, strerror(errno));
|
||||
perror_msg("link(%s, %s)", name, destName);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -162,11 +157,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
if (S_ISDIR(statbuf->st_mode)) {
|
||||
if (rmdir(fileName) < 0) {
|
||||
error_msg("rmdir(%s): %s\n", fileName, strerror(errno));
|
||||
perror_msg("rmdir(%s)", fileName);
|
||||
status = FALSE;
|
||||
}
|
||||
} else if (unlink(fileName) < 0) {
|
||||
error_msg("unlink(%s): %s\n", fileName, strerror(errno));
|
||||
perror_msg("unlink(%s)", fileName);
|
||||
status = FALSE;
|
||||
}
|
||||
return status;
|
||||
@@ -176,13 +171,15 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
{
|
||||
volatile int i;
|
||||
int c;
|
||||
RESERVE_BB_BUFFER(baseDestName,BUFSIZ + 1);
|
||||
pBaseDestName = baseDestName; /* available globally */
|
||||
|
||||
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
|
||||
dz_i = is_cp;
|
||||
else
|
||||
dz_i = is_mv;
|
||||
if (argc < 3)
|
||||
usage(cp_mv_usage[dz_i]);
|
||||
show_usage();
|
||||
|
||||
if (dz_i == is_cp) {
|
||||
recursiveFlag = preserveFlag = forceFlag = FALSE;
|
||||
@@ -207,11 +204,11 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
forceFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage(cp_mv_usage[is_cp]);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
if ((argc - optind) < 2) {
|
||||
usage(cp_mv_usage[dz_i]);
|
||||
show_usage();
|
||||
}
|
||||
} else { /* (dz_i == is_mv) */
|
||||
/* Initialize optind to 1, since in libc5 optind
|
||||
@@ -260,27 +257,27 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
char *pushd, *d, *p;
|
||||
|
||||
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
|
||||
error_msg("getcwd(): %s\n", strerror(errno));
|
||||
perror_msg("getcwd()");
|
||||
continue;
|
||||
}
|
||||
if (chdir(baseDestName) < 0) {
|
||||
error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno));
|
||||
perror_msg("chdir(%s)", baseSrcName);
|
||||
continue;
|
||||
}
|
||||
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
|
||||
error_msg("getcwd(): %s\n", strerror(errno));
|
||||
perror_msg("getcwd()");
|
||||
continue;
|
||||
}
|
||||
while (!state && *d != '\0') {
|
||||
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
|
||||
error_msg("stat(%s): %s\n", d, strerror(errno));
|
||||
perror_msg("stat(%s)", d);
|
||||
state = -1;
|
||||
continue;
|
||||
}
|
||||
if ((sb.st_ino == srcStatBuf.st_ino) &&
|
||||
(sb.st_dev == srcStatBuf.st_dev)) {
|
||||
error_msg("Cannot %s `%s' into a subdirectory of itself, "
|
||||
"`%s/%s'\n", applet_name, baseSrcName,
|
||||
"`%s/%s'", applet_name, baseSrcName,
|
||||
baseDestName, baseSrcName);
|
||||
state = -1;
|
||||
continue;
|
||||
@@ -290,7 +287,7 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
if (chdir(pushd) < 0) {
|
||||
error_msg("chdir(%s): %s\n", pushd, strerror(errno));
|
||||
perror_msg("chdir(%s)", pushd);
|
||||
free(pushd);
|
||||
free(d);
|
||||
continue;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@enol.com>
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -54,12 +54,12 @@ static void decompose_list(const char *list)
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ static void decompose_list(const char *list)
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
error_msg_and_die("missing list of fields\n");
|
||||
error_msg_and_die("missing list of fields");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ extern int cut_main(int argc, char **argv)
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character\n");
|
||||
error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
@@ -209,16 +209,17 @@ extern int cut_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense
|
||||
only when operating on fields\n");
|
||||
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\n");
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields");
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
@@ -233,7 +234,7 @@ extern int cut_main(int argc, char **argv)
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
error_msg("%s: %s\n", argv[i], strerror(errno));
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
|
||||
@@ -20,18 +20,19 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_date
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_date
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
|
||||
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
@@ -45,7 +46,7 @@
|
||||
|
||||
/* Default input handling to save suprising some people */
|
||||
|
||||
struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
int nr;
|
||||
|
||||
@@ -72,7 +73,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
|
||||
/* The new stuff for LRP */
|
||||
|
||||
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
struct tm t;
|
||||
|
||||
@@ -150,7 +151,7 @@ int date_main(int argc, char **argv)
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
@@ -161,10 +162,10 @@ int date_main(int argc, char **argv)
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +178,7 @@ int date_main(int argc, char **argv)
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "busybox.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
|
||||
|
||||
@@ -14,14 +15,14 @@ static unsigned int pointer;
|
||||
static void push(double a)
|
||||
{
|
||||
if (pointer >= (sizeof(stack) / sizeof(*stack)))
|
||||
error_msg_and_die("stack overflow\n");
|
||||
error_msg_and_die("stack overflow");
|
||||
stack[pointer++] = a;
|
||||
}
|
||||
|
||||
static double pop()
|
||||
{
|
||||
if (pointer == 0)
|
||||
error_msg_and_die("stack underflow\n");
|
||||
error_msg_and_die("stack underflow");
|
||||
return stack[--pointer];
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ static void stack_machine(const char *argument)
|
||||
}
|
||||
o++;
|
||||
}
|
||||
error_msg_and_die("%s: syntax error.\n", argument);
|
||||
error_msg_and_die("%s: syntax error.", argument);
|
||||
}
|
||||
|
||||
/* return pointer to next token in buffer and set *buffer to one char
|
||||
@@ -169,7 +170,7 @@ int dc_main(int argc, char **argv)
|
||||
}
|
||||
} else {
|
||||
if (*argv[1]=='-')
|
||||
usage(dc_usage);
|
||||
show_usage();
|
||||
while (argc >= 2) {
|
||||
stack_machine(argv[1]);
|
||||
argv++;
|
||||
|
||||
@@ -2,15 +2,8 @@
|
||||
/*
|
||||
* Mini dd implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999, 2000 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Based in part on code taken from sash.
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Permission to distribute this code under the GPL has been granted.
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,154 +21,138 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
#include <features.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
typedef unsigned long long int uintmax_t;
|
||||
#endif
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dd_main(int argc, char **argv)
|
||||
|
||||
static const struct suffix_mult dd_suffixes[] = {
|
||||
{ "c", 1 },
|
||||
{ "w", 2 },
|
||||
{ "b", 512 },
|
||||
{ "kD", 1000 },
|
||||
{ "k", 1024 },
|
||||
{ "MD", 1000000 },
|
||||
{ "M", 1048576 },
|
||||
{ "GD", 1000000000 },
|
||||
{ "G", 1073741824 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
char *inFile = NULL;
|
||||
char *outFile = NULL;
|
||||
int inFd;
|
||||
int outFd;
|
||||
int inCc = 0;
|
||||
int outCc;
|
||||
int trunc=TRUE;
|
||||
int sync=FALSE;
|
||||
long blockSize = 512,ibs;
|
||||
uintmax_t skipBlocks = 0;
|
||||
uintmax_t seekBlocks = 0;
|
||||
uintmax_t count = (uintmax_t) - 1;
|
||||
uintmax_t inTotal = 0;
|
||||
uintmax_t outTotal = 0;
|
||||
uintmax_t totalSize;
|
||||
int i, ifd, ofd, oflag, sync = FALSE, trunc = TRUE;
|
||||
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
|
||||
size_t bs = 512, count = -1;
|
||||
ssize_t n;
|
||||
off_t seek = 0, skip = 0;
|
||||
FILE *statusfp;
|
||||
char *infile = NULL, *outfile = NULL, *buf;
|
||||
|
||||
unsigned char buf[BUFSIZ];
|
||||
char *keyword = NULL;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strncmp("bs=", argv[i], 3) == 0)
|
||||
bs = parse_number(argv[i]+3, dd_suffixes);
|
||||
else if (strncmp("count=", argv[i], 6) == 0)
|
||||
count = parse_number(argv[i]+6, dd_suffixes);
|
||||
else if (strncmp("seek=", argv[i], 5) == 0)
|
||||
seek = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("skip=", argv[i], 5) == 0)
|
||||
skip = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("if=", argv[i], 3) == 0)
|
||||
infile = argv[i]+3;
|
||||
else if (strncmp("of=", argv[i], 3) == 0)
|
||||
outfile = argv[i]+3;
|
||||
else if (strncmp("conv=", argv[i], 5) == 0) {
|
||||
buf = argv[i]+5;
|
||||
while (1) {
|
||||
if (strncmp("notrunc", buf, 7) == 0) {
|
||||
trunc = FALSE;
|
||||
buf += 7;
|
||||
} else if (strncmp("sync", buf, 4) == 0) {
|
||||
sync = TRUE;
|
||||
buf += 4;
|
||||
} else {
|
||||
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
|
||||
}
|
||||
if (buf[0] == '\0')
|
||||
break;
|
||||
if (buf[0] == ',')
|
||||
buf++;
|
||||
}
|
||||
} else
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
buf = xmalloc(bs);
|
||||
|
||||
/* Parse any options */
|
||||
while (argc) {
|
||||
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
|
||||
inFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
|
||||
outFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (strncmp("count", *argv, 5) == 0) {
|
||||
count = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (count < 0) {
|
||||
error_msg("Bad count value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "bs", 2) == 0) {
|
||||
blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (blockSize <= 0) {
|
||||
error_msg("Bad block size value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "skip", 4) == 0) {
|
||||
skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (skipBlocks <= 0) {
|
||||
error_msg("Bad skip value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
if (infile != NULL) {
|
||||
if ((ifd = open(infile, O_RDONLY)) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
} else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = "standard input";
|
||||
}
|
||||
|
||||
} else if (strncmp(*argv, "seek", 4) == 0) {
|
||||
seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (seekBlocks <= 0) {
|
||||
error_msg("Bad seek value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "conv", 4) == 0) {
|
||||
keyword = (strchr(*argv, '=') + 1);
|
||||
if (strcmp(keyword, "notrunc") == 0)
|
||||
trunc=FALSE;
|
||||
if (strcmp(keyword, "sync") == 0)
|
||||
sync=TRUE;
|
||||
} else {
|
||||
goto usage;
|
||||
if (outfile != NULL) {
|
||||
oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
if (!seek && trunc)
|
||||
oflag |= O_TRUNC;
|
||||
|
||||
if ((ofd = open(outfile, oflag, 0666)) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
|
||||
if (seek && trunc) {
|
||||
if (ftruncate(ofd, seek * bs) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
statusfp = stdout;
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
statusfp = stderr;
|
||||
}
|
||||
|
||||
if (inFile == NULL)
|
||||
inFd = fileno(stdin);
|
||||
else
|
||||
inFd = open(inFile, 0);
|
||||
|
||||
if (inFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* free(buf); */
|
||||
perror_msg_and_die("%s", inFile);
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
outFd = fileno(stdout);
|
||||
else
|
||||
outFd = open(outFile, O_WRONLY | O_CREAT, 0666);
|
||||
|
||||
if (outFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* close(inFd);
|
||||
free(buf); */
|
||||
perror_msg_and_die("%s", outFile);
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
|
||||
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
|
||||
totalSize=count*blockSize;
|
||||
|
||||
ibs=blockSize;
|
||||
if (ibs > BUFSIZ)
|
||||
ibs=BUFSIZ;
|
||||
|
||||
while (totalSize > outTotal) {
|
||||
inCc = full_read(inFd, buf, ibs);
|
||||
inTotal += inCc;
|
||||
if ( (sync==TRUE) && (inCc>0) )
|
||||
while (inCc<ibs)
|
||||
buf[inCc++]='\0';
|
||||
|
||||
if ((outCc = full_write(outFd, buf, inCc)) < 1){
|
||||
if (outCc < 0 ){
|
||||
perror("Error during write");
|
||||
}
|
||||
while (in_full + in_part != count) {
|
||||
n = safe_read(ifd, buf, bs);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (n == bs)
|
||||
in_full++;
|
||||
else
|
||||
in_part++;
|
||||
if (sync) {
|
||||
memset(buf + n, '\0', bs - n);
|
||||
n = bs;
|
||||
}
|
||||
outTotal += outCc;
|
||||
}
|
||||
if (trunc == TRUE) {
|
||||
ftruncate(outFd, lseek(outFd, 0, SEEK_CUR));
|
||||
n = full_write(ofd, buf, n);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (n == bs)
|
||||
out_full++;
|
||||
else
|
||||
out_part++;
|
||||
}
|
||||
/* Note that we are not freeing memory or closing
|
||||
* files here, to save a few bytes. */
|
||||
#ifdef BB_FEATURE_CLEAN_UP
|
||||
close(inFd);
|
||||
close(outFd);
|
||||
#endif
|
||||
|
||||
printf("%ld+%d records in\n", (long) (inTotal / blockSize),
|
||||
(inTotal % blockSize) != 0);
|
||||
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
|
||||
(outTotal % blockSize) != 0);
|
||||
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
|
||||
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
usage:
|
||||
|
||||
usage(dd_usage);
|
||||
}
|
||||
+12
-17
@@ -3,15 +3,15 @@
|
||||
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
|
||||
* Renamed deallocvt.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
|
||||
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
@@ -19,30 +19,25 @@ int deallocvt_main(int argc, char *argv[])
|
||||
|
||||
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
|
||||
if (argc > 2)
|
||||
usage(deallocvt_usage);
|
||||
show_usage();
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
if (argc == 1) {
|
||||
printf("erik: A\n");
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else
|
||||
printf("erik: B\n");
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
error_msg("0: illegal VT number\n");
|
||||
error_msg("0: illegal VT number");
|
||||
else if (num == 1)
|
||||
error_msg("VT 1 cannot be deallocated\n");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
error_msg_and_die("could not deallocate console %d\n", num);
|
||||
}
|
||||
error_msg("VT 1 cannot be deallocated");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
printf("erik: C\n");
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Vendored
+207
-117
@@ -14,141 +14,147 @@
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
#define BB_CMP
|
||||
//#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
//#define BB_DC
|
||||
#define BB_DD
|
||||
#define BB_DEALLOCVT
|
||||
//#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
#define BB_DOS2UNIX
|
||||
#define BB_DUTMP
|
||||
//#define BB_DOS2UNIX
|
||||
//#define BB_DPKG
|
||||
//#define BB_DPKG_DEB
|
||||
//#define BB_DUTMP
|
||||
#define BB_DU
|
||||
#define BB_DUMPKMAP
|
||||
//#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
#define BB_FBSET
|
||||
#define BB_FDFLUSH
|
||||
//#define BB_EXPR
|
||||
//#define BB_FBSET
|
||||
//#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FREE
|
||||
#define BB_FREERAMDISK
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
//#define BB_FREERAMDISK
|
||||
//#define BB_FSCK_MINIX
|
||||
//#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
//#define BB_HOSTID
|
||||
//#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_IFCONFIG
|
||||
#define BB_INIT
|
||||
#define BB_INSMOD
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_LENGTH
|
||||
#define BB_KLOGD
|
||||
//#define BB_LENGTH
|
||||
#define BB_LN
|
||||
#define BB_LOADACM
|
||||
#define BB_LOADFONT
|
||||
//#define BB_LOADACM
|
||||
//#define BB_LOADFONT
|
||||
#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
//#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
#define BB_MAKEDEVS
|
||||
//#define BB_MAKEDEVS
|
||||
#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
//#define BB_MKFIFO
|
||||
//#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
//#define BB_MKTEMP
|
||||
//#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
//#define BB_MT
|
||||
//#define BB_NSLOOKUP
|
||||
#define BB_PING
|
||||
//#define BB_PIVOT_ROOT
|
||||
#define BB_POWEROFF
|
||||
#define BB_PRINTF
|
||||
//#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
#define BB_READLINK
|
||||
//#define BB_RDATE
|
||||
//#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
#define BB_RENICE
|
||||
//#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
#define BB_RMMOD
|
||||
#define BB_RPMUNPACK
|
||||
//#define BB_RMMOD
|
||||
//#define BB_ROUTE
|
||||
//#define BB_RPMUNPACK
|
||||
#define BB_SED
|
||||
#define BB_SETKEYCODES
|
||||
//#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_STTY
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_SYSLOGD
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
//#define BB_TEE
|
||||
//#define BB_TEST
|
||||
#define BB_TELNET
|
||||
//#define BB_TFTP
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
//#define BB_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
//#define BB_UPDATE
|
||||
#define BB_UPTIME
|
||||
#define BB_USLEEP
|
||||
//#define BB_USLEEP
|
||||
//#define BB_WATCHDOG
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
#define BB_UNIX2DOS
|
||||
#define BB_UPDATE
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
// BusyBox will, by default, malloc space for its buffers. This costs code
|
||||
// size for the call to xmalloc. You can use the following feature to have
|
||||
// them put on the stack. For some very small machines with limited stack
|
||||
// space, this can be deadly. For most folks, this works just fine...
|
||||
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// lots and lots memory for more important things. NOTE: If you enable this
|
||||
// feature, you _must_ have patched the kernel to include the devps patch that
|
||||
// is included in the busybox/kernel-patches directory. You will also need to
|
||||
// create some device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
@@ -156,7 +162,7 @@
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
// show username/groupnames for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
@@ -186,22 +192,17 @@
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
// enable syslogd -C
|
||||
//#define BB_FEATURE_IPC_SYSLOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
@@ -219,6 +220,9 @@
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// use -i (interactive) flag for rm
|
||||
//#define BB_FEATURE_RM_INTERACTIVE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
@@ -231,12 +235,21 @@
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
// Enable command line editing in the shell.
|
||||
// Only relevant if BB_SH is enabled. On by default.
|
||||
#define BB_FEATURE_COMMAND_EDITING
|
||||
//
|
||||
// Enable tab completion in the shell. This is now working quite nicely.
|
||||
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
//
|
||||
// Attempts to match usernames in a ~-prefixed path
|
||||
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things.
|
||||
//among other things. Off by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell applets can be called using full path
|
||||
@@ -245,11 +258,15 @@
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
// Only relevant if BB_SH is enabled. Off by default.
|
||||
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
// Some deeply embedded systems don't have usernames or even hostnames,
|
||||
// and the default prompt can look rather hideous on them. Uncomment
|
||||
// this option for a simpler, path-only prompt (which was the default until
|
||||
// around BusyBox-0.48). On by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
@@ -257,17 +274,11 @@
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
// Support insmod/lsmod/rmmod for post 2.1 kernels
|
||||
//#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support modules status from pre 2.1 kernels
|
||||
//#define BB_FEATURE_LSMOD_OLD_KERNEL
|
||||
// Support modules status from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_LSMOD_NEW_KERNEL
|
||||
// Support insmod/lsmod/rmmod for pre 2.1 kernels
|
||||
//#define BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
@@ -275,20 +286,53 @@
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
// Enable ifconfig status reporting output -- this feature adds 12k.
|
||||
#define BB_FEATURE_IFCONFIG_STATUS
|
||||
//
|
||||
// Enable ifconfig slip-specific options "keepalive" and "outfill"
|
||||
//#define BB_FEATURE_IFCONFIG_SLIP
|
||||
//
|
||||
// Enable ifconfig options "mem_start", "io_addr", and "irq".
|
||||
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
|
||||
//
|
||||
// Enable ifconfig option "hw". Currently works for only with "ether".
|
||||
//#define BB_FEATURE_IFCONFIG_HW
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
#define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
//#define BB_FEATURE_STATUSBAR
|
||||
#define BB_FEATURE_WGET_STATUSBAR
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
|
||||
#define BB_FEATURE_HUMAN_READABLE
|
||||
//
|
||||
// Support for the find -type option.
|
||||
#define BB_FEATURE_FIND_TYPE
|
||||
//
|
||||
// Support for the find -perm option.
|
||||
#define BB_FEATURE_FIND_PERM
|
||||
//
|
||||
// Support for the find -mtine option.
|
||||
#define BB_FEATURE_FIND_MTIME
|
||||
//
|
||||
// Support for the -A -B and -C context flags in grep
|
||||
//#define BB_FEATURE_GREP_CONTEXT
|
||||
//
|
||||
// Support for the EGREP applet (alias to the grep applet)
|
||||
//#define BB_FEATURE_GREP_EGREP_ALIAS
|
||||
//
|
||||
// Tell tftp what commands that should be supported.
|
||||
#define BB_FEATURE_TFTP_PUT
|
||||
#define BB_FEATURE_TFTP_GET
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
@@ -300,59 +344,105 @@
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#else
|
||||
#undef BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG
|
||||
#ifndef BB_DPKG_DEB
|
||||
#define BB_DPKG_DEB
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG_DEB
|
||||
#ifndef BB_AR
|
||||
#define BB_AR
|
||||
#endif
|
||||
#ifndef BB_TAR
|
||||
#define BB_TAR
|
||||
#endif
|
||||
#ifndef BB_FEATURE_TAR_GZIP
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
#if defined BB_IFCONFIG
|
||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||
#define BB_INTERFACE
|
||||
#endif
|
||||
#else
|
||||
#undef BB_INTERFACE
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_SYSLOGD
|
||||
#if defined BB_FEATURE_IPC_SYSLOG
|
||||
#define BB_LOGREAD
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_DOS2UNIX
|
||||
#define BB_UNIX2DOS
|
||||
#endif
|
||||
Vendored
+448
@@ -0,0 +1,448 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
#define BB_DD
|
||||
#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
#define BB_DOS2UNIX
|
||||
#define BB_DPKG
|
||||
#define BB_DPKG_DEB
|
||||
#define BB_DUTMP
|
||||
#define BB_DU
|
||||
#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
#define BB_FBSET
|
||||
#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FREE
|
||||
#define BB_FREERAMDISK
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
#define BB_IFCONFIG
|
||||
#define BB_INIT
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_KLOGD
|
||||
#define BB_LENGTH
|
||||
#define BB_LN
|
||||
#define BB_LOADACM
|
||||
#define BB_LOADFONT
|
||||
#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
#define BB_MAKEDEVS
|
||||
#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
#define BB_PING
|
||||
#define BB_PIVOT_ROOT
|
||||
#define BB_POWEROFF
|
||||
#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
#define BB_RMMOD
|
||||
#define BB_ROUTE
|
||||
#define BB_RPMUNPACK
|
||||
#define BB_SED
|
||||
#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
#define BB_STTY
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_SYSLOGD
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
#define BB_TELNET
|
||||
#define BB_TFTP
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
#define BB_UPDATE
|
||||
#define BB_UPTIME
|
||||
#define BB_USLEEP
|
||||
#define BB_WATCHDOG
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
// BusyBox will, by default, malloc space for its buffers. This costs code
|
||||
// size for the call to xmalloc. You can use the following feature to have
|
||||
// them put on the stack. For some very small machines with limited stack
|
||||
// space, this can be deadly. For most folks, this works just fine...
|
||||
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. NOTE: If you enable this
|
||||
// feature, you _must_ have patched the kernel to include the devps patch that
|
||||
// is included in the busybox/kernel-patches directory. You will also need to
|
||||
// create some device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// enable ls -L
|
||||
#define BB_FEATURE_LS_FOLLOWLINKS
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
//#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
// enable syslogd -C
|
||||
//#define BB_FEATURE_IPC_SYSLOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// You may need to mount with "-o nolock" if you are
|
||||
// not running a local portmapper daemon...
|
||||
#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// use -i (interactive) flag for rm
|
||||
//#define BB_FEATURE_RM_INTERACTIVE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" and "-X" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
// Enable support for tar -z option (currently only works for inflating)
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell.
|
||||
// Only relevant if BB_SH is enabled. On by default.
|
||||
#define BB_FEATURE_COMMAND_EDITING
|
||||
//
|
||||
// Enable tab completion in the shell. This is now working quite nicely.
|
||||
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
//
|
||||
// Attempts to match usernames in a ~-prefixed path
|
||||
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things. Off by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell applets can be called using full path
|
||||
//names. This causes applets (i.e., most busybox commands) to override
|
||||
//real commands on the filesystem. For example, if you run run /bin/cat, it
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
// Only relevant if BB_SH is enabled. Off by default.
|
||||
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Some deeply embedded systems don't have usernames or even hostnames,
|
||||
// and the default prompt can look rather hideous on them. Uncomment
|
||||
// this option for a simpler, path-only prompt (which was the default until
|
||||
// around BusyBox-0.48). On by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// Support insmod/lsmod/rmmod for post 2.1 kernels
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
//
|
||||
// Support insmod/lsmod/rmmod for pre 2.1 kernels
|
||||
//#define BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
// Enable ifconfig status reporting output -- this feature adds 12k.
|
||||
#define BB_FEATURE_IFCONFIG_STATUS
|
||||
//
|
||||
// Enable ifconfig slip-specific options "keepalive" and "outfill"
|
||||
#define BB_FEATURE_IFCONFIG_SLIP
|
||||
//
|
||||
// Enable ifconfig options "mem_start", "io_addr", and "irq".
|
||||
#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
|
||||
//
|
||||
// Enable ifconfig option "hw". Currently works for only with "ether".
|
||||
#define BB_FEATURE_IFCONFIG_HW
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
//#define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
#define BB_FEATURE_WGET_STATUSBAR
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
|
||||
#define BB_FEATURE_HUMAN_READABLE
|
||||
//
|
||||
// Support for the find -type option.
|
||||
#define BB_FEATURE_FIND_TYPE
|
||||
//
|
||||
// Support for the find -perm option.
|
||||
#define BB_FEATURE_FIND_PERM
|
||||
//
|
||||
// Support for the find -mtine option.
|
||||
#define BB_FEATURE_FIND_MTIME
|
||||
//
|
||||
// Support for the -A -B and -C context flags in grep
|
||||
//#define BB_FEATURE_GREP_CONTEXT
|
||||
//
|
||||
// Support for the EGREP applet (alias to the grep applet)
|
||||
//#define BB_FEATURE_GREP_EGREP_ALIAS
|
||||
//
|
||||
// Tell tftp what commands that should be supported.
|
||||
#define BB_FEATURE_TFTP_PUT
|
||||
#define BB_FEATURE_TFTP_GET
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#else
|
||||
#undef BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifndef BB_INIT
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG
|
||||
#ifndef BB_DPKG_DEB
|
||||
#define BB_DPKG_DEB
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG_DEB
|
||||
#ifndef BB_AR
|
||||
#define BB_AR
|
||||
#endif
|
||||
#ifndef BB_TAR
|
||||
#define BB_TAR
|
||||
#endif
|
||||
#ifndef BB_FEATURE_TAR_GZIP
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_IFCONFIG
|
||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||
#define BB_INTERFACE
|
||||
#endif
|
||||
#else
|
||||
#undef BB_INTERFACE
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_SYSLOGD
|
||||
#if defined BB_FEATURE_IPC_SYSLOG
|
||||
#define BB_LOGREAD
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_DOS2UNIX
|
||||
#define BB_UNIX2DOS
|
||||
#endif
|
||||
Loaded 100 of 297 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user