aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--applets/busybox.c4
-rw-r--r--archival/tar.c25
-rw-r--r--busybox.c4
-rw-r--r--chroot.c4
-rw-r--r--console-tools/dumpkmap.c2
-rw-r--r--console-tools/loadacm.c6
-rw-r--r--coreutils/chroot.c4
-rw-r--r--coreutils/cut.c2
-rw-r--r--coreutils/head.c2
-rw-r--r--coreutils/ls.c6
-rw-r--r--coreutils/md5sum.c10
-rw-r--r--coreutils/pwd.c4
-rw-r--r--coreutils/tee.c2
-rw-r--r--coreutils/uudecode.c4
-rw-r--r--coreutils/uuencode.c7
-rw-r--r--cp_mv.c19
-rw-r--r--cut.c2
-rw-r--r--dumpkmap.c2
-rw-r--r--editors/sed.c2
-rw-r--r--findutils/grep.c2
-rw-r--r--freeramdisk.c4
-rw-r--r--grep.c2
-rw-r--r--head.c2
-rw-r--r--insmod.c26
-rw-r--r--kill.c6
-rw-r--r--loadacm.c6
-rw-r--r--ls.c6
-rw-r--r--md5sum.c10
-rw-r--r--miscutils/readlink.c2
-rw-r--r--modutils/insmod.c26
-rw-r--r--mount.c19
-rw-r--r--networking/ping.c4
-rw-r--r--networking/telnet.c2
-rw-r--r--ping.c4
-rw-r--r--procps/kill.c6
-rw-r--r--procps/ps.c10
-rw-r--r--ps.c10
-rw-r--r--pwd.c4
-rw-r--r--rdate.c10
-rw-r--r--readlink.c2
-rw-r--r--sed.c2
-rw-r--r--sysklogd/syslogd.c12
-rw-r--r--syslogd.c12
-rw-r--r--tar.c25
-rw-r--r--tee.c2
-rw-r--r--telnet.c2
-rw-r--r--util-linux/freeramdisk.c4
-rw-r--r--util-linux/mount.c19
-rw-r--r--util-linux/rdate.c10
-rw-r--r--utility.c16
-rw-r--r--uudecode.c4
-rw-r--r--uuencode.c7
52 files changed, 185 insertions, 204 deletions
diff --git a/applets/busybox.c b/applets/busybox.c
index e6f25afb5..0439fb566 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -54,7 +54,7 @@ static char *busybox_fullpath()
54 if (len != -1) { 54 if (len != -1) {
55 path[len] = 0; 55 path[len] = 0;
56 } else { 56 } else {
57 error_msg("%s: %s\n", proc, strerror(errno)); 57 perror_msg("%s", proc);
58 return NULL; 58 return NULL;
59 } 59 }
60 return strdup(path); 60 return strdup(path);
@@ -78,7 +78,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
78 rc = Link(busybox, command); 78 rc = Link(busybox, command);
79 79
80 if (rc) { 80 if (rc) {
81 error_msg("%s: %s\n", command, strerror(errno)); 81 perror_msg("%s", command);
82 } 82 }
83 } 83 }
84} 84}
diff --git a/archival/tar.c b/archival/tar.c
index e1beee117..c6a2a6627 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -317,7 +317,7 @@ extern int tar_main(int argc, char **argv)
317 else 317 else
318 tarFd = open(tarName, O_RDONLY); 318 tarFd = open(tarName, O_RDONLY);
319 if (tarFd < 0) 319 if (tarFd < 0)
320 error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno)); 320 perror_msg_and_die("Error opening '%s'", tarName);
321 321
322#ifdef BB_FEATURE_TAR_GZIP 322#ifdef BB_FEATURE_TAR_GZIP
323 /* unzip tarFd in a seperate process */ 323 /* unzip tarFd in a seperate process */
@@ -425,8 +425,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
425 return( TRUE); 425 return( TRUE);
426 426
427 if (create_path(header->name, header->mode) != TRUE) { 427 if (create_path(header->name, header->mode) != TRUE) {
428 error_msg("%s: Cannot mkdir: %s\n", 428 perror_msg("%s: Cannot mkdir", header->name);
429 header->name, strerror(errno));
430 return( FALSE); 429 return( FALSE);
431 } 430 }
432 /* make the final component, just in case it was 431 /* make the final component, just in case it was
@@ -445,8 +444,8 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
445 return( TRUE); 444 return( TRUE);
446 445
447 if (link(header->linkname, header->name) < 0) { 446 if (link(header->linkname, header->name) < 0) {
448 error_msg("%s: Cannot create hard link to '%s': %s\n", 447 perror_msg("%s: Cannot create hard link to '%s'", header->name,
449 header->name, header->linkname, strerror(errno)); 448 header->linkname);
450 return( FALSE); 449 return( FALSE);
451 } 450 }
452 451
@@ -463,8 +462,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
463 462
464#ifdef S_ISLNK 463#ifdef S_ISLNK
465 if (symlink(header->linkname, header->name) < 0) { 464 if (symlink(header->linkname, header->name) < 0) {
466 error_msg("%s: Cannot create symlink to '%s': %s\n", 465 perror_msg("%s: Cannot create symlink to '%s'", header->name,
467 header->name, header->linkname, strerror(errno)); 466 header->linkname);
468 return( FALSE); 467 return( FALSE);
469 } 468 }
470 /* Try to change ownership of the symlink. 469 /* Try to change ownership of the symlink.
@@ -493,14 +492,12 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
493 492
494 if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) { 493 if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
495 if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) { 494 if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
496 error_msg("%s: Cannot mknod: %s\n", 495 perror_msg("%s: Cannot mknod", header->name);
497 header->name, strerror(errno));
498 return( FALSE); 496 return( FALSE);
499 } 497 }
500 } else if (S_ISFIFO(header->mode)) { 498 } else if (S_ISFIFO(header->mode)) {
501 if (mkfifo(header->name, header->mode) < 0) { 499 if (mkfifo(header->name, header->mode) < 0) {
502 error_msg("%s: Cannot mkfifo: %s\n", 500 perror_msg("%s: Cannot mkfifo", header->name);
503 header->name, strerror(errno));
504 return( FALSE); 501 return( FALSE);
505 } 502 }
506 } 503 }
@@ -790,7 +787,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
790 close(tarFd); 787 close(tarFd);
791 if (status > 0) { 788 if (status > 0) {
792 /* Bummer - we read a partial header */ 789 /* Bummer - we read a partial header */
793 error_msg( "Error reading tar file: %s\n", strerror(errno)); 790 perror_msg("Error reading tar file");
794 return ( FALSE); 791 return ( FALSE);
795 } 792 }
796 else if (errorFlag==TRUE) { 793 else if (errorFlag==TRUE) {
@@ -1007,7 +1004,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
1007 header.typeflag = SYMTYPE; 1004 header.typeflag = SYMTYPE;
1008 link_size = readlink(fileName, buffer, sizeof(buffer) - 1); 1005 link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
1009 if ( link_size < 0) { 1006 if ( link_size < 0) {
1010 error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); 1007 perror_msg("Error reading symlink '%s'", header.name);
1011 return ( FALSE); 1008 return ( FALSE);
1012 } 1009 }
1013 buffer[link_size] = '\0'; 1010 buffer[link_size] = '\0';
@@ -1165,7 +1162,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
1165 else 1162 else
1166 tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); 1163 tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
1167 if (tbInfo.tarFd < 0) { 1164 if (tbInfo.tarFd < 0) {
1168 error_msg( "Error opening '%s': %s\n", tarName, strerror(errno)); 1165 perror_msg( "Error opening '%s'", tarName);
1169 freeHardLinkInfo(&tbInfo.hlInfoHead); 1166 freeHardLinkInfo(&tbInfo.hlInfoHead);
1170 return ( FALSE); 1167 return ( FALSE);
1171 } 1168 }
diff --git a/busybox.c b/busybox.c
index e6f25afb5..0439fb566 100644
--- a/busybox.c
+++ b/busybox.c
@@ -54,7 +54,7 @@ static char *busybox_fullpath()
54 if (len != -1) { 54 if (len != -1) {
55 path[len] = 0; 55 path[len] = 0;
56 } else { 56 } else {
57 error_msg("%s: %s\n", proc, strerror(errno)); 57 perror_msg("%s", proc);
58 return NULL; 58 return NULL;
59 } 59 }
60 return strdup(path); 60 return strdup(path);
@@ -78,7 +78,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
78 rc = Link(busybox, command); 78 rc = Link(busybox, command);
79 79
80 if (rc) { 80 if (rc) {
81 error_msg("%s: %s\n", command, strerror(errno)); 81 perror_msg("%s", command);
82 } 82 }
83 } 83 }
84} 84}
diff --git a/chroot.c b/chroot.c
index 34daf7f25..91d3407f2 100644
--- a/chroot.c
+++ b/chroot.c
@@ -38,7 +38,7 @@ int chroot_main(int argc, char **argv)
38 argv++; 38 argv++;
39 39
40 if (chroot(*argv) || (chdir("/"))) { 40 if (chroot(*argv) || (chdir("/"))) {
41 error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno)); 41 perror_msg_and_die("cannot change root directory to %s", *argv);
42 } 42 }
43 43
44 argc--; 44 argc--;
@@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv)
57 return EXIT_SUCCESS; 57 return EXIT_SUCCESS;
58#endif 58#endif
59 } 59 }
60 error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno)); 60 perror_msg_and_die("cannot execute %s", prog);
61 61
62} 62}
63 63
diff --git a/console-tools/dumpkmap.c b/console-tools/dumpkmap.c
index 3ff5ef691..c5a2ea74e 100644
--- a/console-tools/dumpkmap.c
+++ b/console-tools/dumpkmap.c
@@ -50,7 +50,7 @@ int dumpkmap_main(int argc, char **argv)
50 50
51 fd = open("/dev/tty0", O_RDWR); 51 fd = open("/dev/tty0", O_RDWR);
52 if (fd < 0) { 52 if (fd < 0) {
53 error_msg("Error opening /dev/tty0: %s\n", strerror(errno)); 53 perror_msg("Error opening /dev/tty0");
54 return EXIT_FAILURE; 54 return EXIT_FAILURE;
55 } 55 }
56 56
diff --git a/console-tools/loadacm.c b/console-tools/loadacm.c
index a69664031..52702bf6d 100644
--- a/console-tools/loadacm.c
+++ b/console-tools/loadacm.c
@@ -39,13 +39,11 @@ int loadacm_main(int argc, char **argv)
39 39
40 fd = open("/dev/tty", O_RDWR); 40 fd = open("/dev/tty", O_RDWR);
41 if (fd < 0) { 41 if (fd < 0) {
42 error_msg("Error opening /dev/tty1: %s\n", strerror(errno)); 42 perror_msg_and_die("Error opening /dev/tty1");
43 return EXIT_FAILURE;
44 } 43 }
45 44
46 if (screen_map_load(fd, stdin)) { 45 if (screen_map_load(fd, stdin)) {
47 error_msg("Error loading acm: %s\n", strerror(errno)); 46 perror_msg_and_die("Error loading acm");
48 return EXIT_FAILURE;
49 } 47 }
50 48
51 write(fd, "\033(K", 3); 49 write(fd, "\033(K", 3);
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index 34daf7f25..91d3407f2 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -38,7 +38,7 @@ int chroot_main(int argc, char **argv)
38 argv++; 38 argv++;
39 39
40 if (chroot(*argv) || (chdir("/"))) { 40 if (chroot(*argv) || (chdir("/"))) {
41 error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno)); 41 perror_msg_and_die("cannot change root directory to %s", *argv);
42 } 42 }
43 43
44 argc--; 44 argc--;
@@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv)
57 return EXIT_SUCCESS; 57 return EXIT_SUCCESS;
58#endif 58#endif
59 } 59 }
60 error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno)); 60 perror_msg_and_die("cannot execute %s", prog);
61 61
62} 62}
63 63
diff --git a/coreutils/cut.c b/coreutils/cut.c
index 8b319962d..62f9e8731 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -234,7 +234,7 @@ extern int cut_main(int argc, char **argv)
234 for (i = optind; i < argc; i++) { 234 for (i = optind; i < argc; i++) {
235 file = fopen(argv[i], "r"); 235 file = fopen(argv[i], "r");
236 if (file == NULL) { 236 if (file == NULL) {
237 error_msg("%s: %s\n", argv[i], strerror(errno)); 237 perror_msg("%s", argv[i]);
238 } else { 238 } else {
239 cut_file(file); 239 cut_file(file);
240 fclose(file); 240 fclose(file);
diff --git a/coreutils/head.c b/coreutils/head.c
index f3aef1b9b..6e05eded5 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -80,7 +80,7 @@ int head_main(int argc, char **argv)
80 } 80 }
81 head(len, fp); 81 head(len, fp);
82 if (errno) { 82 if (errno) {
83 error_msg("%s: %s\n", argv[optind], strerror(errno)); 83 perror_msg("%s", argv[optind]);
84 status = EXIT_FAILURE; 84 status = EXIT_FAILURE;
85 errno = 0; 85 errno = 0;
86 } 86 }
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 655dd7ff4..e44bd9b93 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -181,7 +181,7 @@ static int my_stat(struct dnode *cur)
181#ifdef BB_FEATURE_LS_FOLLOWLINKS 181#ifdef BB_FEATURE_LS_FOLLOWLINKS
182 if (follow_links == TRUE) { 182 if (follow_links == TRUE) {
183 if (stat(cur->fullname, &cur->dstat)) { 183 if (stat(cur->fullname, &cur->dstat)) {
184 error_msg("%s: %s\n", cur->fullname, strerror(errno)); 184 perror_msg("%s", cur->fullname);
185 status = EXIT_FAILURE; 185 status = EXIT_FAILURE;
186 free(cur->fullname); 186 free(cur->fullname);
187 free(cur); 187 free(cur);
@@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur)
190 } else 190 } else
191#endif 191#endif
192 if (lstat(cur->fullname, &cur->dstat)) { 192 if (lstat(cur->fullname, &cur->dstat)) {
193 error_msg("%s: %s\n", cur->fullname, strerror(errno)); 193 perror_msg("%s", cur->fullname);
194 status = EXIT_FAILURE; 194 status = EXIT_FAILURE;
195 free(cur->fullname); 195 free(cur->fullname);
196 free(cur); 196 free(cur);
@@ -511,7 +511,7 @@ struct dnode **list_dir(char *path)
511 nfiles= 0; 511 nfiles= 0;
512 dir = opendir(path); 512 dir = opendir(path);
513 if (dir == NULL) { 513 if (dir == NULL) {
514 error_msg("%s: %s\n", path, strerror(errno)); 514 perror_msg("%s", path);
515 status = EXIT_FAILURE; 515 status = EXIT_FAILURE;
516 return(NULL); /* could not open the dir */ 516 return(NULL); /* could not open the dir */
517 } 517 }
diff --git a/coreutils/md5sum.c b/coreutils/md5sum.c
index 57fac7450..ecc1458a2 100644
--- a/coreutils/md5sum.c
+++ b/coreutils/md5sum.c
@@ -651,13 +651,13 @@ static int md5_file(const char *filename,
651 } else { 651 } else {
652 fp = fopen(filename, OPENOPTS(binary)); 652 fp = fopen(filename, OPENOPTS(binary));
653 if (fp == NULL) { 653 if (fp == NULL) {
654 error_msg("%s: %s\n", filename, strerror(errno)); 654 perror_msg("%s", filename);
655 return FALSE; 655 return FALSE;
656 } 656 }
657 } 657 }
658 658
659 if (md5_stream(fp, md5_result)) { 659 if (md5_stream(fp, md5_result)) {
660 error_msg("%s: %s\n", filename, strerror(errno)); 660 perror_msg("%s", filename);
661 661
662 if (fp != stdin) 662 if (fp != stdin)
663 fclose(fp); 663 fclose(fp);
@@ -665,7 +665,7 @@ static int md5_file(const char *filename,
665 } 665 }
666 666
667 if (fp != stdin && fclose(fp) == EOF) { 667 if (fp != stdin && fclose(fp) == EOF) {
668 error_msg("%s: %s\n", filename, strerror(errno)); 668 perror_msg("%s", filename);
669 return FALSE; 669 return FALSE;
670 } 670 }
671 671
@@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name)
689 } else { 689 } else {
690 checkfile_stream = fopen(checkfile_name, "r"); 690 checkfile_stream = fopen(checkfile_name, "r");
691 if (checkfile_stream == NULL) { 691 if (checkfile_stream == NULL) {
692 error_msg("%s: %s\n", checkfile_name, strerror(errno)); 692 perror_msg("%s", checkfile_name);
693 return FALSE; 693 return FALSE;
694 } 694 }
695 } 695 }
@@ -775,7 +775,7 @@ static int md5_check(const char *checkfile_name)
775 } 775 }
776 776
777 if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) { 777 if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
778 error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); 778 perror_msg("md5sum: %s", checkfile_name);
779 return FALSE; 779 return FALSE;
780 } 780 }
781 781
diff --git a/coreutils/pwd.c b/coreutils/pwd.c
index 71731944c..da089f37c 100644
--- a/coreutils/pwd.c
+++ b/coreutils/pwd.c
@@ -31,8 +31,8 @@ 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 error_msg_and_die("%s\n", strerror(errno)); 34 perror_msg_and_die("getcwd");
35 35
36 printf("%s\n", buf); 36 puts(buf);
37 return EXIT_SUCCESS; 37 return EXIT_SUCCESS;
38} 38}
diff --git a/coreutils/tee.c b/coreutils/tee.c
index 347684a28..f0eca070d 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
47 while (optind < argc) { 47 while (optind < argc) {
48 if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) { 48 if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
49 nfiles--; 49 nfiles--;
50 error_msg("%s: %s\n", argv[optind-1], strerror(errno)); 50 perror_msg("%s", argv[optind-1]);
51 status = 1; 51 status = 1;
52 } 52 }
53 } 53 }
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index ff4a9d9e6..279b9d6ce 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -257,7 +257,7 @@ static int decode (const char *inname,
257 && (freopen (outname, "w", stdout) == NULL 257 && (freopen (outname, "w", stdout) == NULL
258 || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) 258 || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
259 )) { 259 )) {
260 error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */ 260 perror_msg("%s", outname); /* */
261 return FALSE; 261 return FALSE;
262 } 262 }
263 263
@@ -302,7 +302,7 @@ int uudecode_main (int argc,
302 if (decode (argv[optind], outname) != 0) 302 if (decode (argv[optind], outname) != 0)
303 exit_status = FALSE; 303 exit_status = FALSE;
304 } else { 304 } else {
305 error_msg("%s: %s\n", argv[optind], strerror(errno)); 305 perror_msg("%s", argv[optind]);
306 exit_status = EXIT_FAILURE; 306 exit_status = EXIT_FAILURE;
307 } 307 }
308 optind++; 308 optind++;
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index 41e659075..36bc4970f 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -160,15 +160,12 @@ int uuencode_main (int argc,
160 trans_ptr = uu_std; /* Standard encoding is old uu format */ 160 trans_ptr = uu_std; /* Standard encoding is old uu format */
161 161
162 /* Parse any options */ 162 /* Parse any options */
163 while ((opt = getopt (argc, argv, "m")) != EOF) { 163 while ((opt = getopt (argc, argv, "m")) > 0) {
164 switch (opt) { 164 switch (opt) {
165 case 'm': 165 case 'm':
166 trans_ptr = uu_base64; 166 trans_ptr = uu_base64;
167 break; 167 break;
168 168
169 case 0:
170 break;
171
172 default: 169 default:
173 usage(uuencode_usage); 170 usage(uuencode_usage);
174 } 171 }
@@ -178,7 +175,7 @@ int uuencode_main (int argc,
178 case 2: 175 case 2:
179 /* Optional first argument is input file. */ 176 /* Optional first argument is input file. */
180 if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { 177 if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
181 error_msg("%s: %s\n", argv[optind], strerror(errno)); 178 perror_msg("%s", argv[optind]);
182 return EXIT_FAILURE; 179 return EXIT_FAILURE;
183 } 180 }
184 mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); 181 mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
diff --git a/cp_mv.c b/cp_mv.c
index b334206fb..0b3288276 100644
--- a/cp_mv.c
+++ b/cp_mv.c
@@ -130,8 +130,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
130 if (mv_Action_first_time && (dz_i == is_mv)) { 130 if (mv_Action_first_time && (dz_i == is_mv)) {
131 mv_Action_first_time = errno = 0; 131 mv_Action_first_time = errno = 0;
132 if (rename(fileName, destName) < 0 && errno != EXDEV) { 132 if (rename(fileName, destName) < 0 && errno != EXDEV) {
133 error_msg("rename(%s, %s): %s\n", fileName, destName, 133 perror_msg("rename(%s, %s)", fileName, destName);
134 strerror(errno));
135 goto do_copyFile; /* Try anyway... */ 134 goto do_copyFile; /* Try anyway... */
136 } 135 }
137 else if (errno == EXDEV) 136 else if (errno == EXDEV)
@@ -143,7 +142,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
143 if (preserveFlag == TRUE && statbuf->st_nlink > 1) { 142 if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
144 if (is_in_ino_dev_hashtable(statbuf, &name)) { 143 if (is_in_ino_dev_hashtable(statbuf, &name)) {
145 if (link(name, destName) < 0) { 144 if (link(name, destName) < 0) {
146 error_msg("link(%s, %s): %s\n", name, destName, strerror(errno)); 145 perror_msg("link(%s, %s)", name, destName);
147 return FALSE; 146 return FALSE;
148 } 147 }
149 return TRUE; 148 return TRUE;
@@ -162,11 +161,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
162 161
163 if (S_ISDIR(statbuf->st_mode)) { 162 if (S_ISDIR(statbuf->st_mode)) {
164 if (rmdir(fileName) < 0) { 163 if (rmdir(fileName) < 0) {
165 error_msg("rmdir(%s): %s\n", fileName, strerror(errno)); 164 perror_msg("rmdir(%s)", fileName);
166 status = FALSE; 165 status = FALSE;
167 } 166 }
168 } else if (unlink(fileName) < 0) { 167 } else if (unlink(fileName) < 0) {
169 error_msg("unlink(%s): %s\n", fileName, strerror(errno)); 168 perror_msg("unlink(%s)", fileName);
170 status = FALSE; 169 status = FALSE;
171 } 170 }
172 return status; 171 return status;
@@ -260,20 +259,20 @@ extern int cp_mv_main(int argc, char **argv)
260 char *pushd, *d, *p; 259 char *pushd, *d, *p;
261 260
262 if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { 261 if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
263 error_msg("getcwd(): %s\n", strerror(errno)); 262 perror_msg("getcwd()");
264 continue; 263 continue;
265 } 264 }
266 if (chdir(baseDestName) < 0) { 265 if (chdir(baseDestName) < 0) {
267 error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno)); 266 perror_msg("chdir(%s)", baseSrcName);
268 continue; 267 continue;
269 } 268 }
270 if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { 269 if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
271 error_msg("getcwd(): %s\n", strerror(errno)); 270 perror_msg("getcwd()");
272 continue; 271 continue;
273 } 272 }
274 while (!state && *d != '\0') { 273 while (!state && *d != '\0') {
275 if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ 274 if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
276 error_msg("stat(%s): %s\n", d, strerror(errno)); 275 perror_msg("stat(%s)", d);
277 state = -1; 276 state = -1;
278 continue; 277 continue;
279 } 278 }
@@ -290,7 +289,7 @@ extern int cp_mv_main(int argc, char **argv)
290 } 289 }
291 } 290 }
292 if (chdir(pushd) < 0) { 291 if (chdir(pushd) < 0) {
293 error_msg("chdir(%s): %s\n", pushd, strerror(errno)); 292 perror_msg("chdir(%s)", pushd);
294 free(pushd); 293 free(pushd);
295 free(d); 294 free(d);
296 continue; 295 continue;
diff --git a/cut.c b/cut.c
index 8b319962d..62f9e8731 100644
--- a/cut.c
+++ b/cut.c
@@ -234,7 +234,7 @@ extern int cut_main(int argc, char **argv)
234 for (i = optind; i < argc; i++) { 234 for (i = optind; i < argc; i++) {
235 file = fopen(argv[i], "r"); 235 file = fopen(argv[i], "r");
236 if (file == NULL) { 236 if (file == NULL) {
237 error_msg("%s: %s\n", argv[i], strerror(errno)); 237 perror_msg("%s", argv[i]);
238 } else { 238 } else {
239 cut_file(file); 239 cut_file(file);
240 fclose(file); 240 fclose(file);
diff --git a/dumpkmap.c b/dumpkmap.c
index 3ff5ef691..c5a2ea74e 100644
--- a/dumpkmap.c
+++ b/dumpkmap.c
@@ -50,7 +50,7 @@ int dumpkmap_main(int argc, char **argv)
50 50
51 fd = open("/dev/tty0", O_RDWR); 51 fd = open("/dev/tty0", O_RDWR);
52 if (fd < 0) { 52 if (fd < 0) {
53 error_msg("Error opening /dev/tty0: %s\n", strerror(errno)); 53 perror_msg("Error opening /dev/tty0");
54 return EXIT_FAILURE; 54 return EXIT_FAILURE;
55 } 55 }
56 56
diff --git a/editors/sed.c b/editors/sed.c
index 812f62145..a7152e52a 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -757,7 +757,7 @@ extern int sed_main(int argc, char **argv)
757 for (i = optind; i < argc; i++) { 757 for (i = optind; i < argc; i++) {
758 file = fopen(argv[i], "r"); 758 file = fopen(argv[i], "r");
759 if (file == NULL) { 759 if (file == NULL) {
760 error_msg("%s: %s\n", argv[i], strerror(errno)); 760 perror_msg("%s", argv[i]);
761 } else { 761 } else {
762 process_file(file); 762 process_file(file);
763 fclose(file); 763 fclose(file);
diff --git a/findutils/grep.c b/findutils/grep.c
index 9014443b1..83336613e 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -169,7 +169,7 @@ extern int grep_main(int argc, char **argv)
169 file = fopen(cur_file, "r"); 169 file = fopen(cur_file, "r");
170 if (file == NULL) { 170 if (file == NULL) {
171 if (!suppress_err_msgs) 171 if (!suppress_err_msgs)
172 error_msg("%s: %s\n", cur_file, strerror(errno)); 172 perror_msg("%s", cur_file);
173 } 173 }
174 else { 174 else {
175 grep_file(file); 175 grep_file(file);
diff --git a/freeramdisk.c b/freeramdisk.c
index a568cc67c..a2b17c673 100644
--- a/freeramdisk.c
+++ b/freeramdisk.c
@@ -43,10 +43,10 @@ freeramdisk_main(int argc, char **argv)
43 } 43 }
44 44
45 if ((f = open(argv[1], O_RDWR)) == -1) { 45 if ((f = open(argv[1], O_RDWR)) == -1) {
46 error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno)); 46 perror_msg_and_die("cannot open %s", argv[1]);
47 } 47 }
48 if (ioctl(f, BLKFLSBUF) < 0) { 48 if (ioctl(f, BLKFLSBUF) < 0) {
49 error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); 49 perror_msg_and_die("failed ioctl on %s", argv[1]);
50 } 50 }
51 /* Don't bother closing. Exit does 51 /* Don't bother closing. Exit does
52 * that, so we can save a few bytes */ 52 * that, so we can save a few bytes */
diff --git a/grep.c b/grep.c
index 9014443b1..83336613e 100644
--- a/grep.c
+++ b/grep.c
@@ -169,7 +169,7 @@ extern int grep_main(int argc, char **argv)
169 file = fopen(cur_file, "r"); 169 file = fopen(cur_file, "r");
170 if (file == NULL) { 170 if (file == NULL) {
171 if (!suppress_err_msgs) 171 if (!suppress_err_msgs)
172 error_msg("%s: %s\n", cur_file, strerror(errno)); 172 perror_msg("%s", cur_file);
173 } 173 }
174 else { 174 else {
175 grep_file(file); 175 grep_file(file);
diff --git a/head.c b/head.c
index f3aef1b9b..6e05eded5 100644
--- a/head.c
+++ b/head.c
@@ -80,7 +80,7 @@ int head_main(int argc, char **argv)
80 } 80 }
81 head(len, fp); 81 head(len, fp);
82 if (errno) { 82 if (errno) {
83 error_msg("%s: %s\n", argv[optind], strerror(errno)); 83 perror_msg("%s", argv[optind]);
84 status = EXIT_FAILURE; 84 status = EXIT_FAILURE;
85 errno = 0; 85 errno = 0;
86 } 86 }
diff --git a/insmod.c b/insmod.c
index f2f1e8028..cbe00c2b4 100644
--- a/insmod.c
+++ b/insmod.c
@@ -78,7 +78,7 @@
78#ifndef MODUTILS_MODULE_H 78#ifndef MODUTILS_MODULE_H
79#define MODUTILS_MODULE_H 1 79#define MODUTILS_MODULE_H 1
80 80
81#ident "$Id: insmod.c,v 1.32 2000/12/13 16:41:29 andersen Exp $" 81#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
82 82
83/* This file contains the structures used by the 2.0 and 2.1 kernels. 83/* This file contains the structures used by the 2.0 and 2.1 kernels.
84 We do not use the kernel headers directly because we do not wish 84 We do not use the kernel headers directly because we do not wish
@@ -284,7 +284,7 @@ int delete_module(const char *);
284#ifndef MODUTILS_OBJ_H 284#ifndef MODUTILS_OBJ_H
285#define MODUTILS_OBJ_H 1 285#define MODUTILS_OBJ_H 1
286 286
287#ident "$Id: insmod.c,v 1.32 2000/12/13 16:41:29 andersen Exp $" 287#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
288 288
289/* The relocatable object is manipulated using elfin types. */ 289/* The relocatable object is manipulated using elfin types. */
290 290
@@ -1562,7 +1562,7 @@ static int old_get_kernel_symbols(const char *m_name)
1562 1562
1563 nks = get_kernel_syms(NULL); 1563 nks = get_kernel_syms(NULL);
1564 if (nks < 0) { 1564 if (nks < 0) {
1565 error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); 1565 perror_msg("get_kernel_syms: %s", m_name);
1566 return 0; 1566 return 0;
1567 } 1567 }
1568 1568
@@ -1743,7 +1743,7 @@ old_init_module(const char *m_name, struct obj_file *f,
1743 m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN 1743 m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
1744 : 0), &routines, symtab); 1744 : 0), &routines, symtab);
1745 if (ret) 1745 if (ret)
1746 error_msg("init_module: %s: %s\n", m_name, strerror(errno)); 1746 perror_msg("init_module: %s", m_name);
1747 1747
1748 free(image); 1748 free(image);
1749 free(symtab); 1749 free(symtab);
@@ -2055,7 +2055,7 @@ static int new_get_kernel_symbols(void)
2055 module_names = xrealloc(module_names, bufsize = ret); 2055 module_names = xrealloc(module_names, bufsize = ret);
2056 goto retry_modules_load; 2056 goto retry_modules_load;
2057 } 2057 }
2058 error_msg("QM_MODULES: %s\n", strerror(errno)); 2058 perror_msg("QM_MODULES");
2059 return 0; 2059 return 0;
2060 } 2060 }
2061 2061
@@ -2074,7 +2074,7 @@ static int new_get_kernel_symbols(void)
2074 /* The module was removed out from underneath us. */ 2074 /* The module was removed out from underneath us. */
2075 continue; 2075 continue;
2076 } 2076 }
2077 error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); 2077 perror_msg("query_module: QM_INFO: %s", mn);
2078 return 0; 2078 return 0;
2079 } 2079 }
2080 2080
@@ -2089,7 +2089,7 @@ static int new_get_kernel_symbols(void)
2089 /* The module was removed out from underneath us. */ 2089 /* The module was removed out from underneath us. */
2090 continue; 2090 continue;
2091 default: 2091 default:
2092 error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); 2092 perror_msg("query_module: QM_SYMBOLS: %s", mn);
2093 return 0; 2093 return 0;
2094 } 2094 }
2095 } 2095 }
@@ -2114,7 +2114,7 @@ static int new_get_kernel_symbols(void)
2114 syms = xrealloc(syms, bufsize = ret); 2114 syms = xrealloc(syms, bufsize = ret);
2115 goto retry_kern_sym_load; 2115 goto retry_kern_sym_load;
2116 } 2116 }
2117 error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); 2117 perror_msg("kernel: QM_SYMBOLS");
2118 return 0; 2118 return 0;
2119 } 2119 }
2120 nksyms = nsyms = ret; 2120 nksyms = nsyms = ret;
@@ -2295,7 +2295,7 @@ new_init_module(const char *m_name, struct obj_file *f,
2295 2295
2296 ret = new_sys_init_module(m_name, (struct new_module *) image); 2296 ret = new_sys_init_module(m_name, (struct new_module *) image);
2297 if (ret) 2297 if (ret)
2298 error_msg("init_module: %s: %s\n", m_name, strerror(errno)); 2298 perror_msg("init_module: %s", m_name);
2299 2299
2300 free(image); 2300 free(image);
2301 2301
@@ -2680,7 +2680,7 @@ struct obj_file *obj_load(FILE * fp)
2680 2680
2681 fseek(fp, 0, SEEK_SET); 2681 fseek(fp, 0, SEEK_SET);
2682 if (fread(&f->header, sizeof(f->header), 1, fp) != 1) { 2682 if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
2683 error_msg("error reading ELF header: %s\n", strerror(errno)); 2683 perror_msg("error reading ELF header");
2684 return NULL; 2684 return NULL;
2685 } 2685 }
2686 2686
@@ -2719,7 +2719,7 @@ struct obj_file *obj_load(FILE * fp)
2719 section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); 2719 section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
2720 fseek(fp, f->header.e_shoff, SEEK_SET); 2720 fseek(fp, f->header.e_shoff, SEEK_SET);
2721 if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) { 2721 if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
2722 error_msg("error reading ELF section headers: %s\n", strerror(errno)); 2722 perror_msg("error reading ELF section headers");
2723 return NULL; 2723 return NULL;
2724 } 2724 }
2725 2725
@@ -2749,7 +2749,7 @@ struct obj_file *obj_load(FILE * fp)
2749 sec->contents = xmalloc(sec->header.sh_size); 2749 sec->contents = xmalloc(sec->header.sh_size);
2750 fseek(fp, sec->header.sh_offset, SEEK_SET); 2750 fseek(fp, sec->header.sh_offset, SEEK_SET);
2751 if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { 2751 if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
2752 error_msg("error reading ELF section data: %s\n", strerror(errno)); 2752 perror_msg("error reading ELF section data");
2753 return NULL; 2753 return NULL;
2754 } 2754 }
2755 } else { 2755 } else {
@@ -3075,7 +3075,7 @@ extern int insmod_main( int argc, char **argv)
3075 m_size); 3075 m_size);
3076 goto out; 3076 goto out;
3077 default: 3077 default:
3078 error_msg("create_module: %s: %s\n", m_name, strerror(errno)); 3078 perror_msg("create_module: %s", m_name);
3079 goto out; 3079 goto out;
3080 } 3080 }
3081 3081
diff --git a/kill.c b/kill.c
index caaa52a5b..8fa9da77d 100644
--- a/kill.c
+++ b/kill.c
@@ -204,10 +204,10 @@ extern int kill_main(int argc, char **argv)
204 int pid; 204 int pid;
205 205
206 if (!isdigit(**argv)) 206 if (!isdigit(**argv))
207 error_msg_and_die( "Bad PID: %s\n", strerror(errno)); 207 perror_msg_and_die( "Bad PID");
208 pid = strtol(*argv, NULL, 0); 208 pid = strtol(*argv, NULL, 0);
209 if (kill(pid, sig) != 0) 209 if (kill(pid, sig) != 0)
210 error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno)); 210 perror_msg_and_die( "Could not kill pid '%d'", pid);
211 argv++; 211 argv++;
212 } 212 }
213 } 213 }
@@ -229,7 +229,7 @@ extern int kill_main(int argc, char **argv)
229 if (*pidList==myPid) 229 if (*pidList==myPid)
230 continue; 230 continue;
231 if (kill(*pidList, sig) != 0) 231 if (kill(*pidList, sig) != 0)
232 error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno)); 232 perror_msg_and_die( "Could not kill pid '%d'", *pidList);
233 } 233 }
234 /* Note that we don't bother to free the memory 234 /* Note that we don't bother to free the memory
235 * allocated in find_pid_by_name(). It will be freed 235 * allocated in find_pid_by_name(). It will be freed
diff --git a/loadacm.c b/loadacm.c
index a69664031..52702bf6d 100644
--- a/loadacm.c
+++ b/loadacm.c
@@ -39,13 +39,11 @@ int loadacm_main(int argc, char **argv)
39 39
40 fd = open("/dev/tty", O_RDWR); 40 fd = open("/dev/tty", O_RDWR);
41 if (fd < 0) { 41 if (fd < 0) {
42 error_msg("Error opening /dev/tty1: %s\n", strerror(errno)); 42 perror_msg_and_die("Error opening /dev/tty1");
43 return EXIT_FAILURE;
44 } 43 }
45 44
46 if (screen_map_load(fd, stdin)) { 45 if (screen_map_load(fd, stdin)) {
47 error_msg("Error loading acm: %s\n", strerror(errno)); 46 perror_msg_and_die("Error loading acm");
48 return EXIT_FAILURE;
49 } 47 }
50 48
51 write(fd, "\033(K", 3); 49 write(fd, "\033(K", 3);
diff --git a/ls.c b/ls.c
index 655dd7ff4..e44bd9b93 100644
--- a/ls.c
+++ b/ls.c
@@ -181,7 +181,7 @@ static int my_stat(struct dnode *cur)
181#ifdef BB_FEATURE_LS_FOLLOWLINKS 181#ifdef BB_FEATURE_LS_FOLLOWLINKS
182 if (follow_links == TRUE) { 182 if (follow_links == TRUE) {
183 if (stat(cur->fullname, &cur->dstat)) { 183 if (stat(cur->fullname, &cur->dstat)) {
184 error_msg("%s: %s\n", cur->fullname, strerror(errno)); 184 perror_msg("%s", cur->fullname);
185 status = EXIT_FAILURE; 185 status = EXIT_FAILURE;
186 free(cur->fullname); 186 free(cur->fullname);
187 free(cur); 187 free(cur);
@@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur)
190 } else 190 } else
191#endif 191#endif
192 if (lstat(cur->fullname, &cur->dstat)) { 192 if (lstat(cur->fullname, &cur->dstat)) {
193 error_msg("%s: %s\n", cur->fullname, strerror(errno)); 193 perror_msg("%s", cur->fullname);
194 status = EXIT_FAILURE; 194 status = EXIT_FAILURE;
195 free(cur->fullname); 195 free(cur->fullname);
196 free(cur); 196 free(cur);
@@ -511,7 +511,7 @@ struct dnode **list_dir(char *path)
511 nfiles= 0; 511 nfiles= 0;
512 dir = opendir(path); 512 dir = opendir(path);
513 if (dir == NULL) { 513 if (dir == NULL) {
514 error_msg("%s: %s\n", path, strerror(errno)); 514 perror_msg("%s", path);
515 status = EXIT_FAILURE; 515 status = EXIT_FAILURE;
516 return(NULL); /* could not open the dir */ 516 return(NULL); /* could not open the dir */
517 } 517 }
diff --git a/md5sum.c b/md5sum.c
index 57fac7450..ecc1458a2 100644
--- a/md5sum.c
+++ b/md5sum.c
@@ -651,13 +651,13 @@ static int md5_file(const char *filename,
651 } else { 651 } else {
652 fp = fopen(filename, OPENOPTS(binary)); 652 fp = fopen(filename, OPENOPTS(binary));
653 if (fp == NULL) { 653 if (fp == NULL) {
654 error_msg("%s: %s\n", filename, strerror(errno)); 654 perror_msg("%s", filename);
655 return FALSE; 655 return FALSE;
656 } 656 }
657 } 657 }
658 658
659 if (md5_stream(fp, md5_result)) { 659 if (md5_stream(fp, md5_result)) {
660 error_msg("%s: %s\n", filename, strerror(errno)); 660 perror_msg("%s", filename);
661 661
662 if (fp != stdin) 662 if (fp != stdin)
663 fclose(fp); 663 fclose(fp);
@@ -665,7 +665,7 @@ static int md5_file(const char *filename,
665 } 665 }
666 666
667 if (fp != stdin && fclose(fp) == EOF) { 667 if (fp != stdin && fclose(fp) == EOF) {
668 error_msg("%s: %s\n", filename, strerror(errno)); 668 perror_msg("%s", filename);
669 return FALSE; 669 return FALSE;
670 } 670 }
671 671
@@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name)
689 } else { 689 } else {
690 checkfile_stream = fopen(checkfile_name, "r"); 690 checkfile_stream = fopen(checkfile_name, "r");
691 if (checkfile_stream == NULL) { 691 if (checkfile_stream == NULL) {
692 error_msg("%s: %s\n", checkfile_name, strerror(errno)); 692 perror_msg("%s", checkfile_name);
693 return FALSE; 693 return FALSE;
694 } 694 }
695 } 695 }
@@ -775,7 +775,7 @@ static int md5_check(const char *checkfile_name)
775 } 775 }
776 776
777 if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) { 777 if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
778 error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); 778 perror_msg("md5sum: %s", checkfile_name);
779 return FALSE; 779 return FALSE;
780 } 780 }
781 781
diff --git a/miscutils/readlink.c b/miscutils/readlink.c
index bb40b0787..bb2056a25 100644
--- a/miscutils/readlink.c
+++ b/miscutils/readlink.c
@@ -39,7 +39,7 @@ int readlink_main(int argc, char **argv)
39 buf = xrealloc(buf, bufsize); 39 buf = xrealloc(buf, bufsize);
40 size = readlink(argv[1], buf, bufsize); 40 size = readlink(argv[1], buf, bufsize);
41 if (size == -1) 41 if (size == -1)
42 error_msg_and_die("%s: %s\n", argv[1], strerror(errno)); 42 perror_msg_and_die("%s", argv[1]);
43 } 43 }
44 44
45 buf[size] = '\0'; 45 buf[size] = '\0';
diff --git a/modutils/insmod.c b/modutils/insmod.c
index f2f1e8028..cbe00c2b4 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -78,7 +78,7 @@
78#ifndef MODUTILS_MODULE_H 78#ifndef MODUTILS_MODULE_H
79#define MODUTILS_MODULE_H 1 79#define MODUTILS_MODULE_H 1
80 80
81#ident "$Id: insmod.c,v 1.32 2000/12/13 16:41:29 andersen Exp $" 81#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
82 82
83/* This file contains the structures used by the 2.0 and 2.1 kernels. 83/* This file contains the structures used by the 2.0 and 2.1 kernels.
84 We do not use the kernel headers directly because we do not wish 84 We do not use the kernel headers directly because we do not wish
@@ -284,7 +284,7 @@ int delete_module(const char *);
284#ifndef MODUTILS_OBJ_H 284#ifndef MODUTILS_OBJ_H
285#define MODUTILS_OBJ_H 1 285#define MODUTILS_OBJ_H 1
286 286
287#ident "$Id: insmod.c,v 1.32 2000/12/13 16:41:29 andersen Exp $" 287#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
288 288
289/* The relocatable object is manipulated using elfin types. */ 289/* The relocatable object is manipulated using elfin types. */
290 290
@@ -1562,7 +1562,7 @@ static int old_get_kernel_symbols(const char *m_name)
1562 1562
1563 nks = get_kernel_syms(NULL); 1563 nks = get_kernel_syms(NULL);
1564 if (nks < 0) { 1564 if (nks < 0) {
1565 error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); 1565 perror_msg("get_kernel_syms: %s", m_name);
1566 return 0; 1566 return 0;
1567 } 1567 }
1568 1568
@@ -1743,7 +1743,7 @@ old_init_module(const char *m_name, struct obj_file *f,
1743 m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN 1743 m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
1744 : 0), &routines, symtab); 1744 : 0), &routines, symtab);
1745 if (ret) 1745 if (ret)
1746 error_msg("init_module: %s: %s\n", m_name, strerror(errno)); 1746 perror_msg("init_module: %s", m_name);
1747 1747
1748 free(image); 1748 free(image);
1749 free(symtab); 1749 free(symtab);
@@ -2055,7 +2055,7 @@ static int new_get_kernel_symbols(void)
2055 module_names = xrealloc(module_names, bufsize = ret); 2055 module_names = xrealloc(module_names, bufsize = ret);
2056 goto retry_modules_load; 2056 goto retry_modules_load;
2057 } 2057 }
2058 error_msg("QM_MODULES: %s\n", strerror(errno)); 2058 perror_msg("QM_MODULES");
2059 return 0; 2059 return 0;
2060 } 2060 }
2061 2061
@@ -2074,7 +2074,7 @@ static int new_get_kernel_symbols(void)
2074 /* The module was removed out from underneath us. */ 2074 /* The module was removed out from underneath us. */
2075 continue; 2075 continue;
2076 } 2076 }
2077 error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); 2077 perror_msg("query_module: QM_INFO: %s", mn);
2078 return 0; 2078 return 0;
2079 } 2079 }
2080 2080
@@ -2089,7 +2089,7 @@ static int new_get_kernel_symbols(void)
2089 /* The module was removed out from underneath us. */ 2089 /* The module was removed out from underneath us. */
2090 continue; 2090 continue;
2091 default: 2091 default:
2092 error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); 2092 perror_msg("query_module: QM_SYMBOLS: %s", mn);
2093 return 0; 2093 return 0;
2094 } 2094 }
2095 } 2095 }
@@ -2114,7 +2114,7 @@ static int new_get_kernel_symbols(void)
2114 syms = xrealloc(syms, bufsize = ret); 2114 syms = xrealloc(syms, bufsize = ret);
2115 goto retry_kern_sym_load; 2115 goto retry_kern_sym_load;
2116 } 2116 }
2117 error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); 2117 perror_msg("kernel: QM_SYMBOLS");
2118 return 0; 2118 return 0;
2119 } 2119 }
2120 nksyms = nsyms = ret; 2120 nksyms = nsyms = ret;
@@ -2295,7 +2295,7 @@ new_init_module(const char *m_name, struct obj_file *f,
2295 2295
2296 ret = new_sys_init_module(m_name, (struct new_module *) image); 2296 ret = new_sys_init_module(m_name, (struct new_module *) image);
2297 if (ret) 2297 if (ret)
2298 error_msg("init_module: %s: %s\n", m_name, strerror(errno)); 2298 perror_msg("init_module: %s", m_name);
2299 2299
2300 free(image); 2300 free(image);
2301 2301
@@ -2680,7 +2680,7 @@ struct obj_file *obj_load(FILE * fp)
2680 2680
2681 fseek(fp, 0, SEEK_SET); 2681 fseek(fp, 0, SEEK_SET);
2682 if (fread(&f->header, sizeof(f->header), 1, fp) != 1) { 2682 if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
2683 error_msg("error reading ELF header: %s\n", strerror(errno)); 2683 perror_msg("error reading ELF header");
2684 return NULL; 2684 return NULL;
2685 } 2685 }
2686 2686
@@ -2719,7 +2719,7 @@ struct obj_file *obj_load(FILE * fp)
2719 section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); 2719 section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
2720 fseek(fp, f->header.e_shoff, SEEK_SET); 2720 fseek(fp, f->header.e_shoff, SEEK_SET);
2721 if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) { 2721 if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
2722 error_msg("error reading ELF section headers: %s\n", strerror(errno)); 2722 perror_msg("error reading ELF section headers");
2723 return NULL; 2723 return NULL;
2724 } 2724 }
2725 2725
@@ -2749,7 +2749,7 @@ struct obj_file *obj_load(FILE * fp)
2749 sec->contents = xmalloc(sec->header.sh_size); 2749 sec->contents = xmalloc(sec->header.sh_size);
2750 fseek(fp, sec->header.sh_offset, SEEK_SET); 2750 fseek(fp, sec->header.sh_offset, SEEK_SET);
2751 if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { 2751 if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
2752 error_msg("error reading ELF section data: %s\n", strerror(errno)); 2752 perror_msg("error reading ELF section data");
2753 return NULL; 2753 return NULL;
2754 } 2754 }
2755 } else { 2755 } else {
@@ -3075,7 +3075,7 @@ extern int insmod_main( int argc, char **argv)
3075 m_size); 3075 m_size);
3076 goto out; 3076 goto out;
3077 default: 3077 default:
3078 error_msg("create_module: %s: %s\n", m_name, strerror(errno)); 3078 perror_msg("create_module: %s", m_name);
3079 goto out; 3079 goto out;
3080 } 3080 }
3081 3081
diff --git a/mount.c b/mount.c
index 06673f942..8240b99aa 100644
--- a/mount.c
+++ b/mount.c
@@ -271,18 +271,18 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
271 /* open device */ 271 /* open device */
272 fd = open(device, O_RDONLY); 272 fd = open(device, O_RDONLY);
273 if (fd < 0) 273 if (fd < 0)
274 error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); 274 perror_msg_and_die("open failed for `%s'", device);
275 275
276 /* How many filesystems? We need to know to allocate enough space */ 276 /* How many filesystems? We need to know to allocate enough space */
277 numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS); 277 numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS);
278 if (numfilesystems<0) 278 if (numfilesystems<0)
279 error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno)); 279 perror_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS");
280 fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype)); 280 fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype));
281 281
282 /* Grab the list of available filesystems */ 282 /* Grab the list of available filesystems */
283 status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist); 283 status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist);
284 if (status<0) 284 if (status<0)
285 error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno)); 285 perror_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS");
286 286
287 /* Walk the list trying to mount filesystems 287 /* Walk the list trying to mount filesystems
288 * that do not claim to be nodev filesystems */ 288 * that do not claim to be nodev filesystems */
@@ -307,8 +307,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
307 307
308 if (status == FALSE) { 308 if (status == FALSE) {
309 if (whineOnErrors == TRUE) { 309 if (whineOnErrors == TRUE) {
310 error_msg("Mounting %s on %s failed: %s\n", 310 perror_msg("Mounting %s on %s failed", blockDevice, directory);
311 blockDevice, directory, strerror(errno));
312 } 311 }
313 return (FALSE); 312 return (FALSE);
314 } 313 }
@@ -340,18 +339,18 @@ extern int mount_main(int argc, char **argv)
340 /* open device */ 339 /* open device */
341 fd = open(device, O_RDONLY); 340 fd = open(device, O_RDONLY);
342 if (fd < 0) 341 if (fd < 0)
343 error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); 342 perror_msg_and_die("open failed for `%s'", device);
344 343
345 /* How many mounted filesystems? We need to know to 344 /* How many mounted filesystems? We need to know to
346 * allocate enough space for later... */ 345 * allocate enough space for later... */
347 numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS); 346 numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
348 if (numfilesystems<0) 347 if (numfilesystems<0)
349 error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno)); 348 perror_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS");
350 mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent)); 349 mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent));
351 350
352 /* Grab the list of mounted filesystems */ 351 /* Grab the list of mounted filesystems */
353 if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0) 352 if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0)
354 error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno)); 353 perror_msg_and_die( "\nDEVMTAB_GET_MOUNTS");
355 354
356 for( i = 0 ; i < numfilesystems ; i++) { 355 for( i = 0 ; i < numfilesystems ; i++) {
357 fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname, 356 fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
@@ -453,7 +452,7 @@ extern int mount_main(int argc, char **argv)
453 fstabmount = TRUE; 452 fstabmount = TRUE;
454 453
455 if (f == NULL) 454 if (f == NULL)
456 error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno)); 455 perror_msg_and_die( "\nCannot read /etc/fstab");
457 456
458 while ((m = getmntent(f)) != NULL) { 457 while ((m = getmntent(f)) != NULL) {
459 if (all == FALSE && directory == NULL && ( 458 if (all == FALSE && directory == NULL && (
@@ -487,7 +486,7 @@ singlemount:
487 rc = nfsmount (device, directory, &flags, 486 rc = nfsmount (device, directory, &flags,
488 &extra_opts, &string_flags, 1); 487 &extra_opts, &string_flags, 1);
489 if ( rc != 0) { 488 if ( rc != 0) {
490 error_msg_and_die("nfsmount failed: %s\n", strerror(errno)); 489 perror_msg_and_die("nfsmount failed");
491 rc = EXIT_FAILURE; 490 rc = EXIT_FAILURE;
492 } 491 }
493 } 492 }
diff --git a/networking/ping.c b/networking/ping.c
index ccc535b26..4be2120c8 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * $Id: ping.c,v 1.28 2000/12/07 19:56:48 markw Exp $ 3 * $Id: ping.c,v 1.29 2000/12/18 03:57:16 kraai Exp $
4 * Mini ping implementation for busybox 4 * Mini ping implementation for busybox
5 * 5 *
6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> 6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -325,7 +325,7 @@ static void sendping(int junk)
325 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); 325 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
326 326
327 if (i < 0) 327 if (i < 0)
328 error_msg_and_die("sendto: %s\n", strerror(errno)); 328 perror_msg_and_die("sendto");
329 else if ((size_t)i != sizeof(packet)) 329 else if ((size_t)i != sizeof(packet))
330 error_msg_and_die("ping wrote %d chars; %d expected\n", i, 330 error_msg_and_die("ping wrote %d chars; %d expected\n", i,
331 (int)sizeof(packet)); 331 (int)sizeof(packet));
diff --git a/networking/telnet.c b/networking/telnet.c
index 7a7bcfb9f..fff8c06b5 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -650,7 +650,7 @@ static int remote_connect(struct in_addr addr, int port)
650 650
651 if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0) 651 if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0)
652 { 652 {
653 error_msg_and_die("Unable to connect to remote host: %s\n", strerror(errno)); 653 perror_msg_and_die("Unable to connect to remote host");
654 } 654 }
655 return s; 655 return s;
656} 656}
diff --git a/ping.c b/ping.c
index ccc535b26..4be2120c8 100644
--- a/ping.c
+++ b/ping.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * $Id: ping.c,v 1.28 2000/12/07 19:56:48 markw Exp $ 3 * $Id: ping.c,v 1.29 2000/12/18 03:57:16 kraai Exp $
4 * Mini ping implementation for busybox 4 * Mini ping implementation for busybox
5 * 5 *
6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> 6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -325,7 +325,7 @@ static void sendping(int junk)
325 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); 325 (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
326 326
327 if (i < 0) 327 if (i < 0)
328 error_msg_and_die("sendto: %s\n", strerror(errno)); 328 perror_msg_and_die("sendto");
329 else if ((size_t)i != sizeof(packet)) 329 else if ((size_t)i != sizeof(packet))
330 error_msg_and_die("ping wrote %d chars; %d expected\n", i, 330 error_msg_and_die("ping wrote %d chars; %d expected\n", i,
331 (int)sizeof(packet)); 331 (int)sizeof(packet));
diff --git a/procps/kill.c b/procps/kill.c
index caaa52a5b..8fa9da77d 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -204,10 +204,10 @@ extern int kill_main(int argc, char **argv)
204 int pid; 204 int pid;
205 205
206 if (!isdigit(**argv)) 206 if (!isdigit(**argv))
207 error_msg_and_die( "Bad PID: %s\n", strerror(errno)); 207 perror_msg_and_die( "Bad PID");
208 pid = strtol(*argv, NULL, 0); 208 pid = strtol(*argv, NULL, 0);
209 if (kill(pid, sig) != 0) 209 if (kill(pid, sig) != 0)
210 error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno)); 210 perror_msg_and_die( "Could not kill pid '%d'", pid);
211 argv++; 211 argv++;
212 } 212 }
213 } 213 }
@@ -229,7 +229,7 @@ extern int kill_main(int argc, char **argv)
229 if (*pidList==myPid) 229 if (*pidList==myPid)
230 continue; 230 continue;
231 if (kill(*pidList, sig) != 0) 231 if (kill(*pidList, sig) != 0)
232 error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno)); 232 perror_msg_and_die( "Could not kill pid '%d'", *pidList);
233 } 233 }
234 /* Note that we don't bother to free the memory 234 /* Note that we don't bother to free the memory
235 * allocated in find_pid_by_name(). It will be freed 235 * allocated in find_pid_by_name(). It will be freed
diff --git a/procps/ps.c b/procps/ps.c
index 357ece383..2b41a495f 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -216,11 +216,11 @@ extern int ps_main(int argc, char **argv)
216 /* open device */ 216 /* open device */
217 fd = open(device, O_RDONLY); 217 fd = open(device, O_RDONLY);
218 if (fd < 0) 218 if (fd < 0)
219 error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); 219 perror_msg_and_die( "open failed for `%s'", device);
220 220
221 /* Find out how many processes there are */ 221 /* Find out how many processes there are */
222 if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) 222 if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
223 error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); 223 perror_msg_and_die( "\nDEVPS_GET_PID_LIST");
224 224
225 /* Allocate some memory -- grab a few extras just in case 225 /* Allocate some memory -- grab a few extras just in case
226 * some new processes start up while we wait. The kernel will 226 * some new processes start up while we wait. The kernel will
@@ -231,7 +231,7 @@ extern int ps_main(int argc, char **argv)
231 231
232 /* Now grab the pid list */ 232 /* Now grab the pid list */
233 if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) 233 if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
234 error_msg_and_die("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); 234 perror_msg_and_die("\nDEVPS_GET_PID_LIST");
235 235
236#ifdef BB_FEATURE_AUTOWIDTH 236#ifdef BB_FEATURE_AUTOWIDTH
237 ioctl(fileno(stdout), TIOCGWINSZ, &win); 237 ioctl(fileno(stdout), TIOCGWINSZ, &win);
@@ -247,7 +247,7 @@ extern int ps_main(int argc, char **argv)
247 info.pid = pid_array[i]; 247 info.pid = pid_array[i];
248 248
249 if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) 249 if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
250 error_msg_and_die("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno)); 250 perror_msg_and_die("\nDEVPS_GET_PID_INFO");
251 251
252 /* Make some adjustments as needed */ 252 /* Make some adjustments as needed */
253 my_getpwuid(uidName, info.euid); 253 my_getpwuid(uidName, info.euid);
@@ -277,7 +277,7 @@ extern int ps_main(int argc, char **argv)
277 277
278 /* close device */ 278 /* close device */
279 if (close (fd) != 0) 279 if (close (fd) != 0)
280 error_msg_and_die("close failed for `%s': %s\n", device, strerror (errno)); 280 perror_msg_and_die("close failed for `%s'", device);
281 281
282 exit (0); 282 exit (0);
283} 283}
diff --git a/ps.c b/ps.c
index 357ece383..2b41a495f 100644
--- a/ps.c
+++ b/ps.c
@@ -216,11 +216,11 @@ extern int ps_main(int argc, char **argv)
216 /* open device */ 216 /* open device */
217 fd = open(device, O_RDONLY); 217 fd = open(device, O_RDONLY);
218 if (fd < 0) 218 if (fd < 0)
219 error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); 219 perror_msg_and_die( "open failed for `%s'", device);
220 220
221 /* Find out how many processes there are */ 221 /* Find out how many processes there are */
222 if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) 222 if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
223 error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); 223 perror_msg_and_die( "\nDEVPS_GET_PID_LIST");
224 224
225 /* Allocate some memory -- grab a few extras just in case 225 /* Allocate some memory -- grab a few extras just in case
226 * some new processes start up while we wait. The kernel will 226 * some new processes start up while we wait. The kernel will
@@ -231,7 +231,7 @@ extern int ps_main(int argc, char **argv)
231 231
232 /* Now grab the pid list */ 232 /* Now grab the pid list */
233 if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) 233 if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
234 error_msg_and_die("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); 234 perror_msg_and_die("\nDEVPS_GET_PID_LIST");
235 235
236#ifdef BB_FEATURE_AUTOWIDTH 236#ifdef BB_FEATURE_AUTOWIDTH
237 ioctl(fileno(stdout), TIOCGWINSZ, &win); 237 ioctl(fileno(stdout), TIOCGWINSZ, &win);
@@ -247,7 +247,7 @@ extern int ps_main(int argc, char **argv)
247 info.pid = pid_array[i]; 247 info.pid = pid_array[i];
248 248
249 if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) 249 if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
250 error_msg_and_die("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno)); 250 perror_msg_and_die("\nDEVPS_GET_PID_INFO");
251 251
252 /* Make some adjustments as needed */ 252 /* Make some adjustments as needed */
253 my_getpwuid(uidName, info.euid); 253 my_getpwuid(uidName, info.euid);
@@ -277,7 +277,7 @@ extern int ps_main(int argc, char **argv)
277 277
278 /* close device */ 278 /* close device */
279 if (close (fd) != 0) 279 if (close (fd) != 0)
280 error_msg_and_die("close failed for `%s': %s\n", device, strerror (errno)); 280 perror_msg_and_die("close failed for `%s'", device);
281 281
282 exit (0); 282 exit (0);
283} 283}
diff --git a/pwd.c b/pwd.c
index 71731944c..da089f37c 100644
--- a/pwd.c
+++ b/pwd.c
@@ -31,8 +31,8 @@ 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 error_msg_and_die("%s\n", strerror(errno)); 34 perror_msg_and_die("getcwd");
35 35
36 printf("%s\n", buf); 36 puts(buf);
37 return EXIT_SUCCESS; 37 return EXIT_SUCCESS;
38} 38}
diff --git a/rdate.c b/rdate.c
index 87edecbfc..03f7f2de3 100644
--- a/rdate.c
+++ b/rdate.c
@@ -47,15 +47,15 @@ time_t askremotedate(char *host)
47 int fd; 47 int fd;
48 48
49 if (!(h = gethostbyname(host))) { /* get the IP addr */ 49 if (!(h = gethostbyname(host))) { /* get the IP addr */
50 error_msg("%s: %s\n", host, strerror(errno)); 50 perror_msg("%s", host);
51 return(-1); 51 return(-1);
52 } 52 }
53 if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */ 53 if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */
54 error_msg("%s: %s\n", "time", strerror(errno)); 54 perror_msg("%s", "time");
55 return(-1); 55 return(-1);
56 } 56 }
57 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */ 57 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */
58 error_msg("%s: %s\n", "socket", strerror(errno)); 58 perror_msg("%s", "socket");
59 return(-1); 59 return(-1);
60 } 60 }
61 61
@@ -64,7 +64,7 @@ time_t askremotedate(char *host)
64 sin.sin_family = AF_INET; 64 sin.sin_family = AF_INET;
65 65
66 if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */ 66 if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */
67 error_msg("%s: %s\n", host, strerror(errno)); 67 perror_msg("%s", host);
68 close(fd); 68 close(fd);
69 return(-1); 69 return(-1);
70 } 70 }
@@ -123,7 +123,7 @@ int rdate_main(int argc, char **argv)
123 } 123 }
124 if (setdate) { 124 if (setdate) {
125 if (stime(&time) < 0) 125 if (stime(&time) < 0)
126 error_msg_and_die("Could not set time of day: %s\n", strerror(errno)); 126 perror_msg_and_die("Could not set time of day");
127 } 127 }
128 if (printdate) { 128 if (printdate) {
129 fprintf(stdout, "%s", ctime(&time)); 129 fprintf(stdout, "%s", ctime(&time));
diff --git a/readlink.c b/readlink.c
index bb40b0787..bb2056a25 100644
--- a/readlink.c
+++ b/readlink.c
@@ -39,7 +39,7 @@ int readlink_main(int argc, char **argv)
39 buf = xrealloc(buf, bufsize); 39 buf = xrealloc(buf, bufsize);
40 size = readlink(argv[1], buf, bufsize); 40 size = readlink(argv[1], buf, bufsize);
41 if (size == -1) 41 if (size == -1)
42 error_msg_and_die("%s: %s\n", argv[1], strerror(errno)); 42 perror_msg_and_die("%s", argv[1]);
43 } 43 }
44 44
45 buf[size] = '\0'; 45 buf[size] = '\0';
diff --git a/sed.c b/sed.c
index 812f62145..a7152e52a 100644
--- a/sed.c
+++ b/sed.c
@@ -757,7 +757,7 @@ extern int sed_main(int argc, char **argv)
757 for (i = optind; i < argc; i++) { 757 for (i = optind; i < argc; i++) {
758 file = fopen(argv[i], "r"); 758 file = fopen(argv[i], "r");
759 if (file == NULL) { 759 if (file == NULL) {
760 error_msg("%s: %s\n", argv[i], strerror(errno)); 760 perror_msg("%s", argv[i]);
761 } else { 761 } else {
762 process_file(file); 762 process_file(file);
763 fclose(file); 763 fclose(file);
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index a599b2113..4217c362f 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -313,7 +313,7 @@ static void doSyslogd (void)
313 /* Create the syslog file so realpath() can work. */ 313 /* Create the syslog file so realpath() can work. */
314 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); 314 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
315 if (realpath (_PATH_LOG, lfile) == NULL) 315 if (realpath (_PATH_LOG, lfile) == NULL)
316 error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno)); 316 perror_msg_and_die ("Could not resolve path to " _PATH_LOG);
317 317
318 unlink (lfile); 318 unlink (lfile);
319 319
@@ -321,14 +321,14 @@ static void doSyslogd (void)
321 sunx.sun_family = AF_UNIX; 321 sunx.sun_family = AF_UNIX;
322 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); 322 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
323 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) 323 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
324 error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno)); 324 perror_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG);
325 325
326 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); 326 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
327 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) 327 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
328 error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno)); 328 perror_msg_and_die ("Could not connect to socket " _PATH_LOG);
329 329
330 if (chmod (lfile, 0666) < 0) 330 if (chmod (lfile, 0666) < 0)
331 error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno)); 331 perror_msg_and_die ("Could not set permission on " _PATH_LOG);
332 332
333 FD_ZERO (&fds); 333 FD_ZERO (&fds);
334 FD_SET (sock_fd, &fds); 334 FD_SET (sock_fd, &fds);
@@ -351,7 +351,7 @@ static void doSyslogd (void)
351 351
352 if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { 352 if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) {
353 if (errno == EINTR) continue; /* alarm may have happened. */ 353 if (errno == EINTR) continue; /* alarm may have happened. */
354 error_msg_and_die ("select error: %s\n", strerror (errno)); 354 perror_msg_and_die ("select error");
355 } 355 }
356 356
357 for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { 357 for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
@@ -365,7 +365,7 @@ static void doSyslogd (void)
365 pid_t pid; 365 pid_t pid;
366 366
367 if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { 367 if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
368 error_msg_and_die ("accept error: %s\n", strerror (errno)); 368 perror_msg_and_die ("accept error");
369 } 369 }
370 370
371 pid = fork(); 371 pid = fork();
diff --git a/syslogd.c b/syslogd.c
index a599b2113..4217c362f 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -313,7 +313,7 @@ static void doSyslogd (void)
313 /* Create the syslog file so realpath() can work. */ 313 /* Create the syslog file so realpath() can work. */
314 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); 314 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
315 if (realpath (_PATH_LOG, lfile) == NULL) 315 if (realpath (_PATH_LOG, lfile) == NULL)
316 error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno)); 316 perror_msg_and_die ("Could not resolve path to " _PATH_LOG);
317 317
318 unlink (lfile); 318 unlink (lfile);
319 319
@@ -321,14 +321,14 @@ static void doSyslogd (void)
321 sunx.sun_family = AF_UNIX; 321 sunx.sun_family = AF_UNIX;
322 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); 322 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
323 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) 323 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
324 error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno)); 324 perror_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG);
325 325
326 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); 326 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
327 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) 327 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
328 error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno)); 328 perror_msg_and_die ("Could not connect to socket " _PATH_LOG);
329 329
330 if (chmod (lfile, 0666) < 0) 330 if (chmod (lfile, 0666) < 0)
331 error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno)); 331 perror_msg_and_die ("Could not set permission on " _PATH_LOG);
332 332
333 FD_ZERO (&fds); 333 FD_ZERO (&fds);
334 FD_SET (sock_fd, &fds); 334 FD_SET (sock_fd, &fds);
@@ -351,7 +351,7 @@ static void doSyslogd (void)
351 351
352 if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { 352 if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) {
353 if (errno == EINTR) continue; /* alarm may have happened. */ 353 if (errno == EINTR) continue; /* alarm may have happened. */
354 error_msg_and_die ("select error: %s\n", strerror (errno)); 354 perror_msg_and_die ("select error");
355 } 355 }
356 356
357 for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { 357 for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
@@ -365,7 +365,7 @@ static void doSyslogd (void)
365 pid_t pid; 365 pid_t pid;
366 366
367 if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { 367 if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
368 error_msg_and_die ("accept error: %s\n", strerror (errno)); 368 perror_msg_and_die ("accept error");
369 } 369 }
370 370
371 pid = fork(); 371 pid = fork();
diff --git a/tar.c b/tar.c
index e1beee117..c6a2a6627 100644
--- a/tar.c
+++ b/tar.c
@@ -317,7 +317,7 @@ extern int tar_main(int argc, char **argv)
317 else 317 else
318 tarFd = open(tarName, O_RDONLY); 318 tarFd = open(tarName, O_RDONLY);
319 if (tarFd < 0) 319 if (tarFd < 0)
320 error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno)); 320 perror_msg_and_die("Error opening '%s'", tarName);
321 321
322#ifdef BB_FEATURE_TAR_GZIP 322#ifdef BB_FEATURE_TAR_GZIP
323 /* unzip tarFd in a seperate process */ 323 /* unzip tarFd in a seperate process */
@@ -425,8 +425,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
425 return( TRUE); 425 return( TRUE);
426 426
427 if (create_path(header->name, header->mode) != TRUE) { 427 if (create_path(header->name, header->mode) != TRUE) {
428 error_msg("%s: Cannot mkdir: %s\n", 428 perror_msg("%s: Cannot mkdir", header->name);
429 header->name, strerror(errno));
430 return( FALSE); 429 return( FALSE);
431 } 430 }
432 /* make the final component, just in case it was 431 /* make the final component, just in case it was
@@ -445,8 +444,8 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
445 return( TRUE); 444 return( TRUE);
446 445
447 if (link(header->linkname, header->name) < 0) { 446 if (link(header->linkname, header->name) < 0) {
448 error_msg("%s: Cannot create hard link to '%s': %s\n", 447 perror_msg("%s: Cannot create hard link to '%s'", header->name,
449 header->name, header->linkname, strerror(errno)); 448 header->linkname);
450 return( FALSE); 449 return( FALSE);
451 } 450 }
452 451
@@ -463,8 +462,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
463 462
464#ifdef S_ISLNK 463#ifdef S_ISLNK
465 if (symlink(header->linkname, header->name) < 0) { 464 if (symlink(header->linkname, header->name) < 0) {
466 error_msg("%s: Cannot create symlink to '%s': %s\n", 465 perror_msg("%s: Cannot create symlink to '%s'", header->name,
467 header->name, header->linkname, strerror(errno)); 466 header->linkname);
468 return( FALSE); 467 return( FALSE);
469 } 468 }
470 /* Try to change ownership of the symlink. 469 /* Try to change ownership of the symlink.
@@ -493,14 +492,12 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
493 492
494 if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) { 493 if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
495 if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) { 494 if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
496 error_msg("%s: Cannot mknod: %s\n", 495 perror_msg("%s: Cannot mknod", header->name);
497 header->name, strerror(errno));
498 return( FALSE); 496 return( FALSE);
499 } 497 }
500 } else if (S_ISFIFO(header->mode)) { 498 } else if (S_ISFIFO(header->mode)) {
501 if (mkfifo(header->name, header->mode) < 0) { 499 if (mkfifo(header->name, header->mode) < 0) {
502 error_msg("%s: Cannot mkfifo: %s\n", 500 perror_msg("%s: Cannot mkfifo", header->name);
503 header->name, strerror(errno));
504 return( FALSE); 501 return( FALSE);
505 } 502 }
506 } 503 }
@@ -790,7 +787,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
790 close(tarFd); 787 close(tarFd);
791 if (status > 0) { 788 if (status > 0) {
792 /* Bummer - we read a partial header */ 789 /* Bummer - we read a partial header */
793 error_msg( "Error reading tar file: %s\n", strerror(errno)); 790 perror_msg("Error reading tar file");
794 return ( FALSE); 791 return ( FALSE);
795 } 792 }
796 else if (errorFlag==TRUE) { 793 else if (errorFlag==TRUE) {
@@ -1007,7 +1004,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
1007 header.typeflag = SYMTYPE; 1004 header.typeflag = SYMTYPE;
1008 link_size = readlink(fileName, buffer, sizeof(buffer) - 1); 1005 link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
1009 if ( link_size < 0) { 1006 if ( link_size < 0) {
1010 error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); 1007 perror_msg("Error reading symlink '%s'", header.name);
1011 return ( FALSE); 1008 return ( FALSE);
1012 } 1009 }
1013 buffer[link_size] = '\0'; 1010 buffer[link_size] = '\0';
@@ -1165,7 +1162,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
1165 else 1162 else
1166 tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); 1163 tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
1167 if (tbInfo.tarFd < 0) { 1164 if (tbInfo.tarFd < 0) {
1168 error_msg( "Error opening '%s': %s\n", tarName, strerror(errno)); 1165 perror_msg( "Error opening '%s'", tarName);
1169 freeHardLinkInfo(&tbInfo.hlInfoHead); 1166 freeHardLinkInfo(&tbInfo.hlInfoHead);
1170 return ( FALSE); 1167 return ( FALSE);
1171 } 1168 }
diff --git a/tee.c b/tee.c
index 347684a28..f0eca070d 100644
--- a/tee.c
+++ b/tee.c
@@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
47 while (optind < argc) { 47 while (optind < argc) {
48 if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) { 48 if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
49 nfiles--; 49 nfiles--;
50 error_msg("%s: %s\n", argv[optind-1], strerror(errno)); 50 perror_msg("%s", argv[optind-1]);
51 status = 1; 51 status = 1;
52 } 52 }
53 } 53 }
diff --git a/telnet.c b/telnet.c
index 7a7bcfb9f..fff8c06b5 100644
--- a/telnet.c
+++ b/telnet.c
@@ -650,7 +650,7 @@ static int remote_connect(struct in_addr addr, int port)
650 650
651 if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0) 651 if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0)
652 { 652 {
653 error_msg_and_die("Unable to connect to remote host: %s\n", strerror(errno)); 653 perror_msg_and_die("Unable to connect to remote host");
654 } 654 }
655 return s; 655 return s;
656} 656}
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index a568cc67c..a2b17c673 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -43,10 +43,10 @@ freeramdisk_main(int argc, char **argv)
43 } 43 }
44 44
45 if ((f = open(argv[1], O_RDWR)) == -1) { 45 if ((f = open(argv[1], O_RDWR)) == -1) {
46 error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno)); 46 perror_msg_and_die("cannot open %s", argv[1]);
47 } 47 }
48 if (ioctl(f, BLKFLSBUF) < 0) { 48 if (ioctl(f, BLKFLSBUF) < 0) {
49 error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); 49 perror_msg_and_die("failed ioctl on %s", argv[1]);
50 } 50 }
51 /* Don't bother closing. Exit does 51 /* Don't bother closing. Exit does
52 * that, so we can save a few bytes */ 52 * that, so we can save a few bytes */
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 06673f942..8240b99aa 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -271,18 +271,18 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
271 /* open device */ 271 /* open device */
272 fd = open(device, O_RDONLY); 272 fd = open(device, O_RDONLY);
273 if (fd < 0) 273 if (fd < 0)
274 error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); 274 perror_msg_and_die("open failed for `%s'", device);
275 275
276 /* How many filesystems? We need to know to allocate enough space */ 276 /* How many filesystems? We need to know to allocate enough space */
277 numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS); 277 numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS);
278 if (numfilesystems<0) 278 if (numfilesystems<0)
279 error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno)); 279 perror_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS");
280 fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype)); 280 fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype));
281 281
282 /* Grab the list of available filesystems */ 282 /* Grab the list of available filesystems */
283 status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist); 283 status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist);
284 if (status<0) 284 if (status<0)
285 error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno)); 285 perror_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS");
286 286
287 /* Walk the list trying to mount filesystems 287 /* Walk the list trying to mount filesystems
288 * that do not claim to be nodev filesystems */ 288 * that do not claim to be nodev filesystems */
@@ -307,8 +307,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
307 307
308 if (status == FALSE) { 308 if (status == FALSE) {
309 if (whineOnErrors == TRUE) { 309 if (whineOnErrors == TRUE) {
310 error_msg("Mounting %s on %s failed: %s\n", 310 perror_msg("Mounting %s on %s failed", blockDevice, directory);
311 blockDevice, directory, strerror(errno));
312 } 311 }
313 return (FALSE); 312 return (FALSE);
314 } 313 }
@@ -340,18 +339,18 @@ extern int mount_main(int argc, char **argv)
340 /* open device */ 339 /* open device */
341 fd = open(device, O_RDONLY); 340 fd = open(device, O_RDONLY);
342 if (fd < 0) 341 if (fd < 0)
343 error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); 342 perror_msg_and_die("open failed for `%s'", device);
344 343
345 /* How many mounted filesystems? We need to know to 344 /* How many mounted filesystems? We need to know to
346 * allocate enough space for later... */ 345 * allocate enough space for later... */
347 numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS); 346 numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
348 if (numfilesystems<0) 347 if (numfilesystems<0)
349 error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno)); 348 perror_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS");
350 mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent)); 349 mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent));
351 350
352 /* Grab the list of mounted filesystems */ 351 /* Grab the list of mounted filesystems */
353 if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0) 352 if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0)
354 error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno)); 353 perror_msg_and_die( "\nDEVMTAB_GET_MOUNTS");
355 354
356 for( i = 0 ; i < numfilesystems ; i++) { 355 for( i = 0 ; i < numfilesystems ; i++) {
357 fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname, 356 fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
@@ -453,7 +452,7 @@ extern int mount_main(int argc, char **argv)
453 fstabmount = TRUE; 452 fstabmount = TRUE;
454 453
455 if (f == NULL) 454 if (f == NULL)
456 error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno)); 455 perror_msg_and_die( "\nCannot read /etc/fstab");
457 456
458 while ((m = getmntent(f)) != NULL) { 457 while ((m = getmntent(f)) != NULL) {
459 if (all == FALSE && directory == NULL && ( 458 if (all == FALSE && directory == NULL && (
@@ -487,7 +486,7 @@ singlemount:
487 rc = nfsmount (device, directory, &flags, 486 rc = nfsmount (device, directory, &flags,
488 &extra_opts, &string_flags, 1); 487 &extra_opts, &string_flags, 1);
489 if ( rc != 0) { 488 if ( rc != 0) {
490 error_msg_and_die("nfsmount failed: %s\n", strerror(errno)); 489 perror_msg_and_die("nfsmount failed");
491 rc = EXIT_FAILURE; 490 rc = EXIT_FAILURE;
492 } 491 }
493 } 492 }
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index 87edecbfc..03f7f2de3 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -47,15 +47,15 @@ time_t askremotedate(char *host)
47 int fd; 47 int fd;
48 48
49 if (!(h = gethostbyname(host))) { /* get the IP addr */ 49 if (!(h = gethostbyname(host))) { /* get the IP addr */
50 error_msg("%s: %s\n", host, strerror(errno)); 50 perror_msg("%s", host);
51 return(-1); 51 return(-1);
52 } 52 }
53 if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */ 53 if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */
54 error_msg("%s: %s\n", "time", strerror(errno)); 54 perror_msg("%s", "time");
55 return(-1); 55 return(-1);
56 } 56 }
57 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */ 57 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */
58 error_msg("%s: %s\n", "socket", strerror(errno)); 58 perror_msg("%s", "socket");
59 return(-1); 59 return(-1);
60 } 60 }
61 61
@@ -64,7 +64,7 @@ time_t askremotedate(char *host)
64 sin.sin_family = AF_INET; 64 sin.sin_family = AF_INET;
65 65
66 if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */ 66 if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */
67 error_msg("%s: %s\n", host, strerror(errno)); 67 perror_msg("%s", host);
68 close(fd); 68 close(fd);
69 return(-1); 69 return(-1);
70 } 70 }
@@ -123,7 +123,7 @@ int rdate_main(int argc, char **argv)
123 } 123 }
124 if (setdate) { 124 if (setdate) {
125 if (stime(&time) < 0) 125 if (stime(&time) < 0)
126 error_msg_and_die("Could not set time of day: %s\n", strerror(errno)); 126 perror_msg_and_die("Could not set time of day");
127 } 127 }
128 if (printdate) { 128 if (printdate) {
129 fprintf(stdout, "%s", ctime(&time)); 129 fprintf(stdout, "%s", ctime(&time));
diff --git a/utility.c b/utility.c
index 9b805ae7d..794a9281a 100644
--- a/utility.c
+++ b/utility.c
@@ -1313,11 +1313,11 @@ extern pid_t* find_pid_by_name( char* pidName)
1313 /* open device */ 1313 /* open device */
1314 fd = open(device, O_RDONLY); 1314 fd = open(device, O_RDONLY);
1315 if (fd < 0) 1315 if (fd < 0)
1316 error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); 1316 perror_msg_and_die( "open failed for `%s'", device);
1317 1317
1318 /* Find out how many processes there are */ 1318 /* Find out how many processes there are */
1319 if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) 1319 if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
1320 error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); 1320 perror_msg_and_die( "\nDEVPS_GET_PID_LIST");
1321 1321
1322 /* Allocate some memory -- grab a few extras just in case 1322 /* Allocate some memory -- grab a few extras just in case
1323 * some new processes start up while we wait. The kernel will 1323 * some new processes start up while we wait. The kernel will
@@ -1328,7 +1328,7 @@ extern pid_t* find_pid_by_name( char* pidName)
1328 1328
1329 /* Now grab the pid list */ 1329 /* Now grab the pid list */
1330 if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) 1330 if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
1331 error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); 1331 perror_msg_and_die( "\nDEVPS_GET_PID_LIST");
1332 1332
1333 /* Now search for a match */ 1333 /* Now search for a match */
1334 for (i=1, j=0; i<pid_array[0] ; i++) { 1334 for (i=1, j=0; i<pid_array[0] ; i++) {
@@ -1337,7 +1337,7 @@ extern pid_t* find_pid_by_name( char* pidName)
1337 1337
1338 info.pid = pid_array[i]; 1338 info.pid = pid_array[i];
1339 if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) 1339 if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
1340 error_msg_and_die( "\nDEVPS_GET_PID_INFO: %s\n", strerror (errno)); 1340 perror_msg_and_die( "\nDEVPS_GET_PID_INFO");
1341 1341
1342 /* Make sure we only match on the process name */ 1342 /* Make sure we only match on the process name */
1343 p=info.command_line+1; 1343 p=info.command_line+1;
@@ -1361,7 +1361,7 @@ extern pid_t* find_pid_by_name( char* pidName)
1361 1361
1362 /* close device */ 1362 /* close device */
1363 if (close (fd) != 0) 1363 if (close (fd) != 0)
1364 error_msg_and_die( "close failed for `%s': %s\n",device, strerror (errno)); 1364 perror_msg_and_die( "close failed for `%s'", device);
1365 1365
1366 return pidList; 1366 return pidList;
1367} 1367}
@@ -1387,7 +1387,7 @@ extern pid_t* find_pid_by_name( char* pidName)
1387 1387
1388 dir = opendir("/proc"); 1388 dir = opendir("/proc");
1389 if (!dir) 1389 if (!dir)
1390 error_msg_and_die( "Cannot open /proc: %s\n", strerror (errno)); 1390 perror_msg_and_die( "Cannot open /proc");
1391 1391
1392 while ((next = readdir(dir)) != NULL) { 1392 while ((next = readdir(dir)) != NULL) {
1393 FILE *status; 1393 FILE *status;
@@ -1764,7 +1764,7 @@ FILE *wfopen(const char *path, const char *mode)
1764{ 1764{
1765 FILE *fp; 1765 FILE *fp;
1766 if ((fp = fopen(path, mode)) == NULL) { 1766 if ((fp = fopen(path, mode)) == NULL) {
1767 error_msg("%s: %s\n", path, strerror(errno)); 1767 perror_msg("%s", path);
1768 errno = 0; 1768 errno = 0;
1769 } 1769 }
1770 return fp; 1770 return fp;
@@ -1778,7 +1778,7 @@ FILE *xfopen(const char *path, const char *mode)
1778{ 1778{
1779 FILE *fp; 1779 FILE *fp;
1780 if ((fp = fopen(path, mode)) == NULL) 1780 if ((fp = fopen(path, mode)) == NULL)
1781 error_msg_and_die("%s: %s\n", path, strerror(errno)); 1781 perror_msg_and_die("%s", path);
1782 return fp; 1782 return fp;
1783} 1783}
1784#endif 1784#endif
diff --git a/uudecode.c b/uudecode.c
index ff4a9d9e6..279b9d6ce 100644
--- a/uudecode.c
+++ b/uudecode.c
@@ -257,7 +257,7 @@ static int decode (const char *inname,
257 && (freopen (outname, "w", stdout) == NULL 257 && (freopen (outname, "w", stdout) == NULL
258 || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) 258 || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
259 )) { 259 )) {
260 error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */ 260 perror_msg("%s", outname); /* */
261 return FALSE; 261 return FALSE;
262 } 262 }
263 263
@@ -302,7 +302,7 @@ int uudecode_main (int argc,
302 if (decode (argv[optind], outname) != 0) 302 if (decode (argv[optind], outname) != 0)
303 exit_status = FALSE; 303 exit_status = FALSE;
304 } else { 304 } else {
305 error_msg("%s: %s\n", argv[optind], strerror(errno)); 305 perror_msg("%s", argv[optind]);
306 exit_status = EXIT_FAILURE; 306 exit_status = EXIT_FAILURE;
307 } 307 }
308 optind++; 308 optind++;
diff --git a/uuencode.c b/uuencode.c
index 41e659075..36bc4970f 100644
--- a/uuencode.c
+++ b/uuencode.c
@@ -160,15 +160,12 @@ int uuencode_main (int argc,
160 trans_ptr = uu_std; /* Standard encoding is old uu format */ 160 trans_ptr = uu_std; /* Standard encoding is old uu format */
161 161
162 /* Parse any options */ 162 /* Parse any options */
163 while ((opt = getopt (argc, argv, "m")) != EOF) { 163 while ((opt = getopt (argc, argv, "m")) > 0) {
164 switch (opt) { 164 switch (opt) {
165 case 'm': 165 case 'm':
166 trans_ptr = uu_base64; 166 trans_ptr = uu_base64;
167 break; 167 break;
168 168
169 case 0:
170 break;
171
172 default: 169 default:
173 usage(uuencode_usage); 170 usage(uuencode_usage);
174 } 171 }
@@ -178,7 +175,7 @@ int uuencode_main (int argc,
178 case 2: 175 case 2:
179 /* Optional first argument is input file. */ 176 /* Optional first argument is input file. */
180 if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { 177 if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
181 error_msg("%s: %s\n", argv[optind], strerror(errno)); 178 perror_msg("%s", argv[optind]);
182 return EXIT_FAILURE; 179 return EXIT_FAILURE;
183 } 180 }
184 mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); 181 mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);