aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-06-02 03:21:42 +0000
committerEric Andersen <andersen@codepoet.org>2000-06-02 03:21:42 +0000
commit86ab8a32bd63b2f2a73bdcead8e2bb037589e175 (patch)
tree10aa90962757d07724c78e4fc9baaa27ca7b4858
parent4062268bc7ac748e2ea2e569aa862b2b3f8a2db2 (diff)
downloadbusybox-w32-86ab8a32bd63b2f2a73bdcead8e2bb037589e175.tar.gz
busybox-w32-86ab8a32bd63b2f2a73bdcead8e2bb037589e175.tar.bz2
busybox-w32-86ab8a32bd63b2f2a73bdcead8e2bb037589e175.zip
A number of additional fixed from Pavel Roskin, note some more bugs in the
TODO list. Add Glenn to the Authors list for writing a mini ar for BusyBox, which is now included. -Erik
-rw-r--r--AUTHORS5
-rw-r--r--Changelog7
-rw-r--r--Makefile5
-rw-r--r--TODO2
-rw-r--r--applets/busybox.c3
-rw-r--r--ar.c277
-rw-r--r--archival/ar.c277
-rw-r--r--busybox.c3
-rw-r--r--busybox.def.h1
-rw-r--r--coreutils/pwd.c2
-rw-r--r--coreutils/tail.c2
-rw-r--r--coreutils/test.c12
-rw-r--r--docs/busybox.net/BusyBox.html30
-rw-r--r--docs/busybox.pod26
-rw-r--r--internal.h1
-rw-r--r--kill.c3
-rw-r--r--more.c4
-rw-r--r--procps/kill.c3
-rw-r--r--procps/ps.c13
-rw-r--r--ps.c13
-rw-r--r--pwd.c2
-rw-r--r--sysklogd/syslogd.c8
-rw-r--r--syslogd.c8
-rw-r--r--tail.c2
-rw-r--r--test.c12
-rw-r--r--util-linux/more.c4
-rw-r--r--utility.c6
27 files changed, 681 insertions, 50 deletions
diff --git a/AUTHORS b/AUTHORS
index 30ef908da..14cd785cf 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -32,7 +32,10 @@ Daniel Jacobowitz <dan@debian.org>
32 mktemp.c 32 mktemp.c
33 33
34John Lombardo <john@deltanet.com> 34John Lombardo <john@deltanet.com>
35 dirname, tr 35 dirname, tr
36
37Glenn McGrath <bug1@netconnect.com.au>
38 ar.c
36 39
37Bruce Perens <bruce@pixar.com> 40Bruce Perens <bruce@pixar.com>
38 Original author of BusyBox. His code is still in many apps. 41 Original author of BusyBox. His code is still in many apps.
diff --git a/Changelog b/Changelog
index 31003dc77..42a4cc7ca 100644
--- a/Changelog
+++ b/Changelog
@@ -39,6 +39,13 @@
39 * Changed the way init parses /etc/inittab entries to avoid problems 39 * Changed the way init parses /etc/inittab entries to avoid problems
40 with commands that contain colons in them. Fix thanks to 40 with commands that contain colons in them. Fix thanks to
41 Pavel Roskin <pavel_roskin@geocities.com> 41 Pavel Roskin <pavel_roskin@geocities.com>
42 * Fixed a warning in utility.c due to char being unsigned on Linux/PPC,
43 Fix thanks to Pavel Roskin <pavel_roskin@geocities.com>
44 * Made "killall" complain (not error and exit) about processes that it
45 cannot find by name. Fix thanks to Pavel Roskin <pavel_roskin@geocities.com>
46 * Fixed more and ps to have sensible terminal width defaults, thanks
47 to Pavel Roskin.
48 * Fixed all fatalError() calls lacking a "\n", thanks to Pavel Roskin.
42 * More doc updates 49 * More doc updates
43 50
44 51
diff --git a/Makefile b/Makefile
index f1ca4a522..6471e3490 100644
--- a/Makefile
+++ b/Makefile
@@ -102,11 +102,10 @@ docs/BusyBox.1: docs/busybox.pod
102 102
103docs/BusyBox.html: docs/busybox.pod 103docs/BusyBox.html: docs/busybox.pod
104 pod2html docs/busybox.pod > docs/busybox.lineo.com/BusyBox.html 104 pod2html docs/busybox.pod > docs/busybox.lineo.com/BusyBox.html
105 ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html 105 - rm -f docs/BusyBox.html
106 - ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
106 - rm -f pod2html* 107 - rm -f pod2html*
107 108
108clean:
109
110busybox: $(OBJECTS) 109busybox: $(OBJECTS)
111 $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES) 110 $(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
112 $(STRIP) 111 $(STRIP)
diff --git a/TODO b/TODO
index c1d6f01a6..e6cb94d4b 100644
--- a/TODO
+++ b/TODO
@@ -40,6 +40,8 @@ Bugs that need fixing:
40 /tmp/file in the current directory, rather then trying and failing to create 40 /tmp/file in the current directory, rather then trying and failing to create
41 a symlink named "." in the current working directory). 41 a symlink named "." in the current working directory).
42 - implement 'ls -R'. 42 - implement 'ls -R'.
43 - "cp -a sourcedir/*" (note: no dest) - produces an odd error message about
44 the last file in the dir, rather than saying "missing destination file".
43 45
44 46
45----------- 47-----------
diff --git a/applets/busybox.c b/applets/busybox.c
index bf0591d66..9ee5d2e3a 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -32,6 +32,9 @@ void *__libc_stack_end;
32 32
33const struct BB_applet applets[] = { 33const struct BB_applet applets[] = {
34 34
35#ifdef BB_AR
36 {"ar", ar_main, _BB_DIR_USR_BIN},
37#endif
35#ifdef BB_BASENAME 38#ifdef BB_BASENAME
36 {"basename", basename_main, _BB_DIR_USR_BIN}, 39 {"basename", basename_main, _BB_DIR_USR_BIN},
37#endif 40#endif
diff --git a/ar.c b/ar.c
new file mode 100644
index 000000000..253f3348a
--- /dev/null
+++ b/ar.c
@@ -0,0 +1,277 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Mini ar implementation for busybox
4 *
5 * Copyright (C) 2000 by Glenn McGrath
6 * Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
7 *
8 * Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26
27#include <stdio.h>
28#include <fcntl.h>
29#include <errno.h>
30#include <ctype.h>
31#include "internal.h"
32
33#define AR_BLOCK_SIZE 60
34#define BB_DECLARE_EXTERN
35#define bb_need_io_error
36#include "messages.c"
37
38struct ArHeader { /* Byte Offset */
39 char ar_name[16]; /* 0-15 */
40 char ar_date[12]; /* 16-27 */
41 char ar_uid[6], ar_gid[6]; /* 28-39 */
42 char ar_mode[8]; /* 40-47 */
43 char ar_size[10]; /* 48-57 */
44 char ar_fmag[2]; /* 58-59 */
45};
46typedef struct ArHeader ArHeader;
47
48struct ArInfo {
49 char name[17]; /* File name */
50 time_t date; /* long int, No of seconds since epoch */
51 uid_t uid; /* unsigned int, Numeric UID */
52 gid_t gid; /* unsigned int, Numeric GID */
53 mode_t mode; /* unsigned int, Unix mode */
54 size_t size; /* int, Size of the file */
55};
56typedef struct ArInfo ArInfo;
57
58static const char ar_usage[] = "ar [optxvV] archive [filenames] \n"
59#ifndef BB_FEATURE_TRIVIAL_HELP
60 "\nExtract or list files from an ar archive.\n\n"
61 "Options:\n"
62 "\to\t\tpreserve original dates\n"
63 "\tp\t\textract to stdout\n"
64 "\tt\t\tlist\n"
65 "\tx\t\textract\n"
66 "\tv\t\tverbosely list files processed\n"
67#endif
68 ;
69
70static void displayContents(struct ArInfo *entry, int funct)
71{
72 /* TODO convert mode to string */
73 if ((funct & 2) == 2)
74 printf("%i %i/%i %6i %s ", entry->mode, entry->uid, entry->gid,
75 entry->size, timeString(entry->date));
76 printf("%s\n", entry->name);
77}
78
79/* Converts to new typed struct */
80static int readArHeader(struct ArHeader *rawHeader, struct ArInfo *header)
81{
82 int count2;
83 int count;
84
85 for (count = 0; count < 16; count++) {
86 if (rawHeader->ar_name[count] == ' ') {
87 for (count2 = count; count2 < 16; count2++)
88 if (!isspace(rawHeader->ar_name[count2]))
89 break;
90 if (count2 >= 16)
91 break;
92 }
93 if (rawHeader->ar_name[count] == '/')
94 break;
95 header->name[count] = rawHeader->ar_name[count];
96 }
97 header->name[count] = '\0';
98 header->date = atoi(rawHeader->ar_date);
99 header->uid = atoi(rawHeader->ar_uid);
100 header->gid = atoi(rawHeader->ar_gid);
101 header->mode = atoi(rawHeader->ar_mode);
102 header->size = atoi(rawHeader->ar_size);
103 return (TRUE);
104}
105
106/*
107 * Copy size bytes from current position if srcFd to current position in dstFd
108 * taken from tarExtractRegularFile in tar.c
109 * could be used for ar, tar and copyFile .
110 */
111static int copySubFile(int srcFd, int dstFd, int copySize)
112{
113 int readSize, writeSize, doneSize;
114 char buffer[BUFSIZ];
115
116 while (copySize > 0) {
117 if (copySize > BUFSIZ)
118 readSize = BUFSIZ;
119 else
120 readSize = copySize;
121 writeSize = fullRead(srcFd, buffer, readSize);
122 if (writeSize <= 0) {
123 errorMsg(io_error, "copySubFile :", strerror(errno));
124 return (FALSE);
125 }
126 doneSize = fullWrite(dstFd, buffer, writeSize);
127 if (doneSize <= 0) {
128 errorMsg(io_error, "copySubFile :", strerror(errno));
129 return (FALSE);
130 }
131 copySize -= doneSize;
132 }
133 return (TRUE);
134}
135
136/*
137 * Need to add checks, stat newfile before creation,change mode from 0777
138 * extract to current dir
139 * dstStat.st_size copied from current position of file pointed to by srcFd
140 */
141static int extractToFile(int srcFd, const char *path, const char *name,
142 int size)
143{
144 int dstFd, temp;
145 struct stat tmpStat;
146 char *pathname = NULL;
147
148 if ((temp = isDirectory(path, TRUE, &tmpStat)) != TRUE) {
149 if (!createPath(path, 0777)) {
150 fatalError("Cannot extract to specified path");
151 return (FALSE);
152 }
153 }
154 temp = (strlen(path) + 16);
155 pathname = (char *) xmalloc(temp);
156 pathname = strcpy(pathname, path);
157 pathname = strcat(pathname, &name[0]);
158 dstFd = device_open(pathname, O_WRONLY | O_CREAT);
159 pathname = NULL;
160 temp = copySubFile(srcFd, dstFd, size);
161 close(dstFd);
162 return (TRUE);
163}
164
165/* Step through the ar file entries */
166static int readArFile(char **fileNames, int argc, int funct)
167{
168 int arFd = 0;
169 int pdates = 0;
170 int verbose = 0;
171 int display = 0;
172 int extract = 0;
173 int extToStdout = 0;
174 int status = 0;
175 int found = 0;
176 ArHeader rawArHeader;
177 ArInfo arEntry;
178 char arVersion[8];
179 char *arName;
180 char *selName[argc - 2];
181 int i;
182
183 if ((funct & 1) == 1)
184 pdates = 1;
185 if ((funct & 2) == 2)
186 verbose = 1;
187 if ((funct & 4) == 4)
188 display = 1;
189 if ((funct & 16) == 16) { /* extract to stdout */
190 extract = 1;
191 extToStdout = 1;
192 }
193 if ((funct & 8) == 8) { /* extract to file */
194 extract = 1;
195 }
196 arName = fileNames[2];
197 for (i = 0; i < (argc - 3); i++)
198 selName[i] = fileNames[i + 3];
199 arFd = open(arName, O_RDONLY);
200 if (arFd < 0) {
201 errorMsg("Error opening '%s': %s\n", arName, strerror(errno));
202 return (FALSE);
203 }
204 if (fullRead(arFd, arVersion, 8) <= 0) {
205 errorMsg("ar: Unexpected EOF in archive\n");
206 return (FALSE);
207 }
208 if (strncmp(arVersion, "!<arch>", 7) != 0) {
209 errorMsg("ar header fails check ");
210 return (FALSE);
211 }
212 while ((status = fullRead(arFd, (char *) &rawArHeader, AR_BLOCK_SIZE))
213 == AR_BLOCK_SIZE) {
214 readArHeader(&rawArHeader, &arEntry);
215
216 if (display == 1) {
217 displayContents(&arEntry, funct);
218 }
219 if (argc == 3)
220 found = 1;
221 else {
222 found = 0;
223 for (i = 0; i < (argc - 3); i++) {
224 if ((status = (strcmp(selName[i], arEntry.name))) == 0)
225 found = 1;
226 }
227 }
228 if ((extract == 1) && (found == 1)) {
229 if (extToStdout == 1) {
230 copySubFile(arFd, fileno(stdout), arEntry.size);
231 } else {
232 extractToFile(arFd, "./", arEntry.name, arEntry.size);
233 }
234 } else
235 lseek(arFd, arEntry.size, SEEK_CUR);
236 }
237 return (0);
238}
239
240extern int ar_main(int argc, char **argv)
241{
242 int ret = 0;
243 char *opt_ptr;
244 char c;
245 int funct = 0;
246
247 if (argc < 2)
248 usage(ar_usage);
249
250 opt_ptr = argv[1];
251 if (*opt_ptr == '-')
252 ++opt_ptr;
253 while ((c = *opt_ptr++) != '\0') {
254 switch (c) {
255 case 'o': /* preserver original dates */
256 funct = funct | 1;
257 break;
258 case 'p': /* extract to stdout */
259 funct = funct | 16;
260 break;
261 case 't': /* display contents */
262 funct = funct | 4;
263 break;
264 case 'x': /* extract contents of archive */
265 funct = funct | 8;
266 break;
267 case 'v': /* be verbose */
268 funct = funct | 2;
269 break;
270 default:
271 usage(ar_usage);
272 }
273 }
274 if (funct > 3)
275 ret = readArFile(argv, argc, funct);
276 return (ret);
277}
diff --git a/archival/ar.c b/archival/ar.c
new file mode 100644
index 000000000..253f3348a
--- /dev/null
+++ b/archival/ar.c
@@ -0,0 +1,277 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Mini ar implementation for busybox
4 *
5 * Copyright (C) 2000 by Glenn McGrath
6 * Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
7 *
8 * Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26
27#include <stdio.h>
28#include <fcntl.h>
29#include <errno.h>
30#include <ctype.h>
31#include "internal.h"
32
33#define AR_BLOCK_SIZE 60
34#define BB_DECLARE_EXTERN
35#define bb_need_io_error
36#include "messages.c"
37
38struct ArHeader { /* Byte Offset */
39 char ar_name[16]; /* 0-15 */
40 char ar_date[12]; /* 16-27 */
41 char ar_uid[6], ar_gid[6]; /* 28-39 */
42 char ar_mode[8]; /* 40-47 */
43 char ar_size[10]; /* 48-57 */
44 char ar_fmag[2]; /* 58-59 */
45};
46typedef struct ArHeader ArHeader;
47
48struct ArInfo {
49 char name[17]; /* File name */
50 time_t date; /* long int, No of seconds since epoch */
51 uid_t uid; /* unsigned int, Numeric UID */
52 gid_t gid; /* unsigned int, Numeric GID */
53 mode_t mode; /* unsigned int, Unix mode */
54 size_t size; /* int, Size of the file */
55};
56typedef struct ArInfo ArInfo;
57
58static const char ar_usage[] = "ar [optxvV] archive [filenames] \n"
59#ifndef BB_FEATURE_TRIVIAL_HELP
60 "\nExtract or list files from an ar archive.\n\n"
61 "Options:\n"
62 "\to\t\tpreserve original dates\n"
63 "\tp\t\textract to stdout\n"
64 "\tt\t\tlist\n"
65 "\tx\t\textract\n"
66 "\tv\t\tverbosely list files processed\n"
67#endif
68 ;
69
70static void displayContents(struct ArInfo *entry, int funct)
71{
72 /* TODO convert mode to string */
73 if ((funct & 2) == 2)
74 printf("%i %i/%i %6i %s ", entry->mode, entry->uid, entry->gid,
75 entry->size, timeString(entry->date));
76 printf("%s\n", entry->name);
77}
78
79/* Converts to new typed struct */
80static int readArHeader(struct ArHeader *rawHeader, struct ArInfo *header)
81{
82 int count2;
83 int count;
84
85 for (count = 0; count < 16; count++) {
86 if (rawHeader->ar_name[count] == ' ') {
87 for (count2 = count; count2 < 16; count2++)
88 if (!isspace(rawHeader->ar_name[count2]))
89 break;
90 if (count2 >= 16)
91 break;
92 }
93 if (rawHeader->ar_name[count] == '/')
94 break;
95 header->name[count] = rawHeader->ar_name[count];
96 }
97 header->name[count] = '\0';
98 header->date = atoi(rawHeader->ar_date);
99 header->uid = atoi(rawHeader->ar_uid);
100 header->gid = atoi(rawHeader->ar_gid);
101 header->mode = atoi(rawHeader->ar_mode);
102 header->size = atoi(rawHeader->ar_size);
103 return (TRUE);
104}
105
106/*
107 * Copy size bytes from current position if srcFd to current position in dstFd
108 * taken from tarExtractRegularFile in tar.c
109 * could be used for ar, tar and copyFile .
110 */
111static int copySubFile(int srcFd, int dstFd, int copySize)
112{
113 int readSize, writeSize, doneSize;
114 char buffer[BUFSIZ];
115
116 while (copySize > 0) {
117 if (copySize > BUFSIZ)
118 readSize = BUFSIZ;
119 else
120 readSize = copySize;
121 writeSize = fullRead(srcFd, buffer, readSize);
122 if (writeSize <= 0) {
123 errorMsg(io_error, "copySubFile :", strerror(errno));
124 return (FALSE);
125 }
126 doneSize = fullWrite(dstFd, buffer, writeSize);
127 if (doneSize <= 0) {
128 errorMsg(io_error, "copySubFile :", strerror(errno));
129 return (FALSE);
130 }
131 copySize -= doneSize;
132 }
133 return (TRUE);
134}
135
136/*
137 * Need to add checks, stat newfile before creation,change mode from 0777
138 * extract to current dir
139 * dstStat.st_size copied from current position of file pointed to by srcFd
140 */
141static int extractToFile(int srcFd, const char *path, const char *name,
142 int size)
143{
144 int dstFd, temp;
145 struct stat tmpStat;
146 char *pathname = NULL;
147
148 if ((temp = isDirectory(path, TRUE, &tmpStat)) != TRUE) {
149 if (!createPath(path, 0777)) {
150 fatalError("Cannot extract to specified path");
151 return (FALSE);
152 }
153 }
154 temp = (strlen(path) + 16);
155 pathname = (char *) xmalloc(temp);
156 pathname = strcpy(pathname, path);
157 pathname = strcat(pathname, &name[0]);
158 dstFd = device_open(pathname, O_WRONLY | O_CREAT);
159 pathname = NULL;
160 temp = copySubFile(srcFd, dstFd, size);
161 close(dstFd);
162 return (TRUE);
163}
164
165/* Step through the ar file entries */
166static int readArFile(char **fileNames, int argc, int funct)
167{
168 int arFd = 0;
169 int pdates = 0;
170 int verbose = 0;
171 int display = 0;
172 int extract = 0;
173 int extToStdout = 0;
174 int status = 0;
175 int found = 0;
176 ArHeader rawArHeader;
177 ArInfo arEntry;
178 char arVersion[8];
179 char *arName;
180 char *selName[argc - 2];
181 int i;
182
183 if ((funct & 1) == 1)
184 pdates = 1;
185 if ((funct & 2) == 2)
186 verbose = 1;
187 if ((funct & 4) == 4)
188 display = 1;
189 if ((funct & 16) == 16) { /* extract to stdout */
190 extract = 1;
191 extToStdout = 1;
192 }
193 if ((funct & 8) == 8) { /* extract to file */
194 extract = 1;
195 }
196 arName = fileNames[2];
197 for (i = 0; i < (argc - 3); i++)
198 selName[i] = fileNames[i + 3];
199 arFd = open(arName, O_RDONLY);
200 if (arFd < 0) {
201 errorMsg("Error opening '%s': %s\n", arName, strerror(errno));
202 return (FALSE);
203 }
204 if (fullRead(arFd, arVersion, 8) <= 0) {
205 errorMsg("ar: Unexpected EOF in archive\n");
206 return (FALSE);
207 }
208 if (strncmp(arVersion, "!<arch>", 7) != 0) {
209 errorMsg("ar header fails check ");
210 return (FALSE);
211 }
212 while ((status = fullRead(arFd, (char *) &rawArHeader, AR_BLOCK_SIZE))
213 == AR_BLOCK_SIZE) {
214 readArHeader(&rawArHeader, &arEntry);
215
216 if (display == 1) {
217 displayContents(&arEntry, funct);
218 }
219 if (argc == 3)
220 found = 1;
221 else {
222 found = 0;
223 for (i = 0; i < (argc - 3); i++) {
224 if ((status = (strcmp(selName[i], arEntry.name))) == 0)
225 found = 1;
226 }
227 }
228 if ((extract == 1) && (found == 1)) {
229 if (extToStdout == 1) {
230 copySubFile(arFd, fileno(stdout), arEntry.size);
231 } else {
232 extractToFile(arFd, "./", arEntry.name, arEntry.size);
233 }
234 } else
235 lseek(arFd, arEntry.size, SEEK_CUR);
236 }
237 return (0);
238}
239
240extern int ar_main(int argc, char **argv)
241{
242 int ret = 0;
243 char *opt_ptr;
244 char c;
245 int funct = 0;
246
247 if (argc < 2)
248 usage(ar_usage);
249
250 opt_ptr = argv[1];
251 if (*opt_ptr == '-')
252 ++opt_ptr;
253 while ((c = *opt_ptr++) != '\0') {
254 switch (c) {
255 case 'o': /* preserver original dates */
256 funct = funct | 1;
257 break;
258 case 'p': /* extract to stdout */
259 funct = funct | 16;
260 break;
261 case 't': /* display contents */
262 funct = funct | 4;
263 break;
264 case 'x': /* extract contents of archive */
265 funct = funct | 8;
266 break;
267 case 'v': /* be verbose */
268 funct = funct | 2;
269 break;
270 default:
271 usage(ar_usage);
272 }
273 }
274 if (funct > 3)
275 ret = readArFile(argv, argc, funct);
276 return (ret);
277}
diff --git a/busybox.c b/busybox.c
index bf0591d66..9ee5d2e3a 100644
--- a/busybox.c
+++ b/busybox.c
@@ -32,6 +32,9 @@ void *__libc_stack_end;
32 32
33const struct BB_applet applets[] = { 33const struct BB_applet applets[] = {
34 34
35#ifdef BB_AR
36 {"ar", ar_main, _BB_DIR_USR_BIN},
37#endif
35#ifdef BB_BASENAME 38#ifdef BB_BASENAME
36 {"basename", basename_main, _BB_DIR_USR_BIN}, 39 {"basename", basename_main, _BB_DIR_USR_BIN},
37#endif 40#endif
diff --git a/busybox.def.h b/busybox.def.h
index ea17a3982..42a63d8ee 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -7,6 +7,7 @@
7// 7//
8// 8//
9// BusyBox Applications 9// BusyBox Applications
10#define BB_AR
10#define BB_BASENAME 11#define BB_BASENAME
11#define BB_CAT 12#define BB_CAT
12#define BB_CHMOD_CHOWN_CHGRP 13#define BB_CHMOD_CHOWN_CHGRP
diff --git a/coreutils/pwd.c b/coreutils/pwd.c
index 19494a96c..146ef332b 100644
--- a/coreutils/pwd.c
+++ b/coreutils/pwd.c
@@ -31,7 +31,7 @@ extern int pwd_main(int argc, char **argv)
31 char buf[BUFSIZ + 1]; 31 char buf[BUFSIZ + 1];
32 32
33 if (getcwd(buf, sizeof(buf)) == NULL) 33 if (getcwd(buf, sizeof(buf)) == NULL)
34 fatalError("pwd: %s", strerror(errno)); 34 fatalError("pwd: %s\n", strerror(errno));
35 35
36 printf("%s\n", buf); 36 printf("%s\n", buf);
37 exit(TRUE); 37 exit(TRUE);
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 3b3e2f56c..2027d921d 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -336,7 +336,7 @@ static int tail_file(const char *filename, off_t n_units)
336 /* Not standard input. */ 336 /* Not standard input. */
337 fd = open(filename, O_RDONLY); 337 fd = open(filename, O_RDONLY);
338 if (fd == -1) 338 if (fd == -1)
339 fatalError("open error"); 339 perror(filename);
340 340
341 errors = tail_lines(filename, fd, (long) n_units); 341 errors = tail_lines(filename, fd, (long) n_units);
342 close(fd); 342 close(fd);
diff --git a/coreutils/test.c b/coreutils/test.c
index 9b541e33e..0a16e9328 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -185,7 +185,7 @@ test_main(int argc, char** argv)
185 185
186 if (strcmp(argv[0], "[") == 0) { 186 if (strcmp(argv[0], "[") == 0) {
187 if (strcmp(argv[--argc], "]")) 187 if (strcmp(argv[--argc], "]"))
188 fatalError("missing ]"); 188 fatalError("missing ]\n");
189 argv[argc] = NULL; 189 argv[argc] = NULL;
190 } 190 }
191 if (strcmp(argv[1], dash_dash_help) == 0) { 191 if (strcmp(argv[1], dash_dash_help) == 0) {
@@ -244,9 +244,9 @@ syntax(op, msg)
244 char *msg; 244 char *msg;
245{ 245{
246 if (op && *op) 246 if (op && *op)
247 fatalError("%s: %s", op, msg); 247 fatalError("%s: %s\n", op, msg);
248 else 248 else
249 fatalError("%s", msg); 249 fatalError("%s\n", msg);
250} 250}
251 251
252static int 252static int
@@ -481,13 +481,13 @@ getn(s)
481 r = strtol(s, &p, 10); 481 r = strtol(s, &p, 10);
482 482
483 if (errno != 0) 483 if (errno != 0)
484 fatalError("%s: out of range", s); 484 fatalError("%s: out of range\n", s);
485 485
486 while (isspace(*p)) 486 while (isspace(*p))
487 p++; 487 p++;
488 488
489 if (*p) 489 if (*p)
490 fatalError("%s: bad number", s); 490 fatalError("%s: bad number\n", s);
491 491
492 return (int) r; 492 return (int) r;
493} 493}
@@ -567,7 +567,7 @@ initialize_group_array ()
567{ 567{
568 ngroups = getgroups(0, NULL); 568 ngroups = getgroups(0, NULL);
569 if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL) 569 if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL)
570 fatalError("Out of space"); 570 fatalError("Out of space\n");
571 571
572 getgroups(ngroups, group_array); 572 getgroups(ngroups, group_array);
573} 573}
diff --git a/docs/busybox.net/BusyBox.html b/docs/busybox.net/BusyBox.html
index 0741c013b..86c819198 100644
--- a/docs/busybox.net/BusyBox.html
+++ b/docs/busybox.net/BusyBox.html
@@ -100,8 +100,8 @@ Most BusyBox commands support the <STRONG>--help</STRONG> option to provide a te
100Currently defined functions include: 100Currently defined functions include:
101 101
102<P> 102<P>
103basename, cat, chgrp, chmod, chown, chroot, clear, chvt, cp, cut, date, dd, 103ar, basename, cat, chgrp, chmod, chown, chroot, clear, chvt, cp, cut, date,
104df, dirname, dmesg, du, dutmp, echo, false, fbset, fdflush, find, free, 104dd, df, dirname, dmesg, du, dutmp, echo, false, fbset, fdflush, find, free,
105freeramdisk, deallocvt, fsck.minix, grep, gunzip, gzip, halt, head, hostid, 105freeramdisk, deallocvt, fsck.minix, grep, gunzip, gzip, halt, head, hostid,
106hostname, id, init, kill, killall, length, ln, loadacm, loadfont, loadkmap, 106hostname, id, init, kill, killall, length, ln, loadacm, loadfont, loadkmap,
107logger, logname, ls, lsmod, makedevs, math, mkdir, mkfifo, mkfs.minix, 107logger, logname, ls, lsmod, makedevs, math, mkdir, mkfifo, mkfs.minix,
@@ -115,6 +115,26 @@ yes, zcat, [
115------------------------------- 115-------------------------------
116 116
117<DL> 117<DL>
118<DT><STRONG><A NAME="item_ar">ar</A></STRONG><DD>
119<P>
120Usage: ar [optxvV] archive [filenames]
121
122<P>
123Extract or list files from an ar archive.
124
125<P>
126Options:
127
128<P>
129<PRE> o preserve original dates
130 p extract to stdout
131 t list
132 x extract
133 v verbosely list files processed
134</PRE>
135<P>
136-------------------------------
137
118<DT><STRONG><A NAME="item_basename">basename</A></STRONG><DD> 138<DT><STRONG><A NAME="item_basename">basename</A></STRONG><DD>
119<P> 139<P>
120Usage: basename FILE [SUFFIX] 140Usage: basename FILE [SUFFIX]
@@ -2433,6 +2453,12 @@ HREF="mailto:john@deltanet.com">john@deltanet.com</A>&gt;
2433<br> 2453<br>
2434 2454
2435<P> 2455<P>
2456Glenn McGrath &lt;<A
2457HREF="mailto:bug1@netconnect.com.au">bug1@netconnect.com.au</A>&gt;
2458
2459<br>
2460
2461<P>
2436Bruce Perens &lt;<A HREF="mailto:bruce@perens.com">bruce@perens.com</A>&gt; 2462Bruce Perens &lt;<A HREF="mailto:bruce@perens.com">bruce@perens.com</A>&gt;
2437 2463
2438<br> 2464<br>
diff --git a/docs/busybox.pod b/docs/busybox.pod
index e8b5a9ed9..5b9205b60 100644
--- a/docs/busybox.pod
+++ b/docs/busybox.pod
@@ -55,8 +55,8 @@ terse runtime description of their behavior.
55 55
56Currently defined functions include: 56Currently defined functions include:
57 57
58basename, cat, chgrp, chmod, chown, chroot, clear, chvt, cp, cut, date, dd, df, 58ar, basename, cat, chgrp, chmod, chown, chroot, clear, chvt, cp, cut, date, dd,
59dirname, dmesg, du, dutmp, echo, false, fbset, fdflush, find, free, 59df, dirname, dmesg, du, dutmp, echo, false, fbset, fdflush, find, free,
60freeramdisk, deallocvt, fsck.minix, grep, gunzip, gzip, halt, head, hostid, 60freeramdisk, deallocvt, fsck.minix, grep, gunzip, gzip, halt, head, hostid,
61hostname, id, init, kill, killall, length, ln, loadacm, loadfont, loadkmap, 61hostname, id, init, kill, killall, length, ln, loadacm, loadfont, loadkmap,
62logger, logname, ls, lsmod, makedevs, math, mkdir, mkfifo, mkfs.minix, mknod, 62logger, logname, ls, lsmod, makedevs, math, mkdir, mkfifo, mkfs.minix, mknod,
@@ -69,6 +69,22 @@ uname, uniq, update, uptime, usleep, wc, whoami, yes, zcat, [
69 69
70=over 4 70=over 4
71 71
72=item ar
73
74Usage: ar [optxvV] archive [filenames]
75
76Extract or list files from an ar archive.
77
78Options:
79
80 o preserve original dates
81 p extract to stdout
82 t list
83 x extract
84 v verbosely list files processed
85
86-------------------------------
87
72=item basename 88=item basename
73 89
74Usage: basename FILE [SUFFIX] 90Usage: basename FILE [SUFFIX]
@@ -1904,6 +1920,10 @@ John Lombardo <john@deltanet.com>
1904 1920
1905=for html <br> 1921=for html <br>
1906 1922
1923Glenn McGrath <bug1@netconnect.com.au>
1924
1925=for html <br>
1926
1907Bruce Perens <bruce@perens.com> 1927Bruce Perens <bruce@perens.com>
1908 1928
1909=for html <br> 1929=for html <br>
@@ -1926,4 +1946,4 @@ Enrique Zanardi <ezanardi@ull.es>
1926 1946
1927=cut 1947=cut
1928 1948
1929# $Id: busybox.pod,v 1.32 2000/06/02 03:30:50 andersen Exp $ 1949# $Id: busybox.pod,v 1.33 2000/06/02 03:21:37 andersen Exp $
diff --git a/internal.h b/internal.h
index 909bf6473..26248621e 100644
--- a/internal.h
+++ b/internal.h
@@ -98,6 +98,7 @@ struct BB_applet {
98/* From busybox.c */ 98/* From busybox.c */
99extern const struct BB_applet applets[]; 99extern const struct BB_applet applets[];
100 100
101extern int ar_main(int argc, char **argv);
101extern int basename_main(int argc, char **argv); 102extern int basename_main(int argc, char **argv);
102extern int busybox_main(int argc, char** argv); 103extern int busybox_main(int argc, char** argv);
103extern int block_device_main(int argc, char** argv); 104extern int block_device_main(int argc, char** argv);
diff --git a/kill.c b/kill.c
index 0487f6a66..1f1bee48b 100644
--- a/kill.c
+++ b/kill.c
@@ -234,6 +234,9 @@ extern int kill_main(int argc, char **argv)
234 pid_t* pidList; 234 pid_t* pidList;
235 235
236 pidList = findPidByName( *argv); 236 pidList = findPidByName( *argv);
237 if (!pidList)
238 errorMsg( "%s: no process killed\n", *argv);
239
237 for(; pidList && *pidList!=0; pidList++) { 240 for(; pidList && *pidList!=0; pidList++) {
238 if (*pidList==myPid) 241 if (*pidList==myPid)
239 continue; 242 continue;
diff --git a/more.c b/more.c
index 50446861e..974149177 100644
--- a/more.c
+++ b/more.c
@@ -74,9 +74,9 @@ void gotsig(int sig)
74 74
75#if defined BB_FEATURE_AUTOWIDTH 75#if defined BB_FEATURE_AUTOWIDTH
76#ifdef BB_FEATURE_USE_TERMIOS 76#ifdef BB_FEATURE_USE_TERMIOS
77static int terminal_width = 0; 77static int terminal_width = TERMINAL_WIDTH;
78#endif 78#endif
79static int terminal_height = 0; 79static int terminal_height = TERMINAL_HEIGHT;
80#else 80#else
81#define terminal_width TERMINAL_WIDTH 81#define terminal_width TERMINAL_WIDTH
82#define terminal_height TERMINAL_HEIGHT 82#define terminal_height TERMINAL_HEIGHT
diff --git a/procps/kill.c b/procps/kill.c
index 0487f6a66..1f1bee48b 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -234,6 +234,9 @@ extern int kill_main(int argc, char **argv)
234 pid_t* pidList; 234 pid_t* pidList;
235 235
236 pidList = findPidByName( *argv); 236 pidList = findPidByName( *argv);
237 if (!pidList)
238 errorMsg( "%s: no process killed\n", *argv);
239
237 for(; pidList && *pidList!=0; pidList++) { 240 for(; pidList && *pidList!=0; pidList++) {
238 if (*pidList==myPid) 241 if (*pidList==myPid)
239 continue; 242 continue;
diff --git a/procps/ps.c b/procps/ps.c
index 0842a22c2..41b8465bd 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -40,6 +40,9 @@
40#define bb_need_help 40#define bb_need_help
41#include "messages.c" 41#include "messages.c"
42 42
43#define TERMINAL_WIDTH 79 /* not 80 in case terminal has linefold bug */
44
45
43 46
44#if ! defined BB_FEATURE_USE_DEVPS_PATCH 47#if ! defined BB_FEATURE_USE_DEVPS_PATCH
45 48
@@ -124,9 +127,9 @@ extern int ps_main(int argc, char **argv)
124 int len, i, c; 127 int len, i, c;
125#ifdef BB_FEATURE_AUTOWIDTH 128#ifdef BB_FEATURE_AUTOWIDTH
126 struct winsize win = { 0, 0 }; 129 struct winsize win = { 0, 0 };
127 int terminal_width = 0; 130 int terminal_width = TERMINAL_WIDTH;
128#else 131#else
129#define terminal_width 79 132#define terminal_width TERMINAL_WIDTH
130#endif 133#endif
131 134
132 135
@@ -142,7 +145,7 @@ extern int ps_main(int argc, char **argv)
142 145
143 dir = opendir("/proc"); 146 dir = opendir("/proc");
144 if (!dir) 147 if (!dir)
145 fatalError("Can't open /proc"); 148 fatalError("Can't open /proc\n");
146 149
147#ifdef BB_FEATURE_AUTOWIDTH 150#ifdef BB_FEATURE_AUTOWIDTH
148 ioctl(fileno(stdout), TIOCGWINSZ, &win); 151 ioctl(fileno(stdout), TIOCGWINSZ, &win);
@@ -214,9 +217,9 @@ extern int ps_main(int argc, char **argv)
214 char groupName[10] = ""; 217 char groupName[10] = "";
215#ifdef BB_FEATURE_AUTOWIDTH 218#ifdef BB_FEATURE_AUTOWIDTH
216 struct winsize win = { 0, 0 }; 219 struct winsize win = { 0, 0 };
217 int terminal_width = 0; 220 int terminal_width = TERMINAL_WIDTH;
218#else 221#else
219#define terminal_width 79 222#define terminal_width TERMINAL_WIDTH
220#endif 223#endif
221 224
222 if (argc > 1 && **(argv + 1) == '-') 225 if (argc > 1 && **(argv + 1) == '-')
diff --git a/ps.c b/ps.c
index 0842a22c2..41b8465bd 100644
--- a/ps.c
+++ b/ps.c
@@ -40,6 +40,9 @@
40#define bb_need_help 40#define bb_need_help
41#include "messages.c" 41#include "messages.c"
42 42
43#define TERMINAL_WIDTH 79 /* not 80 in case terminal has linefold bug */
44
45
43 46
44#if ! defined BB_FEATURE_USE_DEVPS_PATCH 47#if ! defined BB_FEATURE_USE_DEVPS_PATCH
45 48
@@ -124,9 +127,9 @@ extern int ps_main(int argc, char **argv)
124 int len, i, c; 127 int len, i, c;
125#ifdef BB_FEATURE_AUTOWIDTH 128#ifdef BB_FEATURE_AUTOWIDTH
126 struct winsize win = { 0, 0 }; 129 struct winsize win = { 0, 0 };
127 int terminal_width = 0; 130 int terminal_width = TERMINAL_WIDTH;
128#else 131#else
129#define terminal_width 79 132#define terminal_width TERMINAL_WIDTH
130#endif 133#endif
131 134
132 135
@@ -142,7 +145,7 @@ extern int ps_main(int argc, char **argv)
142 145
143 dir = opendir("/proc"); 146 dir = opendir("/proc");
144 if (!dir) 147 if (!dir)
145 fatalError("Can't open /proc"); 148 fatalError("Can't open /proc\n");
146 149
147#ifdef BB_FEATURE_AUTOWIDTH 150#ifdef BB_FEATURE_AUTOWIDTH
148 ioctl(fileno(stdout), TIOCGWINSZ, &win); 151 ioctl(fileno(stdout), TIOCGWINSZ, &win);
@@ -214,9 +217,9 @@ extern int ps_main(int argc, char **argv)
214 char groupName[10] = ""; 217 char groupName[10] = "";
215#ifdef BB_FEATURE_AUTOWIDTH 218#ifdef BB_FEATURE_AUTOWIDTH
216 struct winsize win = { 0, 0 }; 219 struct winsize win = { 0, 0 };
217 int terminal_width = 0; 220 int terminal_width = TERMINAL_WIDTH;
218#else 221#else
219#define terminal_width 79 222#define terminal_width TERMINAL_WIDTH
220#endif 223#endif
221 224
222 if (argc > 1 && **(argv + 1) == '-') 225 if (argc > 1 && **(argv + 1) == '-')
diff --git a/pwd.c b/pwd.c
index 19494a96c..146ef332b 100644
--- a/pwd.c
+++ b/pwd.c
@@ -31,7 +31,7 @@ extern int pwd_main(int argc, char **argv)
31 char buf[BUFSIZ + 1]; 31 char buf[BUFSIZ + 1];
32 32
33 if (getcwd(buf, sizeof(buf)) == NULL) 33 if (getcwd(buf, sizeof(buf)) == NULL)
34 fatalError("pwd: %s", strerror(errno)); 34 fatalError("pwd: %s\n", strerror(errno));
35 35
36 printf("%s\n", buf); 36 printf("%s\n", buf);
37 exit(TRUE); 37 exit(TRUE);
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index faa6f15e9..9a4af4926 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -194,7 +194,7 @@ static void doSyslogd (void)
194 /* Create the syslog file so realpath() can work. */ 194 /* Create the syslog file so realpath() can work. */
195 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); 195 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
196 if (realpath (_PATH_LOG, lfile) == NULL) 196 if (realpath (_PATH_LOG, lfile) == NULL)
197 fatalError ("Could not resolv path to " _PATH_LOG ": %s", strerror (errno)); 197 fatalError ("Could not resolv path to " _PATH_LOG ": %s\n", strerror (errno));
198 198
199 unlink (lfile); 199 unlink (lfile);
200 200
@@ -202,14 +202,14 @@ static void doSyslogd (void)
202 sunx.sun_family = AF_UNIX; 202 sunx.sun_family = AF_UNIX;
203 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); 203 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
204 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) 204 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
205 fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s", strerror (errno)); 205 fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno));
206 206
207 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); 207 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
208 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) 208 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
209 fatalError ("Could not connect to socket " _PATH_LOG ": %s", strerror (errno)); 209 fatalError ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno));
210 210
211 if (chmod (lfile, 0666) < 0) 211 if (chmod (lfile, 0666) < 0)
212 fatalError ("Could not set permission on " _PATH_LOG ": %s", strerror (errno)); 212 fatalError ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno));
213 213
214 FD_ZERO (&fds); 214 FD_ZERO (&fds);
215 FD_SET (sock_fd, &fds); 215 FD_SET (sock_fd, &fds);
diff --git a/syslogd.c b/syslogd.c
index faa6f15e9..9a4af4926 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -194,7 +194,7 @@ static void doSyslogd (void)
194 /* Create the syslog file so realpath() can work. */ 194 /* Create the syslog file so realpath() can work. */
195 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); 195 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
196 if (realpath (_PATH_LOG, lfile) == NULL) 196 if (realpath (_PATH_LOG, lfile) == NULL)
197 fatalError ("Could not resolv path to " _PATH_LOG ": %s", strerror (errno)); 197 fatalError ("Could not resolv path to " _PATH_LOG ": %s\n", strerror (errno));
198 198
199 unlink (lfile); 199 unlink (lfile);
200 200
@@ -202,14 +202,14 @@ static void doSyslogd (void)
202 sunx.sun_family = AF_UNIX; 202 sunx.sun_family = AF_UNIX;
203 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); 203 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
204 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) 204 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
205 fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s", strerror (errno)); 205 fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno));
206 206
207 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); 207 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
208 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) 208 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
209 fatalError ("Could not connect to socket " _PATH_LOG ": %s", strerror (errno)); 209 fatalError ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno));
210 210
211 if (chmod (lfile, 0666) < 0) 211 if (chmod (lfile, 0666) < 0)
212 fatalError ("Could not set permission on " _PATH_LOG ": %s", strerror (errno)); 212 fatalError ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno));
213 213
214 FD_ZERO (&fds); 214 FD_ZERO (&fds);
215 FD_SET (sock_fd, &fds); 215 FD_SET (sock_fd, &fds);
diff --git a/tail.c b/tail.c
index 3b3e2f56c..2027d921d 100644
--- a/tail.c
+++ b/tail.c
@@ -336,7 +336,7 @@ static int tail_file(const char *filename, off_t n_units)
336 /* Not standard input. */ 336 /* Not standard input. */
337 fd = open(filename, O_RDONLY); 337 fd = open(filename, O_RDONLY);
338 if (fd == -1) 338 if (fd == -1)
339 fatalError("open error"); 339 perror(filename);
340 340
341 errors = tail_lines(filename, fd, (long) n_units); 341 errors = tail_lines(filename, fd, (long) n_units);
342 close(fd); 342 close(fd);
diff --git a/test.c b/test.c
index 9b541e33e..0a16e9328 100644
--- a/test.c
+++ b/test.c
@@ -185,7 +185,7 @@ test_main(int argc, char** argv)
185 185
186 if (strcmp(argv[0], "[") == 0) { 186 if (strcmp(argv[0], "[") == 0) {
187 if (strcmp(argv[--argc], "]")) 187 if (strcmp(argv[--argc], "]"))
188 fatalError("missing ]"); 188 fatalError("missing ]\n");
189 argv[argc] = NULL; 189 argv[argc] = NULL;
190 } 190 }
191 if (strcmp(argv[1], dash_dash_help) == 0) { 191 if (strcmp(argv[1], dash_dash_help) == 0) {
@@ -244,9 +244,9 @@ syntax(op, msg)
244 char *msg; 244 char *msg;
245{ 245{
246 if (op && *op) 246 if (op && *op)
247 fatalError("%s: %s", op, msg); 247 fatalError("%s: %s\n", op, msg);
248 else 248 else
249 fatalError("%s", msg); 249 fatalError("%s\n", msg);
250} 250}
251 251
252static int 252static int
@@ -481,13 +481,13 @@ getn(s)
481 r = strtol(s, &p, 10); 481 r = strtol(s, &p, 10);
482 482
483 if (errno != 0) 483 if (errno != 0)
484 fatalError("%s: out of range", s); 484 fatalError("%s: out of range\n", s);
485 485
486 while (isspace(*p)) 486 while (isspace(*p))
487 p++; 487 p++;
488 488
489 if (*p) 489 if (*p)
490 fatalError("%s: bad number", s); 490 fatalError("%s: bad number\n", s);
491 491
492 return (int) r; 492 return (int) r;
493} 493}
@@ -567,7 +567,7 @@ initialize_group_array ()
567{ 567{
568 ngroups = getgroups(0, NULL); 568 ngroups = getgroups(0, NULL);
569 if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL) 569 if ((group_array = realloc(group_array, ngroups * sizeof(gid_t))) == NULL)
570 fatalError("Out of space"); 570 fatalError("Out of space\n");
571 571
572 getgroups(ngroups, group_array); 572 getgroups(ngroups, group_array);
573} 573}
diff --git a/util-linux/more.c b/util-linux/more.c
index 50446861e..974149177 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -74,9 +74,9 @@ void gotsig(int sig)
74 74
75#if defined BB_FEATURE_AUTOWIDTH 75#if defined BB_FEATURE_AUTOWIDTH
76#ifdef BB_FEATURE_USE_TERMIOS 76#ifdef BB_FEATURE_USE_TERMIOS
77static int terminal_width = 0; 77static int terminal_width = TERMINAL_WIDTH;
78#endif 78#endif
79static int terminal_height = 0; 79static int terminal_height = TERMINAL_HEIGHT;
80#else 80#else
81#define terminal_width TERMINAL_WIDTH 81#define terminal_width TERMINAL_WIDTH
82#define terminal_height TERMINAL_HEIGHT 82#define terminal_height TERMINAL_HEIGHT
diff --git a/utility.c b/utility.c
index 07e540e22..68bdc3197 100644
--- a/utility.c
+++ b/utility.c
@@ -1583,12 +1583,12 @@ cstring_alloc(FILE* f, int depth)
1583 char *cstring; 1583 char *cstring;
1584 char buffer[CSTRING_BUFFER_LENGTH]; 1584 char buffer[CSTRING_BUFFER_LENGTH];
1585 int target = CSTRING_BUFFER_LENGTH * depth; 1585 int target = CSTRING_BUFFER_LENGTH * depth;
1586 int i, len; 1586 int c, i, len, size;
1587 int size;
1588 1587
1589 /* fill buffer */ 1588 /* fill buffer */
1590 i = 0; 1589 i = 0;
1591 while ((buffer[i] = fgetc(f)) != EOF) { 1590 while ((c = fgetc(f)) != EOF) {
1591 buffer[i] = (char) c;
1592 if (buffer[i++] == 0x0a) { break; } 1592 if (buffer[i++] == 0x0a) { break; }
1593 if (i == CSTRING_BUFFER_LENGTH) { break; } 1593 if (i == CSTRING_BUFFER_LENGTH) { break; }
1594 } 1594 }