diff options
-rw-r--r-- | Changelog | 371 | ||||
-rw-r--r-- | Makefile | 47 | ||||
-rw-r--r-- | TODO | 6 | ||||
-rwxr-xr-x | applets/install.sh | 2 | ||||
-rw-r--r-- | archival/gunzip.c | 16 | ||||
-rw-r--r-- | archival/gzip.c | 16 | ||||
-rw-r--r-- | chmod_chown_chgrp.c | 25 | ||||
-rw-r--r-- | coreutils/du.c | 8 | ||||
-rw-r--r-- | coreutils/ln.c | 2 | ||||
-rw-r--r-- | coreutils/ls.c | 28 | ||||
-rw-r--r-- | coreutils/tail.c | 15 | ||||
-rw-r--r-- | cp_mv.c | 26 | ||||
-rw-r--r-- | du.c | 8 | ||||
-rw-r--r-- | gunzip.c | 16 | ||||
-rw-r--r-- | gzip.c | 16 | ||||
-rwxr-xr-x | install.sh | 2 | ||||
-rw-r--r-- | internal.h | 12 | ||||
-rw-r--r-- | ln.c | 2 | ||||
-rw-r--r-- | ls.c | 28 | ||||
-rw-r--r-- | sfdisk.c | 99 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 39 | ||||
-rw-r--r-- | syslogd.c | 39 | ||||
-rw-r--r-- | tail.c | 15 | ||||
-rw-r--r-- | utility.c | 59 |
24 files changed, 483 insertions, 414 deletions
@@ -1,17 +1,15 @@ | |||
1 | 0.42 | 1 | 0.42 |
2 | 2 | ||
3 | * changed fsck_minix.c to reduce its .bss size significantly | ||
4 | -beppu -piptigger | ||
5 | * Fairly massive restructuring of umount.c to deal with remounting | 3 | * Fairly massive restructuring of umount.c to deal with remounting |
6 | busy devices read-only. Adds a -r option to control that; it is | 4 | busy devices read-only. Adds a -r option to control that; it is |
7 | optionally compiled in with BB_FEATURE_REMOUNT | 5 | optionally compiled in with BB_FEATURE_REMOUNT |
8 | * Added a bunch of functions to mtab.c to interact with the | 6 | * Added a bunch of functions to mtab.c to interact with the |
9 | {get,set,end}mntent interface; as it turns out, those functions do | 7 | {get,set,end}mntent interface; as it turns out, those functions do |
10 | not appear to be re-entrant, and that causes a lot of problems with | 8 | not appear to be re-entrant, and that causes a lot of problems with |
11 | the way umount was originally written. | 9 | the way umount was originally written. |
12 | * Makes init send TERM and KILL (instead of HUP and KILL) on reboot | 10 | * Makes init send TERM and KILL (instead of HUP and KILL) on reboot |
13 | to be more consistent with sysvinit | 11 | to be more consistent with sysvinit |
14 | * Changes to init.c to use the new -r option to umount. Also increased | 12 | * Changes to init.c to use the new -r option to umount. Also increased |
15 | the sleep time between the time the TERM and KILL signals are sent | 13 | the sleep time between the time the TERM and KILL signals are sent |
16 | 14 | ||
17 | - Randolph Chung | 15 | - Randolph Chung |
@@ -19,17 +17,19 @@ | |||
19 | 17 | ||
20 | * cp.c, mv.c: removed, replaced by cp_mv.c which has been | 18 | * cp.c, mv.c: removed, replaced by cp_mv.c which has been |
21 | extensively rewritten from the original cp.c. | 19 | extensively rewritten from the original cp.c. |
20 | * Fixed cp and mv so if the source and destination are a the | ||
21 | same directory it will print an error and continue. | ||
22 | * Also added a warning message to the `mv' usage string saying that | 22 | * Also added a warning message to the `mv' usage string saying that |
23 | this is not GNU mv, and it will break hard links. cp also breaks | 23 | this is not GNU mv, and it will break hard links. cp also breaks |
24 | hard links. | 24 | hard links. |
25 | * ln.c: implemented `-n' switch, no-deref symlinks. | 25 | * ln.c: implemented `-n' switch, no-deref symlinks. |
26 | * include<sys/param.h>: and use PATH_MAX everywhere. | 26 | * include<sys/param.h>: and use PATH_MAX everywhere. busybox: File |
27 | * busybox: File name buffer overrun guards to prevent future crashes. | 27 | * name buffer overrun guards to prevent future crashes. |
28 | - Always check exit status. | 28 | - Always check exit status. |
29 | - Purge all use of `creat()', replace with `open()'. | 29 | - Purge all use of `creat()', replace with `open()'. |
30 | * utility.c | 30 | * utility.c |
31 | - recursiveAction was overriding the value of | 31 | - recursiveAction was overriding the value of followLinks thus |
32 | followLinks thus ignoring it. | 32 | ignoring it. |
33 | - isDirectory now takes a followLinks boolean, updated all callers | 33 | - isDirectory now takes a followLinks boolean, updated all callers |
34 | - copyFile had the followLinks logic reversed. | 34 | - copyFile had the followLinks logic reversed. |
35 | * messages.c: New file. Put common error message strings all in | 35 | * messages.c: New file. Put common error message strings all in |
@@ -38,29 +38,31 @@ | |||
38 | -Karl M. Hegbloom | 38 | -Karl M. Hegbloom |
39 | 39 | ||
40 | 40 | ||
41 | * Made tar creation support in busybox tar optional. | 41 | * changed fsck_minix.c to reduce its .bss size significantly |
42 | * You no longer _have_ to put a "-" in front of tar options. | 42 | -beppu -piptigger |
43 | * Tar could inadvertently change permissions and ownership on | 43 | * Made tar creation support in busybox tar optional. You no longer |
44 | * _have_ to put a "-" in front of tar options. Tar could inadvertently | ||
45 | * change permissions and ownership on | ||
44 | certain directories pointed to by symlinks. | 46 | certain directories pointed to by symlinks. |
45 | * Made grep and grep -h do the right thing wrt printing | 47 | * Made grep and grep -h do the right thing wrt printing |
46 | the file name (it failed to print files names in many cases). | 48 | the file name (it failed to print files names in many cases). |
47 | * Fix a namespace aliasing problem wereby if du was built in, the | 49 | * Fix a namespace aliasing problem wereby if du was built in, the |
48 | symlink for both du and dutmp would be installed, or then rm was | 50 | symlink for both du and dutmp would be installed, or then rm was |
49 | built in, the symlinks for both rm and rmmod would be installed. | 51 | built in, the symlinks for both rm and rmmod would be installed. |
50 | * Added a closelog() to init.c after loging -- fix thanks to | 52 | * Added a closelog() to init.c after loging -- fix thanks to |
51 | Taketoshi Sano <kgh12351@nifty.ne.jp> | 53 | Taketoshi Sano <kgh12351@nifty.ne.jp> |
52 | * Rewrote and simplified logger. Added the "-t" option, and made it | 54 | * Rewrote and simplified logger. Added the "-t" option, and made it |
53 | behave itself a bit better. | 55 | behave itself a bit better. |
54 | * Optional support contributed by Ben Collins <bcollins@debian.org> | 56 | * Optional support contributed by Ben Collins <bcollins@debian.org> |
55 | for the kernel init chroot patch by Werner Almesberger, which | 57 | for the kernel init chroot patch by Werner Almesberger, which |
56 | allows init to chroot to a new device, and umount the old one. | 58 | allows init to chroot to a new device, and umount the old one. |
57 | * Fixed bug that wouldn't let one chown a symlink -- it would | 59 | * Fixed bug that wouldn't let one chown a symlink -- it would |
58 | always dereference before. -beppu | 60 | always dereference before. -beppu |
59 | * Fixed a bug where init could have reference already freed memory. | 61 | * Fixed a bug where init could have reference already freed memory. |
60 | Found and fixed by Taketoshi Sano <kgh12351@nifty.ne.jp> | 62 | Found and fixed by Taketoshi Sano <kgh12351@nifty.ne.jp> |
61 | * Several contributions from Friedrich Vedder <fwv@myrtle.lahn.de> | 63 | * Several contributions from Friedrich Vedder <fwv@myrtle.lahn.de> |
62 | * Added (and documented) "-n" option for head - | 64 | * Added (and documented) "-n" option for head - Cleanup for a number of |
63 | * Cleanup for a number of usage messages -- also | 65 | * usage messages -- also |
64 | contributed Friedrich Vedder <fwv@myrtle.lahn.de> | 66 | contributed Friedrich Vedder <fwv@myrtle.lahn.de> |
65 | * Cosmetic fix to busybox.c (Don't print a comma at the | 67 | * Cosmetic fix to busybox.c (Don't print a comma at the |
66 | end of line if there are no more application names). | 68 | end of line if there are no more application names). |
@@ -69,9 +71,9 @@ | |||
69 | * Moved commonly used functions "xmalloc()" and "exit()" | 71 | * Moved commonly used functions "xmalloc()" and "exit()" |
70 | to utility.c (with proper #ifdef's). | 72 | to utility.c (with proper #ifdef's). |
71 | * Created a tiny tail implementation, removing -c, -q, -v, and making | 73 | * Created a tiny tail implementation, removing -c, -q, -v, and making |
72 | tail -f work only with a single file. This reduced tail | 74 | tail -f work only with a single file. This reduced tail from 6k to |
73 | from 6k to 2.4k. The bigger/more featured tail can still be | 75 | 2.4k. The bigger/more featured tail can still be had by disabling |
74 | had by disabling BB_FEATURE_SIMPLE_TAIL in dusybox.defs.h | 76 | BB_FEATURE_SIMPLE_TAIL in dusybox.defs.h |
75 | * Ping now falls back to doing the right thing if /etc/protocols | 77 | * Ping now falls back to doing the right thing if /etc/protocols |
76 | turns up missing. | 78 | turns up missing. |
77 | * Fixed mount and umount. Previously they could leak loop device | 79 | * Fixed mount and umount. Previously they could leak loop device |
@@ -83,15 +85,24 @@ | |||
83 | files pointed to by the symlinks. | 85 | files pointed to by the symlinks. |
84 | * Several fixes from Pavel Roskin <pavel_roskin@geocities.com>: | 86 | * Several fixes from Pavel Roskin <pavel_roskin@geocities.com>: |
85 | - `chown' with 1 argument displayed the error incorrectly | 87 | - `chown' with 1 argument displayed the error incorrectly |
86 | - `fdflush', `length' and `printf' crashed when run without arguments | 88 | - `fdflush', `length' and `printf' crashed if run without arguments |
87 | - `fdflush' tried to flush itself using *argv | 89 | - `fdflush' tried to flush itself using *argv |
88 | - added "skip" and "seek" to dd. | 90 | - added "skip" and "seek" to dd. |
89 | * swapoff -a was not working. Now it is. | 91 | - ls no longer messus up output when combining files and |
90 | * init did not cleanly unmount filesystems on reboot. Now it does. | 92 | directories on the command line |
91 | * "sed -ne s/foo/bar/" worked but "sed -n -e s/foo/bar/" didn't. | 93 | * swapoff -a was not working. Now it is. init did not cleanly unmount |
94 | * filesystems on reboot. Now it does. "sed -ne s/foo/bar/" worked but | ||
95 | * "sed -n -e s/foo/bar/" didn't. | ||
92 | Now both work. | 96 | Now both work. |
93 | * Some architectures (PowerPc) assume chars are unsigned, so they could | 97 | * Some architectures (PowerPc) assume chars are unsigned, so they could |
94 | not distinguish between EOF and '\0xFF' in sed. Sed now uses ints. | 98 | not distinguish between EOF and '\0xFF' in sed. Sed now uses ints. |
99 | * Began converting error handling to use some common routines | ||
100 | in utility.c | ||
101 | * syslogd now has better message handling and ignores SIGHUP. | ||
102 | * install.sh had a bug preventing installation to the specified | ||
103 | target directory. Fix from Gilbert Coville <gilbert@mvista.com> | ||
104 | * You can now spefify alternative strip commands -- change | ||
105 | also from Gilbert Coville. | ||
95 | 106 | ||
96 | 107 | ||
97 | -Erik Andersen | 108 | -Erik Andersen |
@@ -100,48 +111,49 @@ | |||
100 | * New Apps: wc, hostid, logname, tty, whoami, yes -- all contributed | 111 | * New Apps: wc, hostid, logname, tty, whoami, yes -- all contributed |
101 | by Edward Betts <edward@debian.org> | 112 | by Edward Betts <edward@debian.org> |
102 | * Fixed a bug in both cp and mv preventing 'cp foo/README bar' | 113 | * Fixed a bug in both cp and mv preventing 'cp foo/README bar' |
103 | type commands (file in a directory to another directory) | 114 | type commands (file in a directory to another directory) from |
104 | from working. | 115 | working. |
105 | * Fixed a logger bug that caused garbage to be written to the syslog | 116 | * Fixed a logger bug that caused garbage to be written to the syslog |
106 | (unless you used busybox syslog, which hid the bug). Thanks | 117 | (unless you used busybox syslog, which hid the bug). Thanks to |
107 | to Alex Holden <alex@linuxhacker.org> for the fix. | 118 | Alex Holden <alex@linuxhacker.org> for the fix. |
108 | * /bin/true and /bin/false were echoing a blank line when run. Now fixed. | 119 | * /bin/true and /bin/false were echoing a blank line when run. |
120 | Now fixed. | ||
109 | * mkdir -p would print an error when asked to mkdir an existing dir | 121 | * mkdir -p would print an error when asked to mkdir an existing dir |
110 | with no interveining subdirectories. | 122 | with no interveining subdirectories. |
111 | * Fixed "syslogd -O" so that it works. | 123 | * Fixed "syslogd -O" so that it works. Added -o loop option for mount, |
112 | * Added -o loop option for mount, and support in umount for loop | 124 | * and support in umount for loop |
113 | devices. Support is toggled by MOUNT_LOOP feature -- Ben Collins | 125 | devices. Support is toggled by MOUNT_LOOP feature -- Ben Collins |
114 | <bcollins@debian.org> | 126 | <bcollins@debian.org> |
115 | * Several fixes from Marco Pantaleoni <panta@prosa.it> | 127 | * Several fixes from Marco Pantaleoni <panta@prosa.it> compile in |
116 | * compile in fullWrite() not only if BB_TAR is defined, but also | 128 | * fullWrite() not only if BB_TAR is defined, but also |
117 | if BB_CP or BB_MV are (fullWrite() is referenced by copyFile()) | 129 | if BB_CP or BB_MV are (fullWrite() is referenced by copyFile()) |
118 | * add some compiler optimizations to further reduce executable size | 130 | * add some compiler optimizations to further reduce executable size |
119 | (as a side note, on my machines the largest code is generated by | 131 | (as a side note, on my machines the largest code is generated |
120 | gcc 2.95.2 with -Os ! The smallest by plain gcc 2.7.2.3 with -O2 | 132 | by gcc 2.95.2 with -Os ! The smallest by plain gcc 2.7.2.3 with |
121 | -m386 ...) | 133 | -O2 -m386 ...) |
122 | * Compile no longer fails if busybox.def.h defines BB_FEATURE_LINUXRC | 134 | * Compile now won't fail if busybox.def.h defines |
123 | but not BB_INIT. (init_main used to be referenced, but not compiled) | 135 | BB_FEATURE_LINUXRC but not BB_INIT. (init_main used to be |
136 | referenced, but not compiled) | ||
124 | * Fixed a bug in setting TERM for serial console support. TERM now | 137 | * Fixed a bug in setting TERM for serial console support. TERM now |
125 | defaults to "ansi" for serial consoles. | 138 | defaults to "ansi" for serial consoles. |
126 | * Fixed a bug in handling the CONSOLE env. variable for serial consoles. | 139 | * Fixed a bug in handling the CONSOLE env. variable for serial |
140 | * consoles. | ||
127 | 141 | ||
128 | -Erik Andersen, Jan 15, 2000 | 142 | -Erik Andersen, Jan 15, 2000 |
129 | 143 | ||
130 | 0.40 | 144 | 0.40 |
131 | * New Apps: sort, uniq. -beppu | 145 | * New Apps: sort, uniq. -beppu New Apps: lsmod, rmmod -erik New Apps: |
132 | * New Apps: lsmod, rmmod -erik | 146 | * fbset contributed by Randolph Chung <tausq@debian.org>. New App:: |
133 | * New Apps: fbset contributed by Randolph Chung <tausq@debian.org>. | 147 | * loadacm contributed by Peter Novodvorsky <petya@logic.ru> |
134 | * New App:: loadacm contributed by Peter Novodvorsky <petya@logic.ru> | ||
135 | for loading application character maps for Unicode fonts. | 148 | for loading application character maps for Unicode fonts. |
136 | * Major init re-work. init now supports inittab (slightly different | 149 | * Major init re-work. init now supports inittab (slightly different |
137 | but similar to sysvinit), allowing me to get all the policy out | 150 | but similar to sysvinit), allowing me to get all the policy out of |
138 | of init and into the conf file. It works just fine without inittab | 151 | init and into the conf file. It works just fine without inittab |
139 | being present, but if you dont like the defautl behavior you can | 152 | being present, but if you dont like the defautl behavior you can |
140 | now do something about it. Init is much cleaner as a result. | 153 | now do something about it. Init is much cleaner as a result. |
141 | * Fixed an bug in syslogd causing it to stop after 20 minutes. -erik | 154 | * Fixed an bug in syslogd causing it to stop after 20 minutes. -erik |
142 | * Fixed an embarrasing segfault in head -beppu | 155 | * Fixed an embarrasing segfault in head -beppu Fixed the embarrasing |
143 | * Fixed the embarrasing failure of 'logger -p'. -erik | 156 | * failure of 'logger -p'. -erik Added the -s option to du -beppu |
144 | * Added the -s option to du -beppu | ||
145 | * Re-worked the source tree a bit so it will compile under glibc 2.0.7 | 157 | * Re-worked the source tree a bit so it will compile under glibc 2.0.7 |
146 | with the 2.0.x Linux kernel. | 158 | with the 2.0.x Linux kernel. |
147 | * Added 'grep -q' thanks to a patch from "Konstantin Boldyshev" | 159 | * Added 'grep -q' thanks to a patch from "Konstantin Boldyshev" |
@@ -151,19 +163,19 @@ | |||
151 | * Fixed a bug where tar would set, and then clear SGID and SUID bits. | 163 | * Fixed a bug where tar would set, and then clear SGID and SUID bits. |
152 | * Fixed a bug where tar would not set the user and group on device | 164 | * Fixed a bug where tar would not set the user and group on device |
153 | special files. | 165 | special files. |
154 | * Fixed a bug where tar would not restore the time to files. | 166 | * Fixed a bug where tar would not restore the time to files. Fixed a |
155 | * Fixed a major security problem with tar -- it changed ownership | 167 | * major security problem with tar -- it changed ownership |
156 | of any file pointed to by a symlink to 777 (like say libc....) | 168 | of any file pointed to by a symlink to 777 (like say libc....) |
157 | Ouch!!! | 169 | Ouch!!! |
158 | * cp and mv were very broken when moving directories. I have rewritten | 170 | * cp and mv were very broken when moving directories. I have rewritten |
159 | them so they should now work as expected. | 171 | them so they should now work as expected. |
160 | * sed now supports addresses (numeric or regexp, with negation) and | 172 | * sed now supports addresses (numeric or regexp, with negation) and |
161 | has an append command, thanks to Marco Pantaleoni <panta@prosa.it> | 173 | has an append command, thanks to Marco Pantaleoni <panta@prosa.it> |
162 | * Fixed dmesg. It wasn't parsing its options (-n or -s) properly. | 174 | * Fixed dmesg. It wasn't parsing its options (-n or -s) properly. |
163 | * Some cosmetic fixes to ls output formatting to make it behave more | 175 | * Some cosmetic fixes to ls output formatting to make it behave more |
164 | like GNU ls. | 176 | like GNU ls. |
165 | * Fixed a stupid segfault in kill. | 177 | * Fixed a stupid segfault in kill. Several fixes from Friedrich Vedder |
166 | * Several fixes from Friedrich Vedder <fwv@myrtle.lahn.de>: | 178 | * <fwv@myrtle.lahn.de>: |
167 | - Added gunzip -t, removed gunzip.c dead code, | 179 | - Added gunzip -t, removed gunzip.c dead code, |
168 | - fixed several typos | 180 | - fixed several typos |
169 | - Glibc 2.0.7 and libc5 compile fixes | 181 | - Glibc 2.0.7 and libc5 compile fixes |
@@ -175,25 +187,27 @@ | |||
175 | 0.39 | 187 | 0.39 |
176 | * New Apps: ping, hostname, and mkfifo contributed by Randolph Chung | 188 | * New Apps: ping, hostname, and mkfifo contributed by Randolph Chung |
177 | <tausq@debian.org>. 3 items off the TODO list! | 189 | <tausq@debian.org>. 3 items off the TODO list! |
178 | * I wrote free (just calls "cat /proc/meminfo"). | 190 | * I wrote free (just calls "cat /proc/meminfo"). Added tail, based on |
179 | * Added tail, based on tail from GNU textutils-1.19, but adjusted | 191 | * tail from GNU textutils-1.19, but adjusted |
180 | to suit my evil purposes. Costs 6k. I'll make it smaller sometime. | 192 | to suit my evil purposes. Costs 6k. I'll make it smaller |
193 | sometime. | ||
181 | * on reboot, init called 'umount -a -n', which caused errors | 194 | * on reboot, init called 'umount -a -n', which caused errors |
182 | when BB_MTAB was not enabled. Changed to 'umount -a', | 195 | when BB_MTAB was not enabled. Changed to 'umount -a', which does |
183 | which does the right thing. | 196 | the right thing. |
184 | * init will now try to run /sbin/getty if it is present (for easy | 197 | * init will now try to run /sbin/getty if it is present (for easy |
185 | integration with the about-to-be-released tinylogin.) | 198 | integration with the about-to-be-released tinylogin.) |
186 | * kill now behaves itself properly, added 'kill -l' to list signals | 199 | * kill now behaves itself properly, added 'kill -l' to list signals 'ls |
187 | * 'ls -l' was failing on long directories, since my_getid was leaking | 200 | * -l' was failing on long directories, since my_getid was leaking |
188 | one file descriptor per file. Oops. | 201 | one file descriptor per file. Oops. |
189 | * Fixed rebooting from init. I'd accidently left some debugging code in | 202 | * Fixed rebooting from init. I'd accidently left some debugging code |
203 | * in | ||
190 | which blocked reboots. | 204 | which blocked reboots. |
191 | * Fixed reboot, halt (and added poweroff) such that they handle it when | 205 | * Fixed reboot, halt (and added poweroff) such that they handle it when |
192 | init is not at PID 1 (like when running in an initrd). | 206 | init is not at PID 1 (like when running in an initrd). |
193 | * Added a prelinary du implementation. Some parameter parsing | 207 | * Added a prelinary du implementation. Some parameter parsing |
194 | stuff still needs to be added. -beppu (John Beppu <beppu@lineo.com>) | 208 | stuff still needs to be added. -beppu (John Beppu |
195 | * Implemented tee. -beppu | 209 | <beppu@lineo.com>) |
196 | * Implemented head. -beppu | 210 | * Implemented tee. -beppu Implemented head. -beppu |
197 | 211 | ||
198 | -Erik Andersen, Dec 10, 1999 | 212 | -Erik Andersen, Dec 10, 1999 |
199 | 213 | ||
@@ -201,7 +215,8 @@ | |||
201 | * Fixed a segfault in 'umount -a' when a badly formed /etc/fstab | 215 | * Fixed a segfault in 'umount -a' when a badly formed /etc/fstab |
202 | file existed. | 216 | file existed. |
203 | * df will not exit on error, but will stat all mounted filesystems. | 217 | * df will not exit on error, but will stat all mounted filesystems. |
204 | * Fixed tar so uid/gid/permissions on extracted tarballs will be correct. | 218 | * Fixed tar so uid/gid/permissions on extracted tarballs will be |
219 | correct. | ||
205 | * Fixed find -name so it properly uses shell wildcard patterns | 220 | * Fixed find -name so it properly uses shell wildcard patterns |
206 | (i.e. `*', `?', and `[]') instead of regular expressions, which | 221 | (i.e. `*', `?', and `[]') instead of regular expressions, which |
207 | was causing some confusing and unexpected behavior. | 222 | was causing some confusing and unexpected behavior. |
@@ -219,20 +234,25 @@ | |||
219 | 0.37 | 234 | 0.37 |
220 | * Wrote a micro syslogd, and a logger util (to log things to the syslog | 235 | * Wrote a micro syslogd, and a logger util (to log things to the syslog |
221 | from the command line or scripts) With both compiled in, costs 4k. | 236 | from the command line or scripts) With both compiled in, costs 4k. |
222 | * Fixed 'make install' so symlinks are installed in their proper locations. | 237 | * Fixed 'make install' so symlinks are installed in their proper |
223 | * Changed the build system slightly so that features can now be enabled | 238 | * locations. Changed the build system slightly so that features can |
224 | or disabled from the busybox.defs.h header file, without trying to | 239 | * now be enabled |
225 | compile in a source file named after that featue (unless that file exists). | 240 | or disabled from the busybox.defs.h header file, without trying to |
226 | * Several options are now moved into busybox.defs.h | 241 | compile in a source file named after that featue (unless that file |
227 | * Now 'rm -R' and 'rm -r' both work. | 242 | exists). |
228 | * dd now properly handles input beyond 1 block from stdin. | 243 | * Several options are now moved into busybox.defs.h Now 'rm -R' and 'rm |
229 | * Fixed a bug where tar unpacked everything a directories. Moved some code | 244 | * -r' both work. dd now properly handles input beyond 1 block from |
230 | from createPath into mkdir where it belonged, thereby making tar work properly. | 245 | * stdin. Fixed a bug where tar unpacked everything a directories. |
231 | * Fixed an off-by-one bug in cat. Given a list of file it wouldn't cat out the | 246 | * Moved some code |
247 | from createPath into mkdir where it belonged, thereby making tar | ||
248 | work properly. | ||
249 | * Fixed an off-by-one bug in cat. Given a list of file it wouldn't cat | ||
250 | * out the | ||
232 | last file in the list. | 251 | last file in the list. |
233 | * Fixed 'ls -ln' so numeric group/uid are presented properly, and fixed 'ls -l' | 252 | * Fixed 'ls -ln' so numeric group/uid are presented properly, and fixed |
234 | so when uid/gid is not in /etc/{passwd,group} the numeric group/uid are | 253 | * 'ls -l' |
235 | presented properly. | 254 | so when uid/gid is not in /etc/{passwd,group} the numeric group/uid |
255 | are presented properly. | ||
236 | * Also added a TODO. | 256 | * Also added a TODO. |
237 | 257 | ||
238 | 258 | ||
@@ -241,46 +261,53 @@ | |||
241 | 0.36 | 261 | 0.36 |
242 | * fixed dd so it properly defaults to stdin and stdout when no | 262 | * fixed dd so it properly defaults to stdin and stdout when no |
243 | if= and of= are set (fix thanks to Eric Delaunay). | 263 | if= and of= are set (fix thanks to Eric Delaunay). |
244 | * Don't try to close the file descriptor of a pipein tar. (fix also from | 264 | * Don't try to close the file descriptor of a pipein tar. (fix also |
265 | * from | ||
245 | Eric Delaunay). | 266 | Eric Delaunay). |
246 | * Made createPath be quiet (again thanks to Eric Delaunay). | 267 | * Made createPath be quiet (again thanks to Eric Delaunay). If |
247 | * If BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever | 268 | * BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever |
248 | command you define it as will be run if the init script exits. | 269 | command you define it as will be run if the init script exits. |
249 | * Updated install.sh to make it more robust (thanks to Adam Di Carlo) | 270 | * Updated install.sh to make it more robust (thanks to Adam Di Carlo) |
250 | * NFS support added to mount by Eric Delaunay. It costs 10k when compiled | 271 | * NFS support added to mount by Eric Delaunay. It costs 10k when |
272 | * compiled | ||
251 | in, but that is still a big win for those that use NFS. | 273 | in, but that is still a big win for those that use NFS. |
252 | * Made 'rm -f' be silent for non-existant files (thanks to Eric Delaunay). | 274 | * Made 'rm -f' be silent for non-existant files (thanks to Eric |
253 | * changed zcat.c to gunzip.c. It now obeys the principle of least surprise | 275 | * Delaunay). changed zcat.c to gunzip.c. It now obeys the principle |
254 | and acts as god intended gunzip and zcat to act. They answer --help and | 276 | * of least surprise |
255 | obey the '-c' flag. | 277 | and acts as god intended gunzip and zcat to act. They answer |
256 | * Fixed a bug in mv which caused it to not move files when the destination | 278 | --help and obey the '-c' flag. |
279 | * Fixed a bug in mv which caused it to not move files when the | ||
280 | * destination | ||
257 | was a directory. | 281 | was a directory. |
258 | * Fixed a decimal-instead-of-octal bug causing mkdir to make directories | 282 | * Fixed a decimal-instead-of-octal bug causing mkdir to make |
283 | * directories | ||
259 | with very wrong permissions. | 284 | with very wrong permissions. |
260 | * chmod would overwrite file permissions instead of modifying them. | 285 | * chmod would overwrite file permissions instead of modifying them. |
261 | Now it properly modifies permissions. | 286 | Now it properly modifies permissions. |
262 | * Init now sends warnings destined for the console to /dev/console to ensure | 287 | * Init now sends warnings destined for the console to /dev/console to |
263 | they show up on whatever the active console it. Otherwise important | 288 | * ensure |
264 | messages (for example that the system is rebooting) were not seen when | 289 | they show up on whatever the active console it. Otherwise |
265 | switched to a different VT. | 290 | important messages (for example that the system is rebooting) were |
291 | not seen when switched to a different VT. | ||
266 | 292 | ||
267 | -Erik Andersen, Nov 17, 1999 | 293 | -Erik Andersen, Nov 17, 1999 |
268 | 294 | ||
269 | 0.35 | 295 | 0.35 |
270 | * gzip now obeys the principle of least surprise and acts like god intended | 296 | * gzip now obeys the principle of least surprise and acts like god |
271 | (i.e. it accepts a file name, answers --help, and obeys the '-c' flag | 297 | * intended |
272 | and only then outputs to stdout). | 298 | (i.e. it accepts a file name, answers --help, and obeys the '-c' |
299 | flag and only then outputs to stdout). | ||
273 | * Fixed more.c to compile autowidth on sparc and set initial winsize | 300 | * Fixed more.c to compile autowidth on sparc and set initial winsize |
274 | to 0,0 in case the TIOCGWINSZ ioctl fails. Fix thanks to Eric Delaunay. | 301 | to 0,0 in case the TIOCGWINSZ ioctl fails. Fix thanks to Eric |
302 | Delaunay. | ||
275 | * Fixed tar so it now works as expected (it had TRUE/FALSE backwards) | 303 | * Fixed tar so it now works as expected (it had TRUE/FALSE backwards) |
276 | * tar now accepts --help | 304 | * tar now accepts --help chmod, chown, and chgrp usage now works |
277 | * chmod, chown, and chgrp usage now works | 305 | * General usage (i.e. --help) cleanups for most apps umount now parses |
278 | * General usage (i.e. --help) cleanups for most apps | 306 | * options correctly tar can now unpack tarballs containing device |
279 | * umount now parses options correctly | 307 | * special files, |
280 | * tar can now unpack tarballs containing device special files, | 308 | sockets, and fifos (though it can't pack them up) thanks to Matt |
281 | sockets, and fifos (though it can't pack them up) thanks | 309 | Porter. Creating archives containing these is still left to the |
282 | to Matt Porter. Creating archives containing these is still | 310 | interested student. |
283 | left to the interested student. | ||
284 | * fixed up the license in more.c to properly point to Bruce Perens. | 311 | * fixed up the license in more.c to properly point to Bruce Perens. |
285 | 312 | ||
286 | -Erik Andersen, Nov 11, 1999 | 313 | -Erik Andersen, Nov 11, 1999 |
@@ -290,17 +317,17 @@ | |||
290 | Patch thanks to Eric Delaunay | 317 | Patch thanks to Eric Delaunay |
291 | * init now properly handles sparc serial consoles and does a | 318 | * init now properly handles sparc serial consoles and does a |
292 | better job of finding the real console device rather than using | 319 | better job of finding the real console device rather than using |
293 | /dev/console which doesn't support job control. Patch also | 320 | /dev/console which doesn't support job control. Patch also thanks |
294 | thanks to Eric Delaunay. | 321 | to Eric Delaunay. |
295 | * more started to read from stdin after the last file was finished, and | 322 | * more started to read from stdin after the last file was finished, and |
296 | options were not parsed correctly (fix thanks to Eric Delaunay). | 323 | options were not parsed correctly (fix thanks to Eric Delaunay). |
297 | * more will now use the terminal size if BB_FEATURE_AUTOWIDTH is on. | 324 | * more will now use the terminal size if BB_FEATURE_AUTOWIDTH is on. |
298 | * rm wouldn't remove a symlink unless the symlink was valid. This was | 325 | * rm wouldn't remove a symlink unless the symlink was valid. This was |
299 | a side effect of the busybox 0.32 recursiveAction() fix. Things | 326 | a side effect of the busybox 0.32 recursiveAction() fix. Things |
300 | should now work correctly. | 327 | should now work correctly. |
301 | * grep wouldn't grep stdin. Now it does. | 328 | * grep wouldn't grep stdin. Now it does. sed wouldn't sed stdin. Now |
302 | * sed wouldn't sed stdin. Now it does. | 329 | * it does. sed was appending a \n to the end of lines with |
303 | * sed was appending a \n to the end of lines with replacements. | 330 | * replacements. |
304 | Now it doesn't do that. | 331 | Now it doesn't do that. |
305 | * ls -l now bypasses libc6 nss when displaying user/group names. | 332 | * ls -l now bypasses libc6 nss when displaying user/group names. |
306 | Now uses my_getpwuid and my_getgrgid. | 333 | Now uses my_getpwuid and my_getgrgid. |
@@ -321,45 +348,45 @@ | |||
321 | 348 | ||
322 | 0.32 | 349 | 0.32 |
323 | * More changes -- many thanks to Lineo for paying me to work on | 350 | * More changes -- many thanks to Lineo for paying me to work on |
324 | busybox. If you have any problems please let me know ASAP | 351 | busybox. If you have any problems please let me know ASAP at |
325 | at andersen@lineo.com or andersee@debian.org | 352 | andersen@lineo.com or andersee@debian.org |
326 | * usage() now prints the BusyBox version. This will help folks | 353 | * usage() now prints the BusyBox version. This will help folks |
327 | realize that they are not in Kansas anymore. | 354 | realize that they are not in Kansas anymore. |
328 | * Fixed mkdir -m option so that it works. | 355 | * Fixed mkdir -m option so that it works. kill segfaulted w/o any |
329 | * kill segfaulted w/o any arguments. Now it doesn't do that. | 356 | * arguments. Now it doesn't do that. kill wasn't properly accepting |
330 | * kill wasn't properly accepting signal names. It does now. | 357 | * signal names. It does now. Added new apps chvt and deallocvt (I |
331 | * Added new apps chvt and deallocvt (I should probably add open) | 358 | * should probably add open) Major rewrite of init.c. Code is now |
332 | * Major rewrite of init.c. Code is now readable by mere mortals IMHO. | 359 | * readable by mere mortals IMHO. Wrote sed -- weighs only 1.8k (5.8k |
333 | * Wrote sed -- weighs only 1.8k (5.8k with full regular expressions!). | 360 | * with full regular expressions!). Fixed a stupid seg-fault in sync |
334 | * Fixed a stupid seg-fault in sync | 361 | * Fixed mount -- mount -a failed to parse and apply mount options Fixed |
335 | * Fixed mount -- mount -a failed to parse and apply mount options | 362 | * umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>) |
336 | * Fixed umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>) | 363 | * umount -a no longer umounts /proc Added BB_MTAB, allowing (at the |
337 | * umount -a no longer umounts /proc | 364 | * cost of ~1.5k and the need for a rw /etc) |
338 | * Added BB_MTAB, allowing (at the cost of ~1.5k and the need for a rw /etc) | 365 | folks to use a real /etc/mtab file instead of a symlink to |
339 | folks to use a real /etc/mtab file instead of a symlink to /proc/mounts. | 366 | /proc/mounts. mount, and umount will add/remove entries and df |
340 | mount, and umount will add/remove entries and df will now use /etc/mtab | 367 | will now use /etc/mtab if BB_MTAB is defined. |
341 | if BB_MTAB is defined. | ||
342 | * Fixed a nice bug in recursiveAction() which caused it to infinitely | 368 | * Fixed a nice bug in recursiveAction() which caused it to infinitely |
343 | hunt through /proc/../fd/* creating new file descriptors if it | 369 | hunt through /proc/../fd/* creating new file descriptors if it |
344 | followed the /dev/fd link over to /proc. recursiveAction() now | 370 | followed the /dev/fd link over to /proc. recursiveAction() now |
345 | lstat's the file when followLinks==FALSE so it won't follow links | 371 | lstat's the file when followLinks==FALSE so it won't follow links |
346 | as the name suggests. Fix thanks to Matt Porter <porter@debian.org>. | 372 | as the name suggests. Fix thanks to Matt Porter |
373 | <porter@debian.org>. | ||
347 | 374 | ||
348 | 375 | ||
349 | -Erik Andersen, Nov 4, 1999 | 376 | -Erik Andersen, Nov 4, 1999 |
350 | 377 | ||
351 | 0.31 | 378 | 0.31 |
352 | * I added a changelog for version 0.30. | 379 | * I added a changelog for version 0.30. adjusted find internals to |
353 | * adjusted find internals to make it smaller, and removed | 380 | * make it smaller, and removed |
354 | some redundancy. | 381 | some redundancy. |
355 | * Fixed a segfault in ps when /etc/passwd or /etc/group | 382 | * Fixed a segfault in ps when /etc/passwd or /etc/group |
356 | are absent. Now will warn you and carry on. | 383 | are absent. Now will warn you and carry on. |
357 | * Added in optional _real_ regular expression support (to be | 384 | * Added in optional _real_ regular expression support (to be |
358 | the basis for a future sed utility). When compiled in | 385 | the basis for a future sed utility). When compiled in it adds |
359 | it adds 3.9k, but makes grep much more capable. | 386 | 3.9k, but makes grep much more capable. |
360 | * Checked out using nftw(3) for recursive stuff, but unfortunatly | 387 | * Checked out using nftw(3) for recursive stuff, but unfortunatly |
361 | it wasn't supported before GNU libc 2.1, and some folks use | 388 | it wasn't supported before GNU libc 2.1, and some folks use glibc |
362 | glibc 2.0.7 since it is much smaller than that latest and greatest. | 389 | 2.0.7 since it is much smaller than that latest and greatest. |
363 | 390 | ||
364 | -Erik Andersen, Oct 21, 1999 | 391 | -Erik Andersen, Oct 21, 1999 |
365 | 392 | ||
@@ -373,8 +400,8 @@ | |||
373 | * busybox can now invoke apps in two ways: via symlinks to the | 400 | * busybox can now invoke apps in two ways: via symlinks to the |
374 | busybox binary, and as 'busybox [function] [arguments]...' | 401 | busybox binary, and as 'busybox [function] [arguments]...' |
375 | * When invoked as busybox, the list of currently compiled in | 402 | * When invoked as busybox, the list of currently compiled in |
376 | functions is printed out (no this is not bloat -- the list | 403 | functions is printed out (no this is not bloat -- the list has |
377 | has to be there anyway to map invocation name to function). | 404 | to be there anyway to map invocation name to function). |
378 | * busybox no longer parses command lines for apps or displays their | 405 | * busybox no longer parses command lines for apps or displays their |
379 | usage info. Each app gets to handle (or not handle) this for | 406 | usage info. Each app gets to handle (or not handle) this for |
380 | itself. | 407 | itself. |
@@ -385,9 +412,9 @@ | |||
385 | * All shared code now lives in utility.c, and is properly | 412 | * All shared code now lives in utility.c, and is properly |
386 | ifdef'ed to be only included for those apps requiring it. | 413 | ifdef'ed to be only included for those apps requiring it. |
387 | * Eliminated struct FileInfo (the basis of monadic, dyadic, etc) | 414 | * Eliminated struct FileInfo (the basis of monadic, dyadic, etc) |
388 | so now each app has the function prototype of (da-dum): | 415 | so now each app has the function prototype of (da-dum): extern |
389 | extern int foo_main(int argc, char** argv); | 416 | int foo_main(int argc, char** argv); which speeds integration |
390 | which speeds integration of new apps. | 417 | of new apps. |
391 | * Adjusted the Makefile to make it easier to | 418 | * Adjusted the Makefile to make it easier to |
392 | {en|dis}able debugging. | 419 | {en|dis}able debugging. |
393 | * Changed default compiler optimization to -Os | 420 | * Changed default compiler optimization to -Os |
@@ -396,39 +423,43 @@ | |||
396 | App Changes: | 423 | App Changes: |
397 | * To cope with the new app function prototype and the removal of | 424 | * To cope with the new app function prototype and the removal of |
398 | monadic, dyadic, etc, the following apps were re-written: | 425 | monadic, dyadic, etc, the following apps were re-written: |
399 | * cat - Works same as always. | 426 | * cat - Works same as always. chgrp, chmod, chown - |
400 | * chgrp, chmod, chown - rewrite. Combined into a single | 427 | * rewrite. Combined into a single |
401 | source file. Absorbed patches from Enrique Zanardi <ezanard@debian.org> | 428 | source file. Absorbed patches from Enrique Zanardi |
402 | that removes the dependency on libc6 libnss* libraries. | 429 | <ezanard@debian.org> that removes the dependency on |
430 | libc6 libnss* libraries. | ||
403 | * cp - Can now do 'cp -a' can can copy devices, | 431 | * cp - Can now do 'cp -a' can can copy devices, |
404 | pipes, symlinks, as well as recursive or non-recursive dir copies. | 432 | pipes, symlinks, as well as recursive or non-recursive |
405 | * fdflush - adjusted to remove dependancy on struct FileInfo. | 433 | dir copies. |
406 | * find - Now includes some basic regexp matching | 434 | * fdflush - adjusted to remove dependancy on struct |
435 | * FileInfo. find - Now includes some basic regexp matching | ||
407 | which will be the basic of a future mini-sed. | 436 | which will be the basic of a future mini-sed. |
408 | * ln - Same functionality. | 437 | * ln - Same functionality. mkdir - Added -p flag to |
409 | * mkdir - Added -p flag to feature set. | 438 | * feature set. mv - rewrite. rm - Added -f flag to |
410 | * mv - rewrite. | 439 | * feature set. rmdir - Same functionality. swapon, |
411 | * rm - Added -f flag to feature set. | 440 | * swapoff - Combined into a single binary. No longer |
412 | * rmdir - Same functionality. | 441 | uses /etc/swaps. swap{on|off} -a uses /etc/fstab |
413 | * swapon, swapoff - Combined into a single binary. No longer | 442 | instead. |
414 | uses /etc/swaps. swap{on|off} -a uses /etc/fstab instead. | 443 | * touch - Same functionality. date - adjusted with a patch |
415 | * touch - Same functionality. | 444 | * from Matthew Grant <grantma@anathoth.gen.nz> |
416 | * date - adjusted with a patch from Matthew Grant <grantma@anathoth.gen.nz> | 445 | to accomodate glibc timezone support. I then ripped out GNU |
417 | to accomodate glibc timezone support. I then ripped out GNU getopt. | 446 | getopt. |
418 | * mkswap -- new version merged from util-linux. Can now make >128Meg swaps. | 447 | * mkswap -- new version merged from util-linux. Can now make |
419 | * Replaced the old and star, unstar, and tarcat with the tar | 448 | * >128Meg swaps. Replaced the old and star, unstar, and tarcat |
420 | implementation from sash. Now tar behaves as god intended | 449 | * with the tar |
421 | it to (i.e. tar -xvf <file> and tar -cf <file> <dir> work). | 450 | implementation from sash. Now tar behaves as god intended it |
422 | * dd -- rewritten. Can with with files, stdin, stdout. | 451 | to (i.e. tar -xvf <file> and tar -cf <file> <dir> work). |
423 | * Added the following new apps: | 452 | * dd -- rewritten. Can with with files, stdin, stdout. Added the |
424 | * loadfont -- added from debian boot floppies | 453 | * following new apps: loadfont -- added from debian boot floppies |
425 | * chroot -- added based on a patch from Paolo Molaro <lupus@lettere.unipd.it> | 454 | * chroot -- added based on a patch from Paolo Molaro |
426 | * grep -- I just wrote it. Only matches simple strings | 455 | * <lupus@lettere.unipd.it> grep -- I just wrote it. Only matches |
427 | * ps -- I just wrote it. Has _no_ options at all, but works. | 456 | * simple strings ps -- I just wrote it. Has _no_ options at all, |
428 | * fsck_minix, mkfs_minix -- added from util-linux, but I ripped out | 457 | * but works. fsck_minix, mkfs_minix -- added from util-linux, but |
458 | * I ripped out | ||
429 | internationalization and such to make them smaller. | 459 | internationalization and such to make them smaller. |
430 | * sfdisk -- Added from util-linux (minus internationalization and such). | 460 | * sfdisk -- Added from util-linux (minus |
431 | * Probably some other changes that I forgot to document... | 461 | * internationalization and such). Probably some other |
462 | * changes that I forgot to document... | ||
432 | 463 | ||
433 | -Erik Andersen, Oct 20, 1999 | 464 | -Erik Andersen, Oct 20, 1999 |
434 | 465 | ||
@@ -1,5 +1,8 @@ | |||
1 | # Makefile for busybox | 1 | # Makefile for busybox |
2 | # | 2 | # |
3 | # Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org> | ||
4 | # Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org> | ||
5 | # | ||
3 | # This program is free software; you can redistribute it and/or modify | 6 | # This program is free software; you can redistribute it and/or modify |
4 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
5 | # the Free Software Foundation; either version 2 of the License, or | 8 | # the Free Software Foundation; either version 2 of the License, or |
@@ -15,13 +18,13 @@ | |||
15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
16 | # | 19 | # |
17 | 20 | ||
18 | PROG := busybox | 21 | # PROG := busybox |
19 | VERSION := 0.42 | 22 | VERSION := 0.42 |
20 | BUILDTIME := $(shell TZ=GMT date "+%Y%m%d-%H%M") | 23 | BUILDTIME := $(shell TZ=GMT date "+%Y%m%d-%H%M") |
21 | 24 | ||
22 | # Set the following to `true' to make a debuggable build. | 25 | # Set the following to `true' to make a debuggable build. |
23 | # Leave this set to `false' for production use. | 26 | # Leave this set to `false' for production use. |
24 | # eg: `make DODEBUG=true' | 27 | # eg: `make DODEBUG=true tests' |
25 | DODEBUG = false | 28 | DODEBUG = false |
26 | 29 | ||
27 | # If you want a static binary, turn this on. I can't think | 30 | # If you want a static binary, turn this on. I can't think |
@@ -60,15 +63,21 @@ else | |||
60 | OPTIMIZATION = -O2 | 63 | OPTIMIZATION = -O2 |
61 | endif | 64 | endif |
62 | 65 | ||
66 | # Allow alternative stripping tools to be used... | ||
67 | ifndef $(STRIPTOOL) | ||
68 | STRIPTOOL = strip | ||
69 | endif | ||
70 | |||
71 | |||
63 | # -D_GNU_SOURCE is needed because environ is used in init.c | 72 | # -D_GNU_SOURCE is needed because environ is used in init.c |
64 | ifeq ($(DODEBUG),true) | 73 | ifeq ($(DODEBUG),true) |
65 | CFLAGS += -Wall -g -D_GNU_SOURCE | 74 | CFLAGS += -Wall -g -D_GNU_SOURCE |
66 | STRIP = | ||
67 | LDFLAGS = | 75 | LDFLAGS = |
76 | STRIP = | ||
68 | else | 77 | else |
69 | CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE | 78 | CFLAGS += -Wall $(OPTIMIZATION) -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE |
70 | LDFLAGS = -s | 79 | LDFLAGS = -s |
71 | STRIP = strip --remove-section=.note --remove-section=.comment $(PROG) | 80 | STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment |
72 | #Only staticly link when _not_ debugging | 81 | #Only staticly link when _not_ debugging |
73 | ifeq ($(DOSTATIC),true) | 82 | ifeq ($(DOSTATIC),true) |
74 | LDFLAGS += --static | 83 | LDFLAGS += --static |
@@ -84,33 +93,43 @@ OBJECTS = $(shell ./busybox.sh) messages.o utility.o | |||
84 | CFLAGS += -DBB_VER='"$(VERSION)"' | 93 | CFLAGS += -DBB_VER='"$(VERSION)"' |
85 | CFLAGS += -DBB_BT='"$(BUILDTIME)"' | 94 | CFLAGS += -DBB_BT='"$(BUILDTIME)"' |
86 | ifdef BB_INIT_SCRIPT | 95 | ifdef BB_INIT_SCRIPT |
87 | CFLAGS += -DINIT_SCRIPT=${BB_INIT_SCRIPT} | 96 | CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"' |
88 | endif | 97 | endif |
89 | 98 | ||
90 | all: busybox busybox.links | 99 | all: busybox busybox.links |
100 | .PHONY: all | ||
91 | 101 | ||
92 | busybox: $(OBJECTS) | 102 | busybox: $(OBJECTS) |
93 | $(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES) | 103 | $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) |
94 | $(STRIP) | 104 | $(STRIP) $@ |
95 | 105 | ||
96 | busybox.links: busybox.def.h | 106 | busybox.links: busybox.def.h |
97 | - ./busybox.mkll | sort >$@ | 107 | - ./busybox.mkll | sort >$@ |
98 | 108 | ||
109 | regexp.o nfsmount.o: %.o: %.h | ||
110 | $(OBJECTS): %.o: busybox.def.h internal.h %.c | ||
111 | |||
112 | .PHONY: test tests | ||
113 | test tests: | ||
114 | cd tests && $(MAKE) all | ||
115 | |||
116 | .PHONY: clean | ||
99 | clean: | 117 | clean: |
100 | - rm -f $(PROG) busybox.links *~ *.o core | 118 | - rm -f busybox.links *~ *.o core |
101 | - rm -rf _install | 119 | - rm -rf _install |
120 | - cd tests && $(MAKE) clean | ||
102 | 121 | ||
122 | .PHONY: distclean | ||
103 | distclean: clean | 123 | distclean: clean |
104 | - rm -f $(PROG) | 124 | - rm -f busybox |
105 | 125 | - cd tests && $(MAKE) distclean | |
106 | $(OBJECTS): %.o: %.c busybox.def.h internal.h Makefile messages.c | ||
107 | 126 | ||
127 | .PHONY: install | ||
108 | install: busybox busybox.links | 128 | install: busybox busybox.links |
109 | ./install.sh $(PREFIX) | 129 | ./install.sh $(PREFIX) |
110 | 130 | ||
111 | dist: release | 131 | .PHONY: dist release |
112 | 132 | dist release: distclean | |
113 | release: distclean | ||
114 | cd ..; \ | 133 | cd ..; \ |
115 | rm -rf busybox-$(VERSION); \ | 134 | rm -rf busybox-$(VERSION); \ |
116 | cp -a busybox busybox-$(VERSION); \ | 135 | cp -a busybox busybox-$(VERSION); \ |
@@ -10,10 +10,6 @@ around to it some time. If you have any good ideas, please let me know. | |||
10 | separate package (named perhaps tiny-netkit?). This currently includes | 10 | separate package (named perhaps tiny-netkit?). This currently includes |
11 | hostid, hostname, mnc, and ping. | 11 | hostid, hostname, mnc, and ping. |
12 | 12 | ||
13 | * init's waitfor() calls wait() which can catch and ignore the wrong pid | ||
14 | exiting. That other process is then not restarted. | ||
15 | |||
16 | |||
17 | 13 | ||
18 | -Erik | 14 | -Erik |
19 | 15 | ||
@@ -22,7 +18,7 @@ around to it some time. If you have any good ideas, please let me know. | |||
22 | * Allow tar to create archives with sockets, devices, and other special files | 18 | * Allow tar to create archives with sockets, devices, and other special files |
23 | * Make insmod actually work | 19 | * Make insmod actually work |
24 | * dnsdomainname | 20 | * dnsdomainname |
25 | * traceroute/nslookup/netstat | 21 | * traceroute/netstat |
26 | * rdate | 22 | * rdate |
27 | * hwclock | 23 | * hwclock |
28 | * killall | 24 | * killall |
diff --git a/applets/install.sh b/applets/install.sh index 769d1f4a3..100b26bad 100755 --- a/applets/install.sh +++ b/applets/install.sh | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | set -e | 3 | set -e |
4 | 4 | ||
5 | if [ "$1" == "" ]; then | 5 | if [ "$1" = "" ]; then |
6 | echo "No installation directory, aborting." | 6 | echo "No installation directory, aborting." |
7 | exit 1; | 7 | exit 1; |
8 | fi | 8 | fi |
diff --git a/archival/gunzip.c b/archival/gunzip.c index 2bc490e3e..e1c8ac06e 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c | |||
@@ -194,7 +194,7 @@ extern int method; /* compression method */ | |||
194 | # define DECLARE(type, array, size) type * array | 194 | # define DECLARE(type, array, size) type * array |
195 | # define ALLOC(type, array, size) { \ | 195 | # define ALLOC(type, array, size) { \ |
196 | array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ | 196 | array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ |
197 | if (array == NULL) error("insufficient memory"); \ | 197 | if (array == NULL) errorMsg("insufficient memory"); \ |
198 | } | 198 | } |
199 | # define FREE(array) {if (array != NULL) free(array), array=NULL;} | 199 | # define FREE(array) {if (array != NULL) free(array), array=NULL;} |
200 | #else | 200 | #else |
@@ -311,7 +311,7 @@ extern int save_orig_name; /* set if original name must be saved */ | |||
311 | 311 | ||
312 | /* Diagnostic functions */ | 312 | /* Diagnostic functions */ |
313 | #ifdef DEBUG | 313 | #ifdef DEBUG |
314 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | 314 | # define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} |
315 | # define Trace(x) fprintf x | 315 | # define Trace(x) fprintf x |
316 | # define Tracev(x) {if (verbose) fprintf x ;} | 316 | # define Tracev(x) {if (verbose) fprintf x ;} |
317 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | 317 | # define Tracevv(x) {if (verbose>1) fprintf x ;} |
@@ -367,8 +367,6 @@ extern void write_buf OF((int fd, voidp buf, unsigned cnt)); | |||
367 | #ifndef __linux__ | 367 | #ifndef __linux__ |
368 | extern char *basename OF((char *fname)); | 368 | extern char *basename OF((char *fname)); |
369 | #endif /* not __linux__ */ | 369 | #endif /* not __linux__ */ |
370 | extern void error OF((char *m)); | ||
371 | extern void warn OF((char *a, char *b)); | ||
372 | extern void read_error OF((void)); | 370 | extern void read_error OF((void)); |
373 | extern void write_error OF((void)); | 371 | extern void write_error OF((void)); |
374 | 372 | ||
@@ -1045,13 +1043,13 @@ int in, out; /* input and output file descriptors */ | |||
1045 | int res = inflate(); | 1043 | int res = inflate(); |
1046 | 1044 | ||
1047 | if (res == 3) { | 1045 | if (res == 3) { |
1048 | error("out of memory"); | 1046 | errorMsg("out of memory"); |
1049 | } else if (res != 0) { | 1047 | } else if (res != 0) { |
1050 | error("invalid compressed data--format violated"); | 1048 | errorMsg("invalid compressed data--format violated"); |
1051 | } | 1049 | } |
1052 | 1050 | ||
1053 | } else { | 1051 | } else { |
1054 | error("internal error, invalid method"); | 1052 | errorMsg("internal error, invalid method"); |
1055 | } | 1053 | } |
1056 | 1054 | ||
1057 | /* Get the crc and original length */ | 1055 | /* Get the crc and original length */ |
@@ -1080,10 +1078,10 @@ int in, out; /* input and output file descriptors */ | |||
1080 | 1078 | ||
1081 | /* Validate decompression */ | 1079 | /* Validate decompression */ |
1082 | if (orig_crc != updcrc(outbuf, 0)) { | 1080 | if (orig_crc != updcrc(outbuf, 0)) { |
1083 | error("invalid compressed data--crc error"); | 1081 | errorMsg("invalid compressed data--crc error"); |
1084 | } | 1082 | } |
1085 | if (orig_len != (ulg) bytes_out) { | 1083 | if (orig_len != (ulg) bytes_out) { |
1086 | error("invalid compressed data--length error"); | 1084 | errorMsg("invalid compressed data--length error"); |
1087 | } | 1085 | } |
1088 | 1086 | ||
1089 | /* Check if there are more entries in a pkzip file */ | 1087 | /* Check if there are more entries in a pkzip file */ |
diff --git a/archival/gzip.c b/archival/gzip.c index f132679f7..e275fa274 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -125,7 +125,7 @@ extern int method; /* compression method */ | |||
125 | # define DECLARE(type, array, size) type * near array | 125 | # define DECLARE(type, array, size) type * near array |
126 | # define ALLOC(type, array, size) { \ | 126 | # define ALLOC(type, array, size) { \ |
127 | array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ | 127 | array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ |
128 | if (array == NULL) error("insufficient memory"); \ | 128 | if (array == NULL) errorMsg("insufficient memory"); \ |
129 | } | 129 | } |
130 | # define FREE(array) {if (array != NULL) fcfree(array), array=NULL;} | 130 | # define FREE(array) {if (array != NULL) fcfree(array), array=NULL;} |
131 | #else | 131 | #else |
@@ -262,7 +262,7 @@ extern int save_orig_name; /* set if original name must be saved */ | |||
262 | 262 | ||
263 | /* Diagnostic functions */ | 263 | /* Diagnostic functions */ |
264 | #ifdef DEBUG | 264 | #ifdef DEBUG |
265 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | 265 | # define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} |
266 | # define Trace(x) fprintf x | 266 | # define Trace(x) fprintf x |
267 | # define Tracev(x) {if (verbose) fprintf x ;} | 267 | # define Tracev(x) {if (verbose) fprintf x ;} |
268 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | 268 | # define Tracevv(x) {if (verbose>1) fprintf x ;} |
@@ -327,8 +327,6 @@ extern void flush_window OF((void)); | |||
327 | extern void write_buf OF((int fd, voidp buf, unsigned cnt)); | 327 | extern void write_buf OF((int fd, voidp buf, unsigned cnt)); |
328 | extern char *strlwr OF((char *s)); | 328 | extern char *strlwr OF((char *s)); |
329 | extern char *add_envopt OF((int *argcp, char ***argvp, char *env)); | 329 | extern char *add_envopt OF((int *argcp, char ***argvp, char *env)); |
330 | extern void error OF((char *m)); | ||
331 | extern void warn OF((char *a, char *b)); | ||
332 | extern void read_error OF((void)); | 330 | extern void read_error OF((void)); |
333 | extern void write_error OF((void)); | 331 | extern void write_error OF((void)); |
334 | extern void display_ratio OF((long num, long den, FILE * file)); | 332 | extern void display_ratio OF((long num, long den, FILE * file)); |
@@ -1396,7 +1394,7 @@ int length; | |||
1396 | (char *) window + start, length) != EQUAL) { | 1394 | (char *) window + start, length) != EQUAL) { |
1397 | fprintf(stderr, | 1395 | fprintf(stderr, |
1398 | " start %d, match %d, length %d\n", start, match, length); | 1396 | " start %d, match %d, length %d\n", start, match, length); |
1399 | error("invalid match"); | 1397 | errorMsg("invalid match"); |
1400 | } | 1398 | } |
1401 | if (verbose > 1) { | 1399 | if (verbose > 1) { |
1402 | fprintf(stderr, "\\[%d,%d]", start - match, length); | 1400 | fprintf(stderr, "\\[%d,%d]", start - match, length); |
@@ -2916,7 +2914,7 @@ int eof; /* true if this is the last block for a file */ | |||
2916 | #endif | 2914 | #endif |
2917 | /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ | 2915 | /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ |
2918 | if (buf == (char *) 0) | 2916 | if (buf == (char *) 0) |
2919 | error("block vanished"); | 2917 | errorMsg("block vanished"); |
2920 | 2918 | ||
2921 | copy_block(buf, (unsigned) stored_len, 0); /* without header */ | 2919 | copy_block(buf, (unsigned) stored_len, 0); /* without header */ |
2922 | compressed_len = stored_len << 3; | 2920 | compressed_len = stored_len << 3; |
@@ -3099,7 +3097,7 @@ local void set_file_type() | |||
3099 | bin_freq += dyn_ltree[n++].Freq; | 3097 | bin_freq += dyn_ltree[n++].Freq; |
3100 | *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; | 3098 | *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; |
3101 | if (*file_type == BINARY && translate_eol) { | 3099 | if (*file_type == BINARY && translate_eol) { |
3102 | warn("-l used on binary file", ""); | 3100 | errorMsg("-l used on binary file", ""); |
3103 | } | 3101 | } |
3104 | } | 3102 | } |
3105 | 3103 | ||
@@ -3259,13 +3257,13 @@ char *env; /* name of environment variable */ | |||
3259 | nargv = (char **) calloc(*argcp + 1, sizeof(char *)); | 3257 | nargv = (char **) calloc(*argcp + 1, sizeof(char *)); |
3260 | 3258 | ||
3261 | if (nargv == NULL) | 3259 | if (nargv == NULL) |
3262 | error("out of memory"); | 3260 | errorMsg("out of memory"); |
3263 | oargv = *argvp; | 3261 | oargv = *argvp; |
3264 | *argvp = nargv; | 3262 | *argvp = nargv; |
3265 | 3263 | ||
3266 | /* Copy the program name first */ | 3264 | /* Copy the program name first */ |
3267 | if (oargc-- < 0) | 3265 | if (oargc-- < 0) |
3268 | error("argc<=0"); | 3266 | errorMsg("argc<=0"); |
3269 | *(nargv++) = *(oargv++); | 3267 | *(nargv++) = *(oargv++); |
3270 | 3268 | ||
3271 | /* Then copy the environment args */ | 3269 | /* Then copy the environment args */ |
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index d5e67b599..f037e9591 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c | |||
@@ -81,9 +81,7 @@ static int fileAction(const char *fileName, struct stat *statbuf) | |||
81 | case CHMOD_APP: | 81 | case CHMOD_APP: |
82 | /* Parse the specified modes */ | 82 | /* Parse the specified modes */ |
83 | if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) { | 83 | if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) { |
84 | fprintf(stderr, "%s: unknown mode: %s\n", invocationName, | 84 | fatalError( "%s: unknown mode: %s\n", invocationName, theMode); |
85 | theMode); | ||
86 | exit(FALSE); | ||
87 | } | 85 | } |
88 | if (chmod(fileName, statbuf->st_mode) == 0) | 86 | if (chmod(fileName, statbuf->st_mode) == 0) |
89 | return (TRUE); | 87 | return (TRUE); |
@@ -101,14 +99,13 @@ int chmod_chown_chgrp_main(int argc, char **argv) | |||
101 | const char *appUsage; | 99 | const char *appUsage; |
102 | 100 | ||
103 | whichApp = | 101 | whichApp = |
104 | (strcmp(*argv, "chown") == | 102 | (strcmp(*argv, "chown") == 0)? |
105 | 0) ? CHOWN_APP : (strcmp(*argv, | 103 | CHOWN_APP : (strcmp(*argv, "chmod") == 0)? |
106 | "chmod") == 0) ? CHMOD_APP : CHGRP_APP; | 104 | CHMOD_APP : CHGRP_APP; |
107 | 105 | ||
108 | appUsage = | 106 | appUsage = |
109 | (whichApp == CHOWN_APP) ? chown_usage : (whichApp == | 107 | (whichApp == CHOWN_APP)? |
110 | CHMOD_APP) ? chmod_usage : | 108 | chown_usage : (whichApp == CHMOD_APP) ? chmod_usage : chgrp_usage; |
111 | chgrp_usage; | ||
112 | 109 | ||
113 | if (argc < 2) | 110 | if (argc < 2) |
114 | usage(appUsage); | 111 | usage(appUsage); |
@@ -163,17 +160,15 @@ int chmod_chown_chgrp_main(int argc, char **argv) | |||
163 | if (*argv == p) | 160 | if (*argv == p) |
164 | uid = my_getpwnam(*argv); | 161 | uid = my_getpwnam(*argv); |
165 | if (uid == -1) { | 162 | if (uid == -1) { |
166 | fprintf(stderr, "%s: unknown user name: %s\n", | 163 | fatalError( "%s: unknown user name: %s\n", |
167 | invocationName, *argv); | 164 | invocationName, *argv); |
168 | exit(FALSE); | ||
169 | } | 165 | } |
170 | } | 166 | } |
171 | } | 167 | } |
172 | 168 | ||
173 | /* Ok, ready to do the deed now */ | 169 | /* Ok, ready to do the deed now */ |
174 | if (argc <= 1) { | 170 | if (argc <= 1) { |
175 | fprintf(stderr, "%s: too few arguments\n", invocationName); | 171 | fatalError( "%s: too few arguments\n", invocationName); |
176 | exit(FALSE); | ||
177 | } | 172 | } |
178 | while (argc-- > 1) { | 173 | while (argc-- > 1) { |
179 | if (recursiveAction | 174 | if (recursiveAction |
@@ -184,7 +179,5 @@ int chmod_chown_chgrp_main(int argc, char **argv) | |||
184 | exit(TRUE); | 179 | exit(TRUE); |
185 | 180 | ||
186 | bad_group: | 181 | bad_group: |
187 | fprintf(stderr, "%s: unknown group name: %s\n", invocationName, | 182 | fatalError( "%s: unknown group name: %s\n", invocationName, groupName); |
188 | groupName); | ||
189 | exit(FALSE); | ||
190 | } | 183 | } |
diff --git a/coreutils/du.c b/coreutils/du.c index 7151e3a9c..912605882 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
@@ -72,6 +72,10 @@ static long du(char *filename) | |||
72 | du_depth++; | 72 | du_depth++; |
73 | sum = statbuf.st_blocks; | 73 | sum = statbuf.st_blocks; |
74 | 74 | ||
75 | /* Don't add in stuff pointed to by links */ | ||
76 | if (S_ISLNK(statbuf.st_mode)) { | ||
77 | return 0; | ||
78 | } | ||
75 | if (S_ISDIR(statbuf.st_mode)) { | 79 | if (S_ISDIR(statbuf.st_mode)) { |
76 | DIR *dir; | 80 | DIR *dir; |
77 | struct dirent *entry; | 81 | struct dirent *entry; |
@@ -140,7 +144,7 @@ int du_main(int argc, char **argv) | |||
140 | 144 | ||
141 | for (; i < argc; i++) { | 145 | for (; i < argc; i++) { |
142 | sum = du(argv[i]); | 146 | sum = du(argv[i]); |
143 | if ((sum) && (isDirectory(argv[i], FALSE))) { | 147 | if ((sum) && (isDirectory(argv[i], FALSE, NULL))) { |
144 | print_normal(sum, argv[i]); | 148 | print_normal(sum, argv[i]); |
145 | } | 149 | } |
146 | } | 150 | } |
@@ -149,4 +153,4 @@ int du_main(int argc, char **argv) | |||
149 | exit(0); | 153 | exit(0); |
150 | } | 154 | } |
151 | 155 | ||
152 | /* $Id: du.c,v 1.11 2000/02/08 19:58:47 erik Exp $ */ | 156 | /* $Id: du.c,v 1.12 2000/02/11 21:55:04 erik Exp $ */ |
diff --git a/coreutils/ln.c b/coreutils/ln.c index bc51cb0d5..0715bfaed 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c | |||
@@ -84,7 +84,7 @@ extern int ln_main(int argc, char **argv) | |||
84 | exit FALSE; | 84 | exit FALSE; |
85 | } | 85 | } |
86 | 86 | ||
87 | linkIntoDirFlag = isDirectory(linkName, TRUE); | 87 | linkIntoDirFlag = isDirectory(linkName, TRUE, NULL); |
88 | 88 | ||
89 | if ((argc > 3) && !linkIntoDirFlag) { | 89 | if ((argc > 3) && !linkIntoDirFlag) { |
90 | fprintf(stderr, not_a_directory, "ln", linkName); | 90 | fprintf(stderr, not_a_directory, "ln", linkName); |
diff --git a/coreutils/ls.c b/coreutils/ls.c index f23c1e086..c2266f533 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -29,10 +29,10 @@ | |||
29 | * it more portable. | 29 | * it more portable. |
30 | * | 30 | * |
31 | * KNOWN BUGS: | 31 | * KNOWN BUGS: |
32 | * 1. messy output if you mix files and directories on the command line | 32 | * 1. ls -l of a directory doesn't give "total <blocks>" header |
33 | * 2. ls -l of a directory doesn't give "total <blocks>" header | 33 | * 2. ls of a symlink to a directory doesn't list directory contents |
34 | * 3. ls of a symlink to a directory doesn't list directory contents | 34 | * 3. hidden files can make column width too large |
35 | * 4. hidden files can make column width too large | 35 | * |
36 | * NON-OPTIMAL BEHAVIOUR: | 36 | * NON-OPTIMAL BEHAVIOUR: |
37 | * 1. autowidth reads directories twice | 37 | * 1. autowidth reads directories twice |
38 | * 2. if you do a short directory listing without filetype characters | 38 | * 2. if you do a short directory listing without filetype characters |
@@ -100,7 +100,9 @@ static unsigned short opts = 0; | |||
100 | static unsigned short column = 0; | 100 | static unsigned short column = 0; |
101 | 101 | ||
102 | #ifdef BB_FEATURE_AUTOWIDTH | 102 | #ifdef BB_FEATURE_AUTOWIDTH |
103 | static unsigned short terminal_width = 0, column_width = 0; | 103 | static unsigned short terminal_width = 0; |
104 | static unsigned short column_width = 0; | ||
105 | static unsigned short toplevel_column_width = 0; | ||
104 | #else | 106 | #else |
105 | #define terminal_width TERMINAL_WIDTH | 107 | #define terminal_width TERMINAL_WIDTH |
106 | #define column_width COLUMN_WIDTH | 108 | #define column_width COLUMN_WIDTH |
@@ -349,6 +351,9 @@ static int list_item(const char *name) | |||
349 | goto listerr; | 351 | goto listerr; |
350 | 352 | ||
351 | if (!S_ISDIR(info.st_mode) || (opts & DIR_NOLIST)) { | 353 | if (!S_ISDIR(info.st_mode) || (opts & DIR_NOLIST)) { |
354 | #ifdef BB_FEATURE_AUTOWIDTH | ||
355 | column_width = toplevel_column_width; | ||
356 | #endif | ||
352 | list_single(name, &info, name); | 357 | list_single(name, &info, name); |
353 | return 0; | 358 | return 0; |
354 | } | 359 | } |
@@ -407,6 +412,15 @@ static int list_item(const char *name) | |||
407 | list_single(entry->d_name, &info, fullname); | 412 | list_single(entry->d_name, &info, fullname); |
408 | } | 413 | } |
409 | closedir(dir); | 414 | closedir(dir); |
415 | |||
416 | if (opts & DISP_DIRNAME) { /* separate the directory */ | ||
417 | if (column) { | ||
418 | wr("\n", 1); | ||
419 | } | ||
420 | wr("\n", 1); | ||
421 | column = 0; | ||
422 | } | ||
423 | |||
410 | return 0; | 424 | return 0; |
411 | 425 | ||
412 | direrr: | 426 | direrr: |
@@ -530,8 +544,8 @@ extern int ls_main(int argc, char **argv) | |||
530 | for (i = argi; i < argc; i++) { | 544 | for (i = argi; i < argc; i++) { |
531 | int len = strlen(argv[i]); | 545 | int len = strlen(argv[i]); |
532 | 546 | ||
533 | if (column_width < len) | 547 | if (toplevel_column_width < len) |
534 | column_width = len; | 548 | toplevel_column_width = len; |
535 | } | 549 | } |
536 | #endif | 550 | #endif |
537 | 551 | ||
diff --git a/coreutils/tail.c b/coreutils/tail.c index 31705afa2..821244f9e 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | #include "internal.h" | 2 | #include "internal.h" |
3 | |||
3 | /* This file contains _two_ implementations of tail. One is | 4 | /* This file contains _two_ implementations of tail. One is |
4 | * a bit more full featured, but costs 6k. The other (i.e. the | 5 | * a bit more full featured, but costs 6k. The other (i.e. the |
5 | * SIMPLE_TAIL one) is less capable, but is good enough for about | 6 | * SIMPLE_TAIL one) is less capable, but is good enough for about |
@@ -51,7 +52,7 @@ | |||
51 | #define XWRITE(fd, buffer, n_bytes) \ | 52 | #define XWRITE(fd, buffer, n_bytes) \ |
52 | do { \ | 53 | do { \ |
53 | if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \ | 54 | if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \ |
54 | error("write error"); \ | 55 | errorMsg("write error"); \ |
55 | } while (0) | 56 | } while (0) |
56 | 57 | ||
57 | /* Number of items to tail. */ | 58 | /* Number of items to tail. */ |
@@ -117,7 +118,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos) | |||
117 | lseek(fd, pos, SEEK_SET); | 118 | lseek(fd, pos, SEEK_SET); |
118 | bytes_read = fullRead(fd, buffer, bytes_read); | 119 | bytes_read = fullRead(fd, buffer, bytes_read); |
119 | if (bytes_read == -1) | 120 | if (bytes_read == -1) |
120 | error("read error"); | 121 | errorMsg("read error"); |
121 | 122 | ||
122 | /* Count the incomplete line on files that don't end with a newline. */ | 123 | /* Count the incomplete line on files that don't end with a newline. */ |
123 | if (bytes_read && buffer[bytes_read - 1] != '\n') | 124 | if (bytes_read && buffer[bytes_read - 1] != '\n') |
@@ -147,7 +148,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos) | |||
147 | } | 148 | } |
148 | while ((bytes_read = fullRead(fd, buffer, BUFSIZ)) > 0); | 149 | while ((bytes_read = fullRead(fd, buffer, BUFSIZ)) > 0); |
149 | if (bytes_read == -1) | 150 | if (bytes_read == -1) |
150 | error("read error"); | 151 | errorMsg("read error"); |
151 | 152 | ||
152 | return 0; | 153 | return 0; |
153 | } | 154 | } |
@@ -209,7 +210,7 @@ static int pipe_lines(const char *filename, int fd, long int n_lines) | |||
209 | } | 210 | } |
210 | } | 211 | } |
211 | if (tmp->nbytes == -1) | 212 | if (tmp->nbytes == -1) |
212 | error("read error"); | 213 | errorMsg("read error"); |
213 | 214 | ||
214 | free((char *) tmp); | 215 | free((char *) tmp); |
215 | 216 | ||
@@ -272,7 +273,7 @@ static long dump_remainder(const char *filename, int fd) | |||
272 | total += bytes_read; | 273 | total += bytes_read; |
273 | } | 274 | } |
274 | if (bytes_read == -1) | 275 | if (bytes_read == -1) |
275 | error("read error"); | 276 | errorMsg("read error"); |
276 | if (forever) { | 277 | if (forever) { |
277 | fflush(stdout); | 278 | fflush(stdout); |
278 | sleep(1); | 279 | sleep(1); |
@@ -294,7 +295,7 @@ static int tail_lines(const char *filename, int fd, long int n_lines) | |||
294 | write_header(filename); | 295 | write_header(filename); |
295 | 296 | ||
296 | if (fstat(fd, &stats)) | 297 | if (fstat(fd, &stats)) |
297 | error("fstat error"); | 298 | errorMsg("fstat error"); |
298 | 299 | ||
299 | /* Use file_lines only if FD refers to a regular file with | 300 | /* Use file_lines only if FD refers to a regular file with |
300 | its file pointer positioned at beginning of file. */ | 301 | its file pointer positioned at beginning of file. */ |
@@ -329,7 +330,7 @@ static int tail_file(const char *filename, off_t n_units) | |||
329 | /* Not standard input. */ | 330 | /* Not standard input. */ |
330 | fd = open(filename, O_RDONLY); | 331 | fd = open(filename, O_RDONLY); |
331 | if (fd == -1) | 332 | if (fd == -1) |
332 | error("open error"); | 333 | errorMsg("open error"); |
333 | 334 | ||
334 | errors = tail_lines(filename, fd, (long) n_units); | 335 | errors = tail_lines(filename, fd, (long) n_units); |
335 | close(fd); | 336 | close(fd); |
@@ -69,10 +69,12 @@ extern int cp_mv_main(int argc, char **argv) | |||
69 | 69 | ||
70 | const char *baseSrcName; | 70 | const char *baseSrcName; |
71 | int srcDirFlag; | 71 | int srcDirFlag; |
72 | struct stat srcStatBuf; | ||
72 | 73 | ||
73 | char baseDestName[PATH_MAX + 1]; | 74 | char baseDestName[PATH_MAX + 1]; |
74 | size_t baseDestLen; | 75 | size_t baseDestLen; |
75 | int destDirFlag; | 76 | int destDirFlag; |
77 | struct stat destStatBuf; | ||
76 | 78 | ||
77 | void fill_baseDest_buf(char *_buf, size_t * _buflen) { | 79 | void fill_baseDest_buf(char *_buf, size_t * _buflen) { |
78 | const char *srcBasename; | 80 | const char *srcBasename; |
@@ -91,7 +93,6 @@ extern int cp_mv_main(int argc, char **argv) | |||
91 | } | 93 | } |
92 | 94 | ||
93 | int fileAction(const char *fileName, struct stat *statbuf) { | 95 | int fileAction(const char *fileName, struct stat *statbuf) { |
94 | __label__ return_false; | ||
95 | char destName[PATH_MAX + 1]; | 96 | char destName[PATH_MAX + 1]; |
96 | size_t destLen; | 97 | size_t destLen; |
97 | const char *srcBasename; | 98 | const char *srcBasename; |
@@ -109,7 +110,7 @@ extern int cp_mv_main(int argc, char **argv) | |||
109 | 110 | ||
110 | if (destLen + strlen(srcBasename) > PATH_MAX) { | 111 | if (destLen + strlen(srcBasename) > PATH_MAX) { |
111 | fprintf(stderr, name_too_long, "cp"); | 112 | fprintf(stderr, name_too_long, "cp"); |
112 | goto return_false; | 113 | return FALSE; |
113 | } | 114 | } |
114 | strcat(destName, srcBasename); | 115 | strcat(destName, srcBasename); |
115 | } else if (destDirFlag == TRUE) { | 116 | } else if (destDirFlag == TRUE) { |
@@ -118,9 +119,6 @@ extern int cp_mv_main(int argc, char **argv) | |||
118 | srcBasename = baseSrcName; | 119 | srcBasename = baseSrcName; |
119 | } | 120 | } |
120 | return copyFile(fileName, destName, preserveFlag, followLinks); | 121 | return copyFile(fileName, destName, preserveFlag, followLinks); |
121 | |||
122 | return_false: | ||
123 | return FALSE; | ||
124 | } | 122 | } |
125 | 123 | ||
126 | int rmfileAction(const char *fileName, struct stat *statbuf) { | 124 | int rmfileAction(const char *fileName, struct stat *statbuf) { |
@@ -180,7 +178,6 @@ extern int cp_mv_main(int argc, char **argv) | |||
180 | argv++; | 178 | argv++; |
181 | } | 179 | } |
182 | } else { /* (dz_i == is_mv) */ | 180 | } else { /* (dz_i == is_mv) */ |
183 | |||
184 | recursiveFlag = preserveFlag = TRUE; | 181 | recursiveFlag = preserveFlag = TRUE; |
185 | followLinks = FALSE; | 182 | followLinks = FALSE; |
186 | } | 183 | } |
@@ -194,7 +191,7 @@ extern int cp_mv_main(int argc, char **argv) | |||
194 | if (baseDestLen == 0) | 191 | if (baseDestLen == 0) |
195 | goto exit_false; | 192 | goto exit_false; |
196 | 193 | ||
197 | destDirFlag = isDirectory(baseDestName, TRUE); | 194 | destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf); |
198 | if ((argc > 3) && destDirFlag == FALSE) { | 195 | if ((argc > 3) && destDirFlag == FALSE) { |
199 | fprintf(stderr, not_a_directory, "cp", baseDestName); | 196 | fprintf(stderr, not_a_directory, "cp", baseDestName); |
200 | goto exit_false; | 197 | goto exit_false; |
@@ -212,11 +209,18 @@ extern int cp_mv_main(int argc, char **argv) | |||
212 | if (srcLen == 0) | 209 | if (srcLen == 0) |
213 | continue; | 210 | continue; |
214 | 211 | ||
215 | srcDirFlag = isDirectory(baseSrcName, followLinks); | 212 | srcDirFlag = isDirectory(baseSrcName, followLinks, &srcStatBuf); |
216 | 213 | ||
217 | if ((flags_memo = (recursiveFlag == TRUE && | 214 | if ((flags_memo = (recursiveFlag == TRUE && |
218 | srcDirFlag == TRUE && destDirFlag == TRUE))) { | 215 | srcDirFlag == TRUE && destDirFlag == TRUE))) { |
219 | fill_baseDest_buf(&baseDestName[0], &baseDestLen); | 216 | if ((destStatBuf.st_ino == srcStatBuf.st_ino) && |
217 | (destStatBuf.st_rdev == srcStatBuf.st_rdev)) { | ||
218 | fprintf(stderr, | ||
219 | "%s: Cannot %s `%s' into a subdirectory of itself, `%s/%s'\n", | ||
220 | dz, dz, baseSrcName, baseDestName, baseSrcName); | ||
221 | continue; | ||
222 | } | ||
223 | fill_baseDest_buf(baseDestName, &baseDestLen); | ||
220 | } | 224 | } |
221 | if (recursiveAction(baseSrcName, | 225 | if (recursiveAction(baseSrcName, |
222 | recursiveFlag, followLinks, FALSE, | 226 | recursiveFlag, followLinks, FALSE, |
@@ -242,6 +246,6 @@ extern int cp_mv_main(int argc, char **argv) | |||
242 | } | 246 | } |
243 | 247 | ||
244 | // Local Variables: | 248 | // Local Variables: |
245 | // c-file-style: "k&r" | 249 | // c-file-style: "linux" |
246 | // c-basic-offset: 4 | 250 | // tab-width: 4 |
247 | // End: | 251 | // End: |
@@ -72,6 +72,10 @@ static long du(char *filename) | |||
72 | du_depth++; | 72 | du_depth++; |
73 | sum = statbuf.st_blocks; | 73 | sum = statbuf.st_blocks; |
74 | 74 | ||
75 | /* Don't add in stuff pointed to by links */ | ||
76 | if (S_ISLNK(statbuf.st_mode)) { | ||
77 | return 0; | ||
78 | } | ||
75 | if (S_ISDIR(statbuf.st_mode)) { | 79 | if (S_ISDIR(statbuf.st_mode)) { |
76 | DIR *dir; | 80 | DIR *dir; |
77 | struct dirent *entry; | 81 | struct dirent *entry; |
@@ -140,7 +144,7 @@ int du_main(int argc, char **argv) | |||
140 | 144 | ||
141 | for (; i < argc; i++) { | 145 | for (; i < argc; i++) { |
142 | sum = du(argv[i]); | 146 | sum = du(argv[i]); |
143 | if ((sum) && (isDirectory(argv[i], FALSE))) { | 147 | if ((sum) && (isDirectory(argv[i], FALSE, NULL))) { |
144 | print_normal(sum, argv[i]); | 148 | print_normal(sum, argv[i]); |
145 | } | 149 | } |
146 | } | 150 | } |
@@ -149,4 +153,4 @@ int du_main(int argc, char **argv) | |||
149 | exit(0); | 153 | exit(0); |
150 | } | 154 | } |
151 | 155 | ||
152 | /* $Id: du.c,v 1.11 2000/02/08 19:58:47 erik Exp $ */ | 156 | /* $Id: du.c,v 1.12 2000/02/11 21:55:04 erik Exp $ */ |
@@ -194,7 +194,7 @@ extern int method; /* compression method */ | |||
194 | # define DECLARE(type, array, size) type * array | 194 | # define DECLARE(type, array, size) type * array |
195 | # define ALLOC(type, array, size) { \ | 195 | # define ALLOC(type, array, size) { \ |
196 | array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ | 196 | array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ |
197 | if (array == NULL) error("insufficient memory"); \ | 197 | if (array == NULL) errorMsg("insufficient memory"); \ |
198 | } | 198 | } |
199 | # define FREE(array) {if (array != NULL) free(array), array=NULL;} | 199 | # define FREE(array) {if (array != NULL) free(array), array=NULL;} |
200 | #else | 200 | #else |
@@ -311,7 +311,7 @@ extern int save_orig_name; /* set if original name must be saved */ | |||
311 | 311 | ||
312 | /* Diagnostic functions */ | 312 | /* Diagnostic functions */ |
313 | #ifdef DEBUG | 313 | #ifdef DEBUG |
314 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | 314 | # define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} |
315 | # define Trace(x) fprintf x | 315 | # define Trace(x) fprintf x |
316 | # define Tracev(x) {if (verbose) fprintf x ;} | 316 | # define Tracev(x) {if (verbose) fprintf x ;} |
317 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | 317 | # define Tracevv(x) {if (verbose>1) fprintf x ;} |
@@ -367,8 +367,6 @@ extern void write_buf OF((int fd, voidp buf, unsigned cnt)); | |||
367 | #ifndef __linux__ | 367 | #ifndef __linux__ |
368 | extern char *basename OF((char *fname)); | 368 | extern char *basename OF((char *fname)); |
369 | #endif /* not __linux__ */ | 369 | #endif /* not __linux__ */ |
370 | extern void error OF((char *m)); | ||
371 | extern void warn OF((char *a, char *b)); | ||
372 | extern void read_error OF((void)); | 370 | extern void read_error OF((void)); |
373 | extern void write_error OF((void)); | 371 | extern void write_error OF((void)); |
374 | 372 | ||
@@ -1045,13 +1043,13 @@ int in, out; /* input and output file descriptors */ | |||
1045 | int res = inflate(); | 1043 | int res = inflate(); |
1046 | 1044 | ||
1047 | if (res == 3) { | 1045 | if (res == 3) { |
1048 | error("out of memory"); | 1046 | errorMsg("out of memory"); |
1049 | } else if (res != 0) { | 1047 | } else if (res != 0) { |
1050 | error("invalid compressed data--format violated"); | 1048 | errorMsg("invalid compressed data--format violated"); |
1051 | } | 1049 | } |
1052 | 1050 | ||
1053 | } else { | 1051 | } else { |
1054 | error("internal error, invalid method"); | 1052 | errorMsg("internal error, invalid method"); |
1055 | } | 1053 | } |
1056 | 1054 | ||
1057 | /* Get the crc and original length */ | 1055 | /* Get the crc and original length */ |
@@ -1080,10 +1078,10 @@ int in, out; /* input and output file descriptors */ | |||
1080 | 1078 | ||
1081 | /* Validate decompression */ | 1079 | /* Validate decompression */ |
1082 | if (orig_crc != updcrc(outbuf, 0)) { | 1080 | if (orig_crc != updcrc(outbuf, 0)) { |
1083 | error("invalid compressed data--crc error"); | 1081 | errorMsg("invalid compressed data--crc error"); |
1084 | } | 1082 | } |
1085 | if (orig_len != (ulg) bytes_out) { | 1083 | if (orig_len != (ulg) bytes_out) { |
1086 | error("invalid compressed data--length error"); | 1084 | errorMsg("invalid compressed data--length error"); |
1087 | } | 1085 | } |
1088 | 1086 | ||
1089 | /* Check if there are more entries in a pkzip file */ | 1087 | /* Check if there are more entries in a pkzip file */ |
@@ -125,7 +125,7 @@ extern int method; /* compression method */ | |||
125 | # define DECLARE(type, array, size) type * near array | 125 | # define DECLARE(type, array, size) type * near array |
126 | # define ALLOC(type, array, size) { \ | 126 | # define ALLOC(type, array, size) { \ |
127 | array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ | 127 | array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ |
128 | if (array == NULL) error("insufficient memory"); \ | 128 | if (array == NULL) errorMsg("insufficient memory"); \ |
129 | } | 129 | } |
130 | # define FREE(array) {if (array != NULL) fcfree(array), array=NULL;} | 130 | # define FREE(array) {if (array != NULL) fcfree(array), array=NULL;} |
131 | #else | 131 | #else |
@@ -262,7 +262,7 @@ extern int save_orig_name; /* set if original name must be saved */ | |||
262 | 262 | ||
263 | /* Diagnostic functions */ | 263 | /* Diagnostic functions */ |
264 | #ifdef DEBUG | 264 | #ifdef DEBUG |
265 | # define Assert(cond,msg) {if(!(cond)) error(msg);} | 265 | # define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} |
266 | # define Trace(x) fprintf x | 266 | # define Trace(x) fprintf x |
267 | # define Tracev(x) {if (verbose) fprintf x ;} | 267 | # define Tracev(x) {if (verbose) fprintf x ;} |
268 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | 268 | # define Tracevv(x) {if (verbose>1) fprintf x ;} |
@@ -327,8 +327,6 @@ extern void flush_window OF((void)); | |||
327 | extern void write_buf OF((int fd, voidp buf, unsigned cnt)); | 327 | extern void write_buf OF((int fd, voidp buf, unsigned cnt)); |
328 | extern char *strlwr OF((char *s)); | 328 | extern char *strlwr OF((char *s)); |
329 | extern char *add_envopt OF((int *argcp, char ***argvp, char *env)); | 329 | extern char *add_envopt OF((int *argcp, char ***argvp, char *env)); |
330 | extern void error OF((char *m)); | ||
331 | extern void warn OF((char *a, char *b)); | ||
332 | extern void read_error OF((void)); | 330 | extern void read_error OF((void)); |
333 | extern void write_error OF((void)); | 331 | extern void write_error OF((void)); |
334 | extern void display_ratio OF((long num, long den, FILE * file)); | 332 | extern void display_ratio OF((long num, long den, FILE * file)); |
@@ -1396,7 +1394,7 @@ int length; | |||
1396 | (char *) window + start, length) != EQUAL) { | 1394 | (char *) window + start, length) != EQUAL) { |
1397 | fprintf(stderr, | 1395 | fprintf(stderr, |
1398 | " start %d, match %d, length %d\n", start, match, length); | 1396 | " start %d, match %d, length %d\n", start, match, length); |
1399 | error("invalid match"); | 1397 | errorMsg("invalid match"); |
1400 | } | 1398 | } |
1401 | if (verbose > 1) { | 1399 | if (verbose > 1) { |
1402 | fprintf(stderr, "\\[%d,%d]", start - match, length); | 1400 | fprintf(stderr, "\\[%d,%d]", start - match, length); |
@@ -2916,7 +2914,7 @@ int eof; /* true if this is the last block for a file */ | |||
2916 | #endif | 2914 | #endif |
2917 | /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ | 2915 | /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ |
2918 | if (buf == (char *) 0) | 2916 | if (buf == (char *) 0) |
2919 | error("block vanished"); | 2917 | errorMsg("block vanished"); |
2920 | 2918 | ||
2921 | copy_block(buf, (unsigned) stored_len, 0); /* without header */ | 2919 | copy_block(buf, (unsigned) stored_len, 0); /* without header */ |
2922 | compressed_len = stored_len << 3; | 2920 | compressed_len = stored_len << 3; |
@@ -3099,7 +3097,7 @@ local void set_file_type() | |||
3099 | bin_freq += dyn_ltree[n++].Freq; | 3097 | bin_freq += dyn_ltree[n++].Freq; |
3100 | *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; | 3098 | *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; |
3101 | if (*file_type == BINARY && translate_eol) { | 3099 | if (*file_type == BINARY && translate_eol) { |
3102 | warn("-l used on binary file", ""); | 3100 | errorMsg("-l used on binary file", ""); |
3103 | } | 3101 | } |
3104 | } | 3102 | } |
3105 | 3103 | ||
@@ -3259,13 +3257,13 @@ char *env; /* name of environment variable */ | |||
3259 | nargv = (char **) calloc(*argcp + 1, sizeof(char *)); | 3257 | nargv = (char **) calloc(*argcp + 1, sizeof(char *)); |
3260 | 3258 | ||
3261 | if (nargv == NULL) | 3259 | if (nargv == NULL) |
3262 | error("out of memory"); | 3260 | errorMsg("out of memory"); |
3263 | oargv = *argvp; | 3261 | oargv = *argvp; |
3264 | *argvp = nargv; | 3262 | *argvp = nargv; |
3265 | 3263 | ||
3266 | /* Copy the program name first */ | 3264 | /* Copy the program name first */ |
3267 | if (oargc-- < 0) | 3265 | if (oargc-- < 0) |
3268 | error("argc<=0"); | 3266 | errorMsg("argc<=0"); |
3269 | *(nargv++) = *(oargv++); | 3267 | *(nargv++) = *(oargv++); |
3270 | 3268 | ||
3271 | /* Then copy the environment args */ | 3269 | /* Then copy the environment args */ |
diff --git a/install.sh b/install.sh index 769d1f4a3..100b26bad 100755 --- a/install.sh +++ b/install.sh | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | set -e | 3 | set -e |
4 | 4 | ||
5 | if [ "$1" == "" ]; then | 5 | if [ "$1" = "" ]; then |
6 | echo "No installation directory, aborting." | 6 | echo "No installation directory, aborting." |
7 | exit 1; | 7 | exit 1; |
8 | fi | 8 | fi |
diff --git a/internal.h b/internal.h index 090fcc8fb..c2e77d4ab 100644 --- a/internal.h +++ b/internal.h | |||
@@ -144,9 +144,13 @@ extern int whoami_main(int argc, char** argv); | |||
144 | extern int yes_main(int argc, char** argv); | 144 | extern int yes_main(int argc, char** argv); |
145 | 145 | ||
146 | 146 | ||
147 | extern void usage(const char *usage) __attribute__ ((noreturn)); | ||
148 | extern void errorMsg(char *s, ...); | ||
149 | extern void fatalError(char *s, ...) __attribute__ ((noreturn)); | ||
150 | |||
147 | const char *modeString(int mode); | 151 | const char *modeString(int mode); |
148 | const char *timeString(time_t timeVal); | 152 | const char *timeString(time_t timeVal); |
149 | int isDirectory(const char *name, const int followLinks); | 153 | int isDirectory(const char *name, const int followLinks, struct stat *statBuf); |
150 | int isDevice(const char *name); | 154 | int isDevice(const char *name); |
151 | int copyFile(const char *srcName, const char *destName, int setModes, | 155 | int copyFile(const char *srcName, const char *destName, int setModes, |
152 | int followLinks); | 156 | int followLinks); |
@@ -164,7 +168,6 @@ const char* timeString(time_t timeVal); | |||
164 | 168 | ||
165 | extern int createPath (const char *name, int mode); | 169 | extern int createPath (const char *name, int mode); |
166 | extern int parse_mode( const char* s, mode_t* theMode); | 170 | extern int parse_mode( const char* s, mode_t* theMode); |
167 | extern void usage(const char *usage) __attribute__ ((noreturn)); | ||
168 | 171 | ||
169 | extern uid_t my_getpwnam(char *name); | 172 | extern uid_t my_getpwnam(char *name); |
170 | extern gid_t my_getgrnam(char *name); | 173 | extern gid_t my_getgrnam(char *name); |
@@ -184,6 +187,7 @@ extern char *mtab_getinfo(const char *match, const char which); | |||
184 | extern int check_wildcard_match(const char* text, const char* pattern); | 187 | extern int check_wildcard_match(const char* text, const char* pattern); |
185 | extern long getNum (const char *cp); | 188 | extern long getNum (const char *cp); |
186 | extern pid_t findInitPid(); | 189 | extern pid_t findInitPid(); |
190 | extern void *xmalloc (size_t size); | ||
187 | #if defined BB_INIT || defined BB_SYSLOGD | 191 | #if defined BB_INIT || defined BB_SYSLOGD |
188 | extern int device_open(char *device, int mode); | 192 | extern int device_open(char *device, int mode); |
189 | #endif | 193 | #endif |
@@ -195,10 +199,6 @@ extern int set_loop(const char *device, const char *file, int offset, int *loopr | |||
195 | extern char *find_unused_loop_device (void); | 199 | extern char *find_unused_loop_device (void); |
196 | #endif | 200 | #endif |
197 | 201 | ||
198 | #if defined BB_GUNZIP || defined BB_GZIP || defined BB_PRINTF || defined BB_TAIL | ||
199 | extern void *xmalloc (size_t size); | ||
200 | extern void error(char *msg); | ||
201 | #endif | ||
202 | 202 | ||
203 | #if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT) | 203 | #if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT) |
204 | extern int vdprintf(int d, const char *format, va_list ap); | 204 | extern int vdprintf(int d, const char *format, va_list ap); |
@@ -84,7 +84,7 @@ extern int ln_main(int argc, char **argv) | |||
84 | exit FALSE; | 84 | exit FALSE; |
85 | } | 85 | } |
86 | 86 | ||
87 | linkIntoDirFlag = isDirectory(linkName, TRUE); | 87 | linkIntoDirFlag = isDirectory(linkName, TRUE, NULL); |
88 | 88 | ||
89 | if ((argc > 3) && !linkIntoDirFlag) { | 89 | if ((argc > 3) && !linkIntoDirFlag) { |
90 | fprintf(stderr, not_a_directory, "ln", linkName); | 90 | fprintf(stderr, not_a_directory, "ln", linkName); |
@@ -29,10 +29,10 @@ | |||
29 | * it more portable. | 29 | * it more portable. |
30 | * | 30 | * |
31 | * KNOWN BUGS: | 31 | * KNOWN BUGS: |
32 | * 1. messy output if you mix files and directories on the command line | 32 | * 1. ls -l of a directory doesn't give "total <blocks>" header |
33 | * 2. ls -l of a directory doesn't give "total <blocks>" header | 33 | * 2. ls of a symlink to a directory doesn't list directory contents |
34 | * 3. ls of a symlink to a directory doesn't list directory contents | 34 | * 3. hidden files can make column width too large |
35 | * 4. hidden files can make column width too large | 35 | * |
36 | * NON-OPTIMAL BEHAVIOUR: | 36 | * NON-OPTIMAL BEHAVIOUR: |
37 | * 1. autowidth reads directories twice | 37 | * 1. autowidth reads directories twice |
38 | * 2. if you do a short directory listing without filetype characters | 38 | * 2. if you do a short directory listing without filetype characters |
@@ -100,7 +100,9 @@ static unsigned short opts = 0; | |||
100 | static unsigned short column = 0; | 100 | static unsigned short column = 0; |
101 | 101 | ||
102 | #ifdef BB_FEATURE_AUTOWIDTH | 102 | #ifdef BB_FEATURE_AUTOWIDTH |
103 | static unsigned short terminal_width = 0, column_width = 0; | 103 | static unsigned short terminal_width = 0; |
104 | static unsigned short column_width = 0; | ||
105 | static unsigned short toplevel_column_width = 0; | ||
104 | #else | 106 | #else |
105 | #define terminal_width TERMINAL_WIDTH | 107 | #define terminal_width TERMINAL_WIDTH |
106 | #define column_width COLUMN_WIDTH | 108 | #define column_width COLUMN_WIDTH |
@@ -349,6 +351,9 @@ static int list_item(const char *name) | |||
349 | goto listerr; | 351 | goto listerr; |
350 | 352 | ||
351 | if (!S_ISDIR(info.st_mode) || (opts & DIR_NOLIST)) { | 353 | if (!S_ISDIR(info.st_mode) || (opts & DIR_NOLIST)) { |
354 | #ifdef BB_FEATURE_AUTOWIDTH | ||
355 | column_width = toplevel_column_width; | ||
356 | #endif | ||
352 | list_single(name, &info, name); | 357 | list_single(name, &info, name); |
353 | return 0; | 358 | return 0; |
354 | } | 359 | } |
@@ -407,6 +412,15 @@ static int list_item(const char *name) | |||
407 | list_single(entry->d_name, &info, fullname); | 412 | list_single(entry->d_name, &info, fullname); |
408 | } | 413 | } |
409 | closedir(dir); | 414 | closedir(dir); |
415 | |||
416 | if (opts & DISP_DIRNAME) { /* separate the directory */ | ||
417 | if (column) { | ||
418 | wr("\n", 1); | ||
419 | } | ||
420 | wr("\n", 1); | ||
421 | column = 0; | ||
422 | } | ||
423 | |||
410 | return 0; | 424 | return 0; |
411 | 425 | ||
412 | direrr: | 426 | direrr: |
@@ -530,8 +544,8 @@ extern int ls_main(int argc, char **argv) | |||
530 | for (i = argi; i < argc; i++) { | 544 | for (i = argi; i < argc; i++) { |
531 | int len = strlen(argv[i]); | 545 | int len = strlen(argv[i]); |
532 | 546 | ||
533 | if (column_width < len) | 547 | if (toplevel_column_width < len) |
534 | column_width = len; | 548 | toplevel_column_width = len; |
535 | } | 549 | } |
536 | #endif | 550 | #endif |
537 | 551 | ||
@@ -219,29 +219,6 @@ static void warn(char *s, ...) | |||
219 | va_end(p); | 219 | va_end(p); |
220 | } | 220 | } |
221 | 221 | ||
222 | static void error(char *s, ...) | ||
223 | { | ||
224 | va_list p; | ||
225 | |||
226 | va_start(p, s); | ||
227 | fflush(stdout); | ||
228 | fprintf(stderr, "\n" PROGNAME ": "); | ||
229 | vfprintf(stderr, s, p); | ||
230 | va_end(p); | ||
231 | } | ||
232 | |||
233 | static void fatal(char *s, ...) | ||
234 | { | ||
235 | va_list p; | ||
236 | |||
237 | va_start(p, s); | ||
238 | fflush(stdout); | ||
239 | fprintf(stderr, "\n" PROGNAME ": "); | ||
240 | vfprintf(stderr, s, p); | ||
241 | va_end(p); | ||
242 | exit(1); | ||
243 | } | ||
244 | |||
245 | /* | 222 | /* |
246 | * A. About seeking | 223 | * A. About seeking |
247 | */ | 224 | */ |
@@ -273,12 +250,12 @@ static int sseek(char *dev, unsigned int fd, unsigned long s) | |||
273 | if ((out = lseek(fd, in, SEEK_SET)) != in) { | 250 | if ((out = lseek(fd, in, SEEK_SET)) != in) { |
274 | #endif | 251 | #endif |
275 | perror("llseek"); | 252 | perror("llseek"); |
276 | error("seek error on %s - cannot seek to %lu\n", dev, s); | 253 | errorMsg("seek error on %s - cannot seek to %lu\n", dev, s, FALSE); |
277 | return 0; | 254 | return 0; |
278 | } | 255 | } |
279 | 256 | ||
280 | if (in != out) { | 257 | if (in != out) { |
281 | error("seek error: wanted 0x%08x%08x, got 0x%08x%08x\n", | 258 | errorMsg("seek error: wanted 0x%08x%08x, got 0x%08x%08x\n", |
282 | (uint) (in >> 32), (uint) (in & 0xffffffff), | 259 | (uint) (in >> 32), (uint) (in & 0xffffffff), |
283 | (uint) (out >> 32), (uint) (out & 0xffffffff)); | 260 | (uint) (out >> 32), (uint) (out & 0xffffffff)); |
284 | return 0; | 261 | return 0; |
@@ -324,11 +301,11 @@ static struct sector *get_sector(char *dev, int fd, unsigned long sno) | |||
324 | return 0; | 301 | return 0; |
325 | 302 | ||
326 | if (!(s = (struct sector *) malloc(sizeof(struct sector)))) | 303 | if (!(s = (struct sector *) malloc(sizeof(struct sector)))) |
327 | fatal("out of memory - giving up\n"); | 304 | fatalError("out of memory - giving up\n"); |
328 | 305 | ||
329 | if (read(fd, s->data, sizeof(s->data)) != sizeof(s->data)) { | 306 | if (read(fd, s->data, sizeof(s->data)) != sizeof(s->data)) { |
330 | perror("read"); | 307 | perror("read"); |
331 | error("read error on %s - cannot read sector %lu\n", dev, sno); | 308 | errorMsg("read error on %s - cannot read sector %lu\n", dev, sno); |
332 | free(s); | 309 | free(s); |
333 | return 0; | 310 | return 0; |
334 | } | 311 | } |
@@ -344,7 +321,7 @@ static struct sector *get_sector(char *dev, int fd, unsigned long sno) | |||
344 | static int msdos_signature(struct sector *s) | 321 | static int msdos_signature(struct sector *s) |
345 | { | 322 | { |
346 | if (*(unsigned short *) (s->data + 0x1fe) != 0xaa55) { | 323 | if (*(unsigned short *) (s->data + 0x1fe) != 0xaa55) { |
347 | error("ERROR: sector %lu does not have an msdos signature\n", | 324 | errorMsg("ERROR: sector %lu does not have an msdos signature\n", |
348 | s->sectornumber); | 325 | s->sectornumber); |
349 | return 0; | 326 | return 0; |
350 | } | 327 | } |
@@ -361,7 +338,7 @@ static int write_sectors(char *dev, int fd) | |||
361 | return 0; | 338 | return 0; |
362 | if (write(fd, s->data, sizeof(s->data)) != sizeof(s->data)) { | 339 | if (write(fd, s->data, sizeof(s->data)) != sizeof(s->data)) { |
363 | perror("write"); | 340 | perror("write"); |
364 | error("write error on %s - cannot write sector %lu\n", | 341 | errorMsg("write error on %s - cannot write sector %lu\n", |
365 | dev, s->sectornumber); | 342 | dev, s->sectornumber); |
366 | return 0; | 343 | return 0; |
367 | } | 344 | } |
@@ -399,7 +376,7 @@ static int save_sectors(char *dev, int fdin) | |||
399 | fdout = open(save_sector_file, O_WRONLY | O_CREAT, 0444); | 376 | fdout = open(save_sector_file, O_WRONLY | O_CREAT, 0444); |
400 | if (fdout < 0) { | 377 | if (fdout < 0) { |
401 | perror(save_sector_file); | 378 | perror(save_sector_file); |
402 | error("cannot open partition sector save file (%s)\n", | 379 | errorMsg("cannot open partition sector save file (%s)\n", |
403 | save_sector_file); | 380 | save_sector_file); |
404 | return 0; | 381 | return 0; |
405 | } | 382 | } |
@@ -411,13 +388,13 @@ static int save_sectors(char *dev, int fdin) | |||
411 | return 0; | 388 | return 0; |
412 | if (read(fdin, ss + 4, 512) != 512) { | 389 | if (read(fdin, ss + 4, 512) != 512) { |
413 | perror("read"); | 390 | perror("read"); |
414 | error("read error on %s - cannot read sector %lu\n", | 391 | errorMsg("read error on %s - cannot read sector %lu\n", |
415 | dev, s->sectornumber); | 392 | dev, s->sectornumber); |
416 | return 0; | 393 | return 0; |
417 | } | 394 | } |
418 | if (write(fdout, ss, sizeof(ss)) != sizeof(ss)) { | 395 | if (write(fdout, ss, sizeof(ss)) != sizeof(ss)) { |
419 | perror("write"); | 396 | perror("write"); |
420 | error("write error on %s\n"), save_sector_file; | 397 | errorMsg("write error on %s\n"), save_sector_file; |
421 | return 0; | 398 | return 0; |
422 | } | 399 | } |
423 | } | 400 | } |
@@ -435,35 +412,35 @@ static int restore_sectors(char *dev) | |||
435 | 412 | ||
436 | if (stat(restore_sector_file, &statbuf) < 0) { | 413 | if (stat(restore_sector_file, &statbuf) < 0) { |
437 | perror(restore_sector_file); | 414 | perror(restore_sector_file); |
438 | error("cannot stat partition restore file (%s)\n", | 415 | errorMsg("cannot stat partition restore file (%s)\n", |
439 | restore_sector_file); | 416 | restore_sector_file); |
440 | return 0; | 417 | return 0; |
441 | } | 418 | } |
442 | if (statbuf.st_size % 516) { | 419 | if (statbuf.st_size % 516) { |
443 | error("partition restore file has wrong size - not restoring\n"); | 420 | errorMsg("partition restore file has wrong size - not restoring\n"); |
444 | return 0; | 421 | return 0; |
445 | } | 422 | } |
446 | if (!(ss = (char *) malloc(statbuf.st_size))) { | 423 | if (!(ss = (char *) malloc(statbuf.st_size))) { |
447 | error("out of memory?\n"); | 424 | errorMsg("out of memory?\n"); |
448 | return 0; | 425 | return 0; |
449 | } | 426 | } |
450 | fdin = open(restore_sector_file, O_RDONLY); | 427 | fdin = open(restore_sector_file, O_RDONLY); |
451 | if (fdin < 0) { | 428 | if (fdin < 0) { |
452 | perror(restore_sector_file); | 429 | perror(restore_sector_file); |
453 | error("cannot open partition restore file (%s)\n", | 430 | errorMsg("cannot open partition restore file (%s)\n", |
454 | restore_sector_file); | 431 | restore_sector_file); |
455 | return 0; | 432 | return 0; |
456 | } | 433 | } |
457 | if (read(fdin, ss, statbuf.st_size) != statbuf.st_size) { | 434 | if (read(fdin, ss, statbuf.st_size) != statbuf.st_size) { |
458 | perror("read"); | 435 | perror("read"); |
459 | error("error reading %s\n"), restore_sector_file; | 436 | errorMsg("error reading %s\n"), restore_sector_file; |
460 | return 0; | 437 | return 0; |
461 | } | 438 | } |
462 | 439 | ||
463 | fdout = open(dev, O_WRONLY); | 440 | fdout = open(dev, O_WRONLY); |
464 | if (fdout < 0) { | 441 | if (fdout < 0) { |
465 | perror(dev); | 442 | perror(dev); |
466 | error("cannot open device %s for writing\n"), dev; | 443 | errorMsg("cannot open device %s for writing\n"), dev; |
467 | return 0; | 444 | return 0; |
468 | } | 445 | } |
469 | 446 | ||
@@ -475,7 +452,7 @@ static int restore_sectors(char *dev) | |||
475 | return 0; | 452 | return 0; |
476 | if (write(fdout, ss + 4, 512) != 512) { | 453 | if (write(fdout, ss + 4, 512) != 512) { |
477 | perror(dev); | 454 | perror(dev); |
478 | error("error writing sector %lu on %s\n", sno, dev); | 455 | errorMsg("error writing sector %lu on %s\n", sno, dev); |
479 | return 0; | 456 | return 0; |
480 | } | 457 | } |
481 | ss += 516; | 458 | ss += 516; |
@@ -905,7 +882,7 @@ static int asc_to_index(char *pnam, struct disk_desc *z) | |||
905 | pno = linux_to_index(pnum, z); | 882 | pno = linux_to_index(pnum, z); |
906 | } | 883 | } |
907 | if (!(pno >= 0 && pno < z->partno)) | 884 | if (!(pno >= 0 && pno < z->partno)) |
908 | fatal("%s: no such partition\n"), pnam; | 885 | fatalError("%s: no such partition\n"), pnam; |
909 | return pno; | 886 | return pno; |
910 | } | 887 | } |
911 | 888 | ||
@@ -1233,9 +1210,9 @@ static int partitions_ok(struct disk_desc *z) | |||
1233 | /* Have at least 4 partitions been defined? */ | 1210 | /* Have at least 4 partitions been defined? */ |
1234 | if (partno < 4) { | 1211 | if (partno < 4) { |
1235 | if (!partno) | 1212 | if (!partno) |
1236 | fatal("no partition table present.\n"); | 1213 | fatalError("no partition table present.\n"); |
1237 | else | 1214 | else |
1238 | fatal("strange, only %d partitions defined.\n"), partno; | 1215 | fatalError("strange, only %d partitions defined.\n"), partno; |
1239 | return 0; | 1216 | return 0; |
1240 | } | 1217 | } |
1241 | 1218 | ||
@@ -1680,12 +1657,12 @@ static int write_partitions(char *dev, int fd, struct disk_desc *z) | |||
1680 | } | 1657 | } |
1681 | if (save_sector_file) { | 1658 | if (save_sector_file) { |
1682 | if (!save_sectors(dev, fd)) { | 1659 | if (!save_sectors(dev, fd)) { |
1683 | fatal("Failed saving the old sectors - aborting\n"); | 1660 | fatalError("Failed saving the old sectors - aborting\n"); |
1684 | return 0; | 1661 | return 0; |
1685 | } | 1662 | } |
1686 | } | 1663 | } |
1687 | if (!write_sectors(dev, fd)) { | 1664 | if (!write_sectors(dev, fd)) { |
1688 | error("Failed writing the partition on %s\n"), dev; | 1665 | errorMsg("Failed writing the partition on %s\n"), dev; |
1689 | return 0; | 1666 | return 0; |
1690 | } | 1667 | } |
1691 | return 1; | 1668 | return 1; |
@@ -1765,7 +1742,7 @@ read_stdin(unsigned char **fields, unsigned char *line, int fieldssize, | |||
1765 | return RD_EOF; | 1742 | return RD_EOF; |
1766 | } | 1743 | } |
1767 | if (!(lp = index(lp, '\n'))) | 1744 | if (!(lp = index(lp, '\n'))) |
1768 | fatal("long or incomplete input line - quitting\n"); | 1745 | fatalError("long or incomplete input line - quitting\n"); |
1769 | *lp = 0; | 1746 | *lp = 0; |
1770 | 1747 | ||
1771 | /* remove comments, if any */ | 1748 | /* remove comments, if any */ |
@@ -1801,21 +1778,21 @@ read_stdin(unsigned char **fields, unsigned char *line, int fieldssize, | |||
1801 | while (isalnum(*ip)) /* 0x07FF */ | 1778 | while (isalnum(*ip)) /* 0x07FF */ |
1802 | ip++; | 1779 | ip++; |
1803 | } else | 1780 | } else |
1804 | fatal("input error: `=' expected after %s field\n", | 1781 | fatalError("input error: `=' expected after %s field\n", |
1805 | d->fldname); | 1782 | d->fldname); |
1806 | if (fno <= d->fldno) | 1783 | if (fno <= d->fldno) |
1807 | fno = d->fldno + 1; | 1784 | fno = d->fldno + 1; |
1808 | if (*ip == 0) | 1785 | if (*ip == 0) |
1809 | return fno; | 1786 | return fno; |
1810 | if (*ip != ',' && *ip != ';') | 1787 | if (*ip != ',' && *ip != ';') |
1811 | fatal | 1788 | fatalError |
1812 | ("input error: unexpected character %c after %s field\n", | 1789 | ("input error: unexpected character %c after %s field\n", |
1813 | *ip, d->fldname); | 1790 | *ip, d->fldname); |
1814 | *ip = 0; | 1791 | *ip = 0; |
1815 | goto nxtfld; | 1792 | goto nxtfld; |
1816 | } | 1793 | } |
1817 | } | 1794 | } |
1818 | fatal("unrecognized input: %s\n"), ip; | 1795 | fatalError("unrecognized input: %s\n"), ip; |
1819 | } | 1796 | } |
1820 | 1797 | ||
1821 | /* split line into fields */ | 1798 | /* split line into fields */ |
@@ -2251,7 +2228,7 @@ read_partition(char *dev, int interactive, int pno, struct part_desc *ep, | |||
2251 | 2228 | ||
2252 | while (!(i = read_line(pno, ep, dev, interactive, z))) | 2229 | while (!(i = read_line(pno, ep, dev, interactive, z))) |
2253 | if (!interactive) | 2230 | if (!interactive) |
2254 | fatal("bad input\n"); | 2231 | fatalError("bad input\n"); |
2255 | if (i < 0) { | 2232 | if (i < 0) { |
2256 | p->ep = ep; | 2233 | p->ep = ep; |
2257 | return 0; | 2234 | return 0; |
@@ -2612,19 +2589,19 @@ extern int sfdisk_main(int argc, char **argv) | |||
2612 | } | 2589 | } |
2613 | if (do_id) { | 2590 | if (do_id) { |
2614 | if ((do_id & PRINT_ID) != 0 && optind != argc - 2) | 2591 | if ((do_id & PRINT_ID) != 0 && optind != argc - 2) |
2615 | fatal("usage: sfdisk --print-id device partition-number\n"); | 2592 | fatalError("usage: sfdisk --print-id device partition-number\n"); |
2616 | else if ((do_id & CHANGE_ID) != 0 && optind != argc - 3) | 2593 | else if ((do_id & CHANGE_ID) != 0 && optind != argc - 3) |
2617 | fatal | 2594 | fatalError |
2618 | ("usage: sfdisk --change-id device partition-number Id\n"); | 2595 | ("usage: sfdisk --change-id device partition-number Id\n"); |
2619 | else if (optind != argc - 3 && optind != argc - 2) | 2596 | else if (optind != argc - 3 && optind != argc - 2) |
2620 | fatal("usage: sfdisk --id device partition-number [Id]\n"); | 2597 | fatalError("usage: sfdisk --id device partition-number [Id]\n"); |
2621 | do_change_id(argv[optind], argv[optind + 1], | 2598 | do_change_id(argv[optind], argv[optind + 1], |
2622 | (optind == argc - 2) ? 0 : argv[optind + 2]); | 2599 | (optind == argc - 2) ? 0 : argv[optind + 2]); |
2623 | exit(exit_status); | 2600 | exit(exit_status); |
2624 | } | 2601 | } |
2625 | 2602 | ||
2626 | if (optind != argc - 1) | 2603 | if (optind != argc - 1) |
2627 | fatal("can specify only one device (except with -l or -s)\n"); | 2604 | fatalError("can specify only one device (except with -l or -s)\n"); |
2628 | dev = argv[optind]; | 2605 | dev = argv[optind]; |
2629 | 2606 | ||
2630 | if (opt_reread) | 2607 | if (opt_reread) |
@@ -2649,7 +2626,7 @@ static int my_open(char *dev, int rw, int silent) | |||
2649 | fd = open(dev, mode); | 2626 | fd = open(dev, mode); |
2650 | if (fd < 0 && !silent) { | 2627 | if (fd < 0 && !silent) { |
2651 | perror(dev); | 2628 | perror(dev); |
2652 | fatal("cannot open %s %s\n", dev, | 2629 | fatalError("cannot open %s %s\n", dev, |
2653 | rw ? "read-write" : "for reading"); | 2630 | rw ? "read-write" : "for reading"); |
2654 | } | 2631 | } |
2655 | return fd; | 2632 | return fd; |
@@ -2711,7 +2688,7 @@ static void do_size(char *dev, int silent) | |||
2711 | if (ioctl(fd, BLKGETSIZE, &size)) { | 2688 | if (ioctl(fd, BLKGETSIZE, &size)) { |
2712 | if (!silent) { | 2689 | if (!silent) { |
2713 | perror(dev); | 2690 | perror(dev); |
2714 | fatal("BLKGETSIZE ioctl failed for %s\n"), dev; | 2691 | fatalError("BLKGETSIZE ioctl failed for %s\n"), dev; |
2715 | } | 2692 | } |
2716 | return; | 2693 | return; |
2717 | } | 2694 | } |
@@ -2831,7 +2808,7 @@ static void set_unhidden(struct disk_desc *z, char *pnam) | |||
2831 | if (id == 0x11 || id == 0x14 || id == 0x16 || id == 0x17) | 2808 | if (id == 0x11 || id == 0x14 || id == 0x16 || id == 0x17) |
2832 | id -= 0x10; | 2809 | id -= 0x10; |
2833 | else | 2810 | else |
2834 | fatal("partition %s has id %x and is not hidden\n", pnam, id); | 2811 | fatalError("partition %s has id %x and is not hidden\n", pnam, id); |
2835 | z->partitions[pno].p.sys_type = id; | 2812 | z->partitions[pno].p.sys_type = id; |
2836 | } | 2813 | } |
2837 | 2814 | ||
@@ -2889,7 +2866,7 @@ static void do_change_id(char *dev, char *pnam, char *id) | |||
2889 | } | 2866 | } |
2890 | i = strtoul(id, NULL, 16); | 2867 | i = strtoul(id, NULL, 16); |
2891 | if (i > 255) | 2868 | if (i > 255) |
2892 | fatal("Bad Id %x\n"), i; | 2869 | fatalError("Bad Id %x\n"), i; |
2893 | z->partitions[pno].p.sys_type = i; | 2870 | z->partitions[pno].p.sys_type = i; |
2894 | 2871 | ||
2895 | if (write_partitions(dev, fd, z)) | 2872 | if (write_partitions(dev, fd, z)) |
@@ -2921,7 +2898,7 @@ static void do_fdisk(char *dev) | |||
2921 | 2898 | ||
2922 | if (stat(dev, &statbuf) < 0) { | 2899 | if (stat(dev, &statbuf) < 0) { |
2923 | perror(dev); | 2900 | perror(dev); |
2924 | fatal("Fatal error: cannot find %s\n"), dev; | 2901 | fatalError("Fatal error: cannot find %s\n"), dev; |
2925 | } | 2902 | } |
2926 | if (!S_ISBLK(statbuf.st_mode)) { | 2903 | if (!S_ISBLK(statbuf.st_mode)) { |
2927 | warn("Warning: %s is not a block device\n"), dev; | 2904 | warn("Warning: %s is not a block device\n"), dev; |
@@ -2954,7 +2931,7 @@ static void do_fdisk(char *dev) | |||
2954 | out_partitions(dev, z); | 2931 | out_partitions(dev, z); |
2955 | 2932 | ||
2956 | if (one_only && (one_only_pno = linux_to_index(one_only, z)) < 0) | 2933 | if (one_only && (one_only_pno = linux_to_index(one_only, z)) < 0) |
2957 | fatal("Partition %d does not exist, cannot change it\n"), one_only; | 2934 | fatalError("Partition %d does not exist, cannot change it\n"), one_only; |
2958 | 2935 | ||
2959 | z = &newp; | 2936 | z = &newp; |
2960 | 2937 | ||
@@ -2967,7 +2944,7 @@ static void do_fdisk(char *dev) | |||
2967 | 2944 | ||
2968 | if (!partitions_ok(z) && !force) { | 2945 | if (!partitions_ok(z) && !force) { |
2969 | if (!interactive) | 2946 | if (!interactive) |
2970 | fatal("I don't like these partitions - nothing changed.\n" | 2947 | fatalError("I don't like these partitions - nothing changed.\n" |
2971 | "(If you really want this, use the --force option.)\n"); | 2948 | "(If you really want this, use the --force option.)\n"); |
2972 | else | 2949 | else |
2973 | printf | 2950 | printf |
@@ -2985,7 +2962,7 @@ static void do_fdisk(char *dev) | |||
2985 | if (c == EOF) | 2962 | if (c == EOF) |
2986 | printf("\nsfdisk: premature end of input\n"); | 2963 | printf("\nsfdisk: premature end of input\n"); |
2987 | if (c == EOF || answer == 'q' || answer == 'Q') { | 2964 | if (c == EOF || answer == 'q' || answer == 'Q') { |
2988 | fatal("Quitting - nothing changed\n"); | 2965 | fatalError("Quitting - nothing changed\n"); |
2989 | } else if (answer == 'n' || answer == 'N') { | 2966 | } else if (answer == 'n' || answer == 'N') { |
2990 | continue; | 2967 | continue; |
2991 | } else if (answer == 'y' || answer == 'Y') { | 2968 | } else if (answer == 'y' || answer == 'Y') { |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index db535044c..d39cd6a0d 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -110,17 +110,19 @@ static void logMessage(int pri, char *msg) | |||
110 | { | 110 | { |
111 | time_t now; | 111 | time_t now; |
112 | char *timestamp; | 112 | char *timestamp; |
113 | static char res[20]; | 113 | static char res[20] = ""; |
114 | CODE *c_pri, *c_fac; | 114 | CODE *c_pri, *c_fac; |
115 | 115 | ||
116 | for (c_fac = facilitynames; | 116 | if (pri != 0) { |
117 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); | 117 | for (c_fac = facilitynames; |
118 | for (c_pri = prioritynames; | 118 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); |
119 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); | 119 | for (c_pri = prioritynames; |
120 | if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0') | 120 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); |
121 | snprintf(res, sizeof(res), "<%d>", pri); | 121 | if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0') |
122 | else | 122 | snprintf(res, sizeof(res), "<%d>", pri); |
123 | snprintf(res, sizeof(res), "%s.%s", c_fac->c_name, c_pri->c_name); | 123 | else |
124 | snprintf(res, sizeof(res), "%s.%s", c_fac->c_name, c_pri->c_name); | ||
125 | } | ||
124 | 126 | ||
125 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || | 127 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || |
126 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { | 128 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { |
@@ -141,17 +143,11 @@ static void logMessage(int pri, char *msg) | |||
141 | 143 | ||
142 | static void quit_signal(int sig) | 144 | static void quit_signal(int sig) |
143 | { | 145 | { |
144 | logMessage(LOG_SYSLOG | LOG_INFO, "System log daemon exiting."); | 146 | logMessage(0, "System log daemon exiting."); |
145 | unlink(_PATH_LOG); | 147 | unlink(_PATH_LOG); |
146 | exit(TRUE); | 148 | exit(TRUE); |
147 | } | 149 | } |
148 | 150 | ||
149 | static void restart_signal(int sig) | ||
150 | { | ||
151 | /* pretend to restart */ | ||
152 | logMessage(LOG_SYSLOG | LOG_INFO, "syslogd restarting"); | ||
153 | } | ||
154 | |||
155 | static void domark(int sig) | 151 | static void domark(int sig) |
156 | { | 152 | { |
157 | if (MarkInterval > 0) { | 153 | if (MarkInterval > 0) { |
@@ -173,8 +169,8 @@ static void doSyslogd(void) | |||
173 | signal(SIGINT, quit_signal); | 169 | signal(SIGINT, quit_signal); |
174 | signal(SIGTERM, quit_signal); | 170 | signal(SIGTERM, quit_signal); |
175 | signal(SIGQUIT, quit_signal); | 171 | signal(SIGQUIT, quit_signal); |
176 | signal(SIGHUP, restart_signal); | ||
177 | signal(SIGALRM, domark); | 172 | signal(SIGALRM, domark); |
173 | signal(SIGHUP, SIG_IGN); | ||
178 | alarm(MarkInterval); | 174 | alarm(MarkInterval); |
179 | 175 | ||
180 | /* Remove any preexisting socket/file */ | 176 | /* Remove any preexisting socket/file */ |
@@ -201,8 +197,7 @@ static void doSyslogd(void) | |||
201 | exit(FALSE); | 197 | exit(FALSE); |
202 | } | 198 | } |
203 | 199 | ||
204 | logMessage(LOG_SYSLOG | LOG_INFO, "syslogd started: " | 200 | logMessage(0, "syslogd started: BusyBox v" BB_VER " (" BB_BT ")"); |
205 | "BusyBox v" BB_VER " (" BB_BT ")"); | ||
206 | 201 | ||
207 | 202 | ||
208 | while ((conn = accept(fd, (struct sockaddr *) &sunx, | 203 | while ((conn = accept(fd, (struct sockaddr *) &sunx, |
@@ -251,7 +246,7 @@ static void klogd_signal(int sig) | |||
251 | { | 246 | { |
252 | ksyslog(7, NULL, 0); | 247 | ksyslog(7, NULL, 0); |
253 | ksyslog(0, 0, 0); | 248 | ksyslog(0, 0, 0); |
254 | logMessage(LOG_SYSLOG | LOG_INFO, "Kernel log daemon exiting."); | 249 | logMessage(0, "Kernel log daemon exiting."); |
255 | exit(TRUE); | 250 | exit(TRUE); |
256 | } | 251 | } |
257 | 252 | ||
@@ -265,8 +260,8 @@ static void doKlogd(void) | |||
265 | signal(SIGINT, klogd_signal); | 260 | signal(SIGINT, klogd_signal); |
266 | signal(SIGKILL, klogd_signal); | 261 | signal(SIGKILL, klogd_signal); |
267 | signal(SIGTERM, klogd_signal); | 262 | signal(SIGTERM, klogd_signal); |
268 | signal(SIGHUP, klogd_signal); | 263 | signal(SIGHUP, SIG_IGN); |
269 | logMessage(LOG_SYSLOG | LOG_INFO, "klogd started: " | 264 | logMessage(0, "klogd started: " |
270 | "BusyBox v" BB_VER " (" BB_BT ")"); | 265 | "BusyBox v" BB_VER " (" BB_BT ")"); |
271 | 266 | ||
272 | ksyslog(1, NULL, 0); | 267 | ksyslog(1, NULL, 0); |
@@ -110,17 +110,19 @@ static void logMessage(int pri, char *msg) | |||
110 | { | 110 | { |
111 | time_t now; | 111 | time_t now; |
112 | char *timestamp; | 112 | char *timestamp; |
113 | static char res[20]; | 113 | static char res[20] = ""; |
114 | CODE *c_pri, *c_fac; | 114 | CODE *c_pri, *c_fac; |
115 | 115 | ||
116 | for (c_fac = facilitynames; | 116 | if (pri != 0) { |
117 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); | 117 | for (c_fac = facilitynames; |
118 | for (c_pri = prioritynames; | 118 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); |
119 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); | 119 | for (c_pri = prioritynames; |
120 | if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0') | 120 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); |
121 | snprintf(res, sizeof(res), "<%d>", pri); | 121 | if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0') |
122 | else | 122 | snprintf(res, sizeof(res), "<%d>", pri); |
123 | snprintf(res, sizeof(res), "%s.%s", c_fac->c_name, c_pri->c_name); | 123 | else |
124 | snprintf(res, sizeof(res), "%s.%s", c_fac->c_name, c_pri->c_name); | ||
125 | } | ||
124 | 126 | ||
125 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || | 127 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || |
126 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { | 128 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { |
@@ -141,17 +143,11 @@ static void logMessage(int pri, char *msg) | |||
141 | 143 | ||
142 | static void quit_signal(int sig) | 144 | static void quit_signal(int sig) |
143 | { | 145 | { |
144 | logMessage(LOG_SYSLOG | LOG_INFO, "System log daemon exiting."); | 146 | logMessage(0, "System log daemon exiting."); |
145 | unlink(_PATH_LOG); | 147 | unlink(_PATH_LOG); |
146 | exit(TRUE); | 148 | exit(TRUE); |
147 | } | 149 | } |
148 | 150 | ||
149 | static void restart_signal(int sig) | ||
150 | { | ||
151 | /* pretend to restart */ | ||
152 | logMessage(LOG_SYSLOG | LOG_INFO, "syslogd restarting"); | ||
153 | } | ||
154 | |||
155 | static void domark(int sig) | 151 | static void domark(int sig) |
156 | { | 152 | { |
157 | if (MarkInterval > 0) { | 153 | if (MarkInterval > 0) { |
@@ -173,8 +169,8 @@ static void doSyslogd(void) | |||
173 | signal(SIGINT, quit_signal); | 169 | signal(SIGINT, quit_signal); |
174 | signal(SIGTERM, quit_signal); | 170 | signal(SIGTERM, quit_signal); |
175 | signal(SIGQUIT, quit_signal); | 171 | signal(SIGQUIT, quit_signal); |
176 | signal(SIGHUP, restart_signal); | ||
177 | signal(SIGALRM, domark); | 172 | signal(SIGALRM, domark); |
173 | signal(SIGHUP, SIG_IGN); | ||
178 | alarm(MarkInterval); | 174 | alarm(MarkInterval); |
179 | 175 | ||
180 | /* Remove any preexisting socket/file */ | 176 | /* Remove any preexisting socket/file */ |
@@ -201,8 +197,7 @@ static void doSyslogd(void) | |||
201 | exit(FALSE); | 197 | exit(FALSE); |
202 | } | 198 | } |
203 | 199 | ||
204 | logMessage(LOG_SYSLOG | LOG_INFO, "syslogd started: " | 200 | logMessage(0, "syslogd started: BusyBox v" BB_VER " (" BB_BT ")"); |
205 | "BusyBox v" BB_VER " (" BB_BT ")"); | ||
206 | 201 | ||
207 | 202 | ||
208 | while ((conn = accept(fd, (struct sockaddr *) &sunx, | 203 | while ((conn = accept(fd, (struct sockaddr *) &sunx, |
@@ -251,7 +246,7 @@ static void klogd_signal(int sig) | |||
251 | { | 246 | { |
252 | ksyslog(7, NULL, 0); | 247 | ksyslog(7, NULL, 0); |
253 | ksyslog(0, 0, 0); | 248 | ksyslog(0, 0, 0); |
254 | logMessage(LOG_SYSLOG | LOG_INFO, "Kernel log daemon exiting."); | 249 | logMessage(0, "Kernel log daemon exiting."); |
255 | exit(TRUE); | 250 | exit(TRUE); |
256 | } | 251 | } |
257 | 252 | ||
@@ -265,8 +260,8 @@ static void doKlogd(void) | |||
265 | signal(SIGINT, klogd_signal); | 260 | signal(SIGINT, klogd_signal); |
266 | signal(SIGKILL, klogd_signal); | 261 | signal(SIGKILL, klogd_signal); |
267 | signal(SIGTERM, klogd_signal); | 262 | signal(SIGTERM, klogd_signal); |
268 | signal(SIGHUP, klogd_signal); | 263 | signal(SIGHUP, SIG_IGN); |
269 | logMessage(LOG_SYSLOG | LOG_INFO, "klogd started: " | 264 | logMessage(0, "klogd started: " |
270 | "BusyBox v" BB_VER " (" BB_BT ")"); | 265 | "BusyBox v" BB_VER " (" BB_BT ")"); |
271 | 266 | ||
272 | ksyslog(1, NULL, 0); | 267 | ksyslog(1, NULL, 0); |
@@ -1,5 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | #include "internal.h" | 2 | #include "internal.h" |
3 | |||
3 | /* This file contains _two_ implementations of tail. One is | 4 | /* This file contains _two_ implementations of tail. One is |
4 | * a bit more full featured, but costs 6k. The other (i.e. the | 5 | * a bit more full featured, but costs 6k. The other (i.e. the |
5 | * SIMPLE_TAIL one) is less capable, but is good enough for about | 6 | * SIMPLE_TAIL one) is less capable, but is good enough for about |
@@ -51,7 +52,7 @@ | |||
51 | #define XWRITE(fd, buffer, n_bytes) \ | 52 | #define XWRITE(fd, buffer, n_bytes) \ |
52 | do { \ | 53 | do { \ |
53 | if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \ | 54 | if (n_bytes > 0 && fwrite ((buffer), 1, (n_bytes), stdout) == 0) \ |
54 | error("write error"); \ | 55 | errorMsg("write error"); \ |
55 | } while (0) | 56 | } while (0) |
56 | 57 | ||
57 | /* Number of items to tail. */ | 58 | /* Number of items to tail. */ |
@@ -117,7 +118,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos) | |||
117 | lseek(fd, pos, SEEK_SET); | 118 | lseek(fd, pos, SEEK_SET); |
118 | bytes_read = fullRead(fd, buffer, bytes_read); | 119 | bytes_read = fullRead(fd, buffer, bytes_read); |
119 | if (bytes_read == -1) | 120 | if (bytes_read == -1) |
120 | error("read error"); | 121 | errorMsg("read error"); |
121 | 122 | ||
122 | /* Count the incomplete line on files that don't end with a newline. */ | 123 | /* Count the incomplete line on files that don't end with a newline. */ |
123 | if (bytes_read && buffer[bytes_read - 1] != '\n') | 124 | if (bytes_read && buffer[bytes_read - 1] != '\n') |
@@ -147,7 +148,7 @@ file_lines(const char *filename, int fd, long int n_lines, off_t pos) | |||
147 | } | 148 | } |
148 | while ((bytes_read = fullRead(fd, buffer, BUFSIZ)) > 0); | 149 | while ((bytes_read = fullRead(fd, buffer, BUFSIZ)) > 0); |
149 | if (bytes_read == -1) | 150 | if (bytes_read == -1) |
150 | error("read error"); | 151 | errorMsg("read error"); |
151 | 152 | ||
152 | return 0; | 153 | return 0; |
153 | } | 154 | } |
@@ -209,7 +210,7 @@ static int pipe_lines(const char *filename, int fd, long int n_lines) | |||
209 | } | 210 | } |
210 | } | 211 | } |
211 | if (tmp->nbytes == -1) | 212 | if (tmp->nbytes == -1) |
212 | error("read error"); | 213 | errorMsg("read error"); |
213 | 214 | ||
214 | free((char *) tmp); | 215 | free((char *) tmp); |
215 | 216 | ||
@@ -272,7 +273,7 @@ static long dump_remainder(const char *filename, int fd) | |||
272 | total += bytes_read; | 273 | total += bytes_read; |
273 | } | 274 | } |
274 | if (bytes_read == -1) | 275 | if (bytes_read == -1) |
275 | error("read error"); | 276 | errorMsg("read error"); |
276 | if (forever) { | 277 | if (forever) { |
277 | fflush(stdout); | 278 | fflush(stdout); |
278 | sleep(1); | 279 | sleep(1); |
@@ -294,7 +295,7 @@ static int tail_lines(const char *filename, int fd, long int n_lines) | |||
294 | write_header(filename); | 295 | write_header(filename); |
295 | 296 | ||
296 | if (fstat(fd, &stats)) | 297 | if (fstat(fd, &stats)) |
297 | error("fstat error"); | 298 | errorMsg("fstat error"); |
298 | 299 | ||
299 | /* Use file_lines only if FD refers to a regular file with | 300 | /* Use file_lines only if FD refers to a regular file with |
300 | its file pointer positioned at beginning of file. */ | 301 | its file pointer positioned at beginning of file. */ |
@@ -329,7 +330,7 @@ static int tail_file(const char *filename, off_t n_units) | |||
329 | /* Not standard input. */ | 330 | /* Not standard input. */ |
330 | fd = open(filename, O_RDONLY); | 331 | fd = open(filename, O_RDONLY); |
331 | if (fd == -1) | 332 | if (fd == -1) |
332 | error("open error"); | 333 | errorMsg("open error"); |
333 | 334 | ||
334 | errors = tail_lines(filename, fd, (long) n_units); | 335 | errors = tail_lines(filename, fd, (long) n_units); |
335 | close(fd); | 336 | close(fd); |
@@ -77,6 +77,30 @@ extern void usage(const char *usage) | |||
77 | exit FALSE; | 77 | exit FALSE; |
78 | } | 78 | } |
79 | 79 | ||
80 | extern void errorMsg(char *s, ...) | ||
81 | { | ||
82 | va_list p; | ||
83 | |||
84 | va_start(p, s); | ||
85 | fflush(stdout); | ||
86 | fprintf(stderr, "\n"); | ||
87 | vfprintf(stderr, s, p); | ||
88 | fprintf(stderr, "\n"); | ||
89 | va_end(p); | ||
90 | } | ||
91 | |||
92 | extern void fatalError(char *s, ...) | ||
93 | { | ||
94 | va_list p; | ||
95 | |||
96 | va_start(p, s); | ||
97 | fflush(stdout); | ||
98 | fprintf(stderr, "\n"); | ||
99 | vfprintf(stderr, s, p); | ||
100 | fprintf(stderr, "\n"); | ||
101 | va_end(p); | ||
102 | exit( FALSE); | ||
103 | } | ||
80 | 104 | ||
81 | #if defined (BB_INIT) || defined (BB_PS) | 105 | #if defined (BB_INIT) || defined (BB_PS) |
82 | 106 | ||
@@ -110,21 +134,31 @@ int get_kernel_revision() | |||
110 | * Return TRUE if a fileName is a directory. | 134 | * Return TRUE if a fileName is a directory. |
111 | * Nonexistant files return FALSE. | 135 | * Nonexistant files return FALSE. |
112 | */ | 136 | */ |
113 | int isDirectory(const char *fileName, const int followLinks) | 137 | int isDirectory(const char *fileName, const int followLinks, struct stat *statBuf) |
114 | { | 138 | { |
115 | struct stat statBuf; | ||
116 | int status; | 139 | int status; |
140 | int didMalloc = 0; | ||
141 | |||
142 | if (statBuf == NULL) { | ||
143 | statBuf = (struct stat *)xmalloc(sizeof(struct stat)); | ||
144 | ++didMalloc; | ||
145 | } | ||
117 | 146 | ||
118 | if (followLinks == TRUE) | 147 | if (followLinks == TRUE) |
119 | status = stat(fileName, &statBuf); | 148 | status = stat(fileName, statBuf); |
120 | else | 149 | else |
121 | status = lstat(fileName, &statBuf); | 150 | status = lstat(fileName, statBuf); |
122 | 151 | ||
123 | if (status < 0) | 152 | if (status < 0 || !(S_ISDIR(statBuf->st_mode))) { |
124 | return FALSE; | 153 | status = FALSE; |
125 | if (S_ISDIR(statBuf.st_mode)) | 154 | } |
126 | return TRUE; | 155 | else status = TRUE; |
127 | return FALSE; | 156 | |
157 | if (didMalloc) { | ||
158 | free(statBuf); | ||
159 | statBuf = NULL; | ||
160 | } | ||
161 | return status; | ||
128 | } | 162 | } |
129 | #endif | 163 | #endif |
130 | 164 | ||
@@ -1189,16 +1223,11 @@ extern void *xmalloc(size_t size) | |||
1189 | void *cp = malloc(size); | 1223 | void *cp = malloc(size); |
1190 | 1224 | ||
1191 | if (cp == NULL) { | 1225 | if (cp == NULL) { |
1192 | error("out of memory"); | 1226 | errorMsg("out of memory"); |
1193 | } | 1227 | } |
1194 | return cp; | 1228 | return cp; |
1195 | } | 1229 | } |
1196 | 1230 | ||
1197 | extern void error(char *msg) | ||
1198 | { | ||
1199 | fprintf(stderr, "\n%s\n", msg); | ||
1200 | exit(1); | ||
1201 | } | ||
1202 | #endif /* BB_GUNZIP || BB_GZIP || BB_PRINTF || BB_TAIL */ | 1231 | #endif /* BB_GUNZIP || BB_GZIP || BB_PRINTF || BB_TAIL */ |
1203 | 1232 | ||
1204 | #if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT) | 1233 | #if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT) |