From: Matt Kraai Date: Mon, 18 Dec 2000 03:57:16 +0000 (-0000) Subject: Change calls to error_msg.* and strerror to use perror_msg.*. X-Git-Tag: 0_49~120 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1fa1adea2ae16d4f4c82d7466905dce4c6edd5f5;p=oweals%2Fbusybox.git Change calls to error_msg.* and strerror to use perror_msg.*. --- 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() if (len != -1) { path[len] = 0; } else { - error_msg("%s: %s\n", proc, strerror(errno)); + perror_msg("%s", proc); return NULL; } return strdup(path); @@ -78,7 +78,7 @@ static void install_links(const char *busybox, int use_symbolic_links) rc = Link(busybox, command); if (rc) { - error_msg("%s: %s\n", command, strerror(errno)); + perror_msg("%s", command); } } } 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) else tarFd = open(tarName, O_RDONLY); if (tarFd < 0) - error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno)); + perror_msg_and_die("Error opening '%s'", tarName); #ifdef BB_FEATURE_TAR_GZIP /* unzip tarFd in a seperate process */ @@ -425,8 +425,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) return( TRUE); if (create_path(header->name, header->mode) != TRUE) { - error_msg("%s: Cannot mkdir: %s\n", - header->name, strerror(errno)); + perror_msg("%s: Cannot mkdir", header->name); return( FALSE); } /* make the final component, just in case it was @@ -445,8 +444,8 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag) return( TRUE); if (link(header->linkname, header->name) < 0) { - error_msg("%s: Cannot create hard link to '%s': %s\n", - header->name, header->linkname, strerror(errno)); + perror_msg("%s: Cannot create hard link to '%s'", header->name, + header->linkname); return( FALSE); } @@ -463,8 +462,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag) #ifdef S_ISLNK if (symlink(header->linkname, header->name) < 0) { - error_msg("%s: Cannot create symlink to '%s': %s\n", - header->name, header->linkname, strerror(errno)); + perror_msg("%s: Cannot create symlink to '%s'", header->name, + header->linkname); return( FALSE); } /* Try to change ownership of the symlink. @@ -493,14 +492,12 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag) if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) { if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) { - error_msg("%s: Cannot mknod: %s\n", - header->name, strerror(errno)); + perror_msg("%s: Cannot mknod", header->name); return( FALSE); } } else if (S_ISFIFO(header->mode)) { if (mkfifo(header->name, header->mode) < 0) { - error_msg("%s: Cannot mkfifo: %s\n", - header->name, strerror(errno)); + perror_msg("%s: Cannot mkfifo", header->name); return( FALSE); } } @@ -790,7 +787,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag, close(tarFd); if (status > 0) { /* Bummer - we read a partial header */ - error_msg( "Error reading tar file: %s\n", strerror(errno)); + perror_msg("Error reading tar file"); return ( FALSE); } else if (errorFlag==TRUE) { @@ -1007,7 +1004,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st header.typeflag = SYMTYPE; link_size = readlink(fileName, buffer, sizeof(buffer) - 1); if ( link_size < 0) { - error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); + perror_msg("Error reading symlink '%s'", header.name); return ( FALSE); } buffer[link_size] = '\0'; @@ -1165,7 +1162,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv, else tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (tbInfo.tarFd < 0) { - error_msg( "Error opening '%s': %s\n", tarName, strerror(errno)); + perror_msg( "Error opening '%s'", tarName); freeHardLinkInfo(&tbInfo.hlInfoHead); return ( FALSE); } 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() if (len != -1) { path[len] = 0; } else { - error_msg("%s: %s\n", proc, strerror(errno)); + perror_msg("%s", proc); return NULL; } return strdup(path); @@ -78,7 +78,7 @@ static void install_links(const char *busybox, int use_symbolic_links) rc = Link(busybox, command); if (rc) { - error_msg("%s: %s\n", command, strerror(errno)); + perror_msg("%s", command); } } } 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) argv++; if (chroot(*argv) || (chdir("/"))) { - error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno)); + perror_msg_and_die("cannot change root directory to %s", *argv); } argc--; @@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv) return EXIT_SUCCESS; #endif } - error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno)); + perror_msg_and_die("cannot execute %s", prog); } 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) fd = open("/dev/tty0", O_RDWR); if (fd < 0) { - error_msg("Error opening /dev/tty0: %s\n", strerror(errno)); + perror_msg("Error opening /dev/tty0"); return EXIT_FAILURE; } 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) fd = open("/dev/tty", O_RDWR); if (fd < 0) { - error_msg("Error opening /dev/tty1: %s\n", strerror(errno)); - return EXIT_FAILURE; + perror_msg_and_die("Error opening /dev/tty1"); } if (screen_map_load(fd, stdin)) { - error_msg("Error loading acm: %s\n", strerror(errno)); - return EXIT_FAILURE; + perror_msg_and_die("Error loading acm"); } write(fd, "\033(K", 3); 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) argv++; if (chroot(*argv) || (chdir("/"))) { - error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno)); + perror_msg_and_die("cannot change root directory to %s", *argv); } argc--; @@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv) return EXIT_SUCCESS; #endif } - error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno)); + perror_msg_and_die("cannot execute %s", prog); } 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) for (i = optind; i < argc; i++) { file = fopen(argv[i], "r"); if (file == NULL) { - error_msg("%s: %s\n", argv[i], strerror(errno)); + perror_msg("%s", argv[i]); } else { cut_file(file); fclose(file); 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) } head(len, fp); if (errno) { - error_msg("%s: %s\n", argv[optind], strerror(errno)); + perror_msg("%s", argv[optind]); status = EXIT_FAILURE; errno = 0; } 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) #ifdef BB_FEATURE_LS_FOLLOWLINKS if (follow_links == TRUE) { if (stat(cur->fullname, &cur->dstat)) { - error_msg("%s: %s\n", cur->fullname, strerror(errno)); + perror_msg("%s", cur->fullname); status = EXIT_FAILURE; free(cur->fullname); free(cur); @@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur) } else #endif if (lstat(cur->fullname, &cur->dstat)) { - error_msg("%s: %s\n", cur->fullname, strerror(errno)); + perror_msg("%s", cur->fullname); status = EXIT_FAILURE; free(cur->fullname); free(cur); @@ -511,7 +511,7 @@ struct dnode **list_dir(char *path) nfiles= 0; dir = opendir(path); if (dir == NULL) { - error_msg("%s: %s\n", path, strerror(errno)); + perror_msg("%s", path); status = EXIT_FAILURE; return(NULL); /* could not open the dir */ } 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, } else { fp = fopen(filename, OPENOPTS(binary)); if (fp == NULL) { - error_msg("%s: %s\n", filename, strerror(errno)); + perror_msg("%s", filename); return FALSE; } } if (md5_stream(fp, md5_result)) { - error_msg("%s: %s\n", filename, strerror(errno)); + perror_msg("%s", filename); if (fp != stdin) fclose(fp); @@ -665,7 +665,7 @@ static int md5_file(const char *filename, } if (fp != stdin && fclose(fp) == EOF) { - error_msg("%s: %s\n", filename, strerror(errno)); + perror_msg("%s", filename); return FALSE; } @@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name) } else { checkfile_stream = fopen(checkfile_name, "r"); if (checkfile_stream == NULL) { - error_msg("%s: %s\n", checkfile_name, strerror(errno)); + perror_msg("%s", checkfile_name); return FALSE; } } @@ -775,7 +775,7 @@ static int md5_check(const char *checkfile_name) } if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) { - error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); + perror_msg("md5sum: %s", checkfile_name); return FALSE; } 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) char buf[BUFSIZ + 1]; if (getcwd(buf, sizeof(buf)) == NULL) - error_msg_and_die("%s\n", strerror(errno)); + perror_msg_and_die("getcwd"); - printf("%s\n", buf); + puts(buf); return EXIT_SUCCESS; } 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) while (optind < argc) { if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) { nfiles--; - error_msg("%s: %s\n", argv[optind-1], strerror(errno)); + perror_msg("%s", argv[optind-1]); status = 1; } } 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, && (freopen (outname, "w", stdout) == NULL || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) )) { - error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */ + perror_msg("%s", outname); /* */ return FALSE; } @@ -302,7 +302,7 @@ int uudecode_main (int argc, if (decode (argv[optind], outname) != 0) exit_status = FALSE; } else { - error_msg("%s: %s\n", argv[optind], strerror(errno)); + perror_msg("%s", argv[optind]); exit_status = EXIT_FAILURE; } optind++; 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, trans_ptr = uu_std; /* Standard encoding is old uu format */ /* Parse any options */ - while ((opt = getopt (argc, argv, "m")) != EOF) { + while ((opt = getopt (argc, argv, "m")) > 0) { switch (opt) { case 'm': trans_ptr = uu_base64; break; - case 0: - break; - default: usage(uuencode_usage); } @@ -178,7 +175,7 @@ int uuencode_main (int argc, case 2: /* Optional first argument is input file. */ if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { - error_msg("%s: %s\n", argv[optind], strerror(errno)); + perror_msg("%s", argv[optind]); return EXIT_FAILURE; } mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); 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) if (mv_Action_first_time && (dz_i == is_mv)) { mv_Action_first_time = errno = 0; if (rename(fileName, destName) < 0 && errno != EXDEV) { - error_msg("rename(%s, %s): %s\n", fileName, destName, - strerror(errno)); + perror_msg("rename(%s, %s)", fileName, destName); goto do_copyFile; /* Try anyway... */ } else if (errno == EXDEV) @@ -143,7 +142,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) if (preserveFlag == TRUE && statbuf->st_nlink > 1) { if (is_in_ino_dev_hashtable(statbuf, &name)) { if (link(name, destName) < 0) { - error_msg("link(%s, %s): %s\n", name, destName, strerror(errno)); + perror_msg("link(%s, %s)", name, destName); return FALSE; } return TRUE; @@ -162,11 +161,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk) if (S_ISDIR(statbuf->st_mode)) { if (rmdir(fileName) < 0) { - error_msg("rmdir(%s): %s\n", fileName, strerror(errno)); + perror_msg("rmdir(%s)", fileName); status = FALSE; } } else if (unlink(fileName) < 0) { - error_msg("unlink(%s): %s\n", fileName, strerror(errno)); + perror_msg("unlink(%s)", fileName); status = FALSE; } return status; @@ -260,20 +259,20 @@ extern int cp_mv_main(int argc, char **argv) char *pushd, *d, *p; if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { - error_msg("getcwd(): %s\n", strerror(errno)); + perror_msg("getcwd()"); continue; } if (chdir(baseDestName) < 0) { - error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno)); + perror_msg("chdir(%s)", baseSrcName); continue; } if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { - error_msg("getcwd(): %s\n", strerror(errno)); + perror_msg("getcwd()"); continue; } while (!state && *d != '\0') { if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ - error_msg("stat(%s): %s\n", d, strerror(errno)); + perror_msg("stat(%s)", d); state = -1; continue; } @@ -290,7 +289,7 @@ extern int cp_mv_main(int argc, char **argv) } } if (chdir(pushd) < 0) { - error_msg("chdir(%s): %s\n", pushd, strerror(errno)); + perror_msg("chdir(%s)", pushd); free(pushd); free(d); continue; 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) for (i = optind; i < argc; i++) { file = fopen(argv[i], "r"); if (file == NULL) { - error_msg("%s: %s\n", argv[i], strerror(errno)); + perror_msg("%s", argv[i]); } else { cut_file(file); fclose(file); 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) fd = open("/dev/tty0", O_RDWR); if (fd < 0) { - error_msg("Error opening /dev/tty0: %s\n", strerror(errno)); + perror_msg("Error opening /dev/tty0"); return EXIT_FAILURE; } 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) for (i = optind; i < argc; i++) { file = fopen(argv[i], "r"); if (file == NULL) { - error_msg("%s: %s\n", argv[i], strerror(errno)); + perror_msg("%s", argv[i]); } else { process_file(file); 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) file = fopen(cur_file, "r"); if (file == NULL) { if (!suppress_err_msgs) - error_msg("%s: %s\n", cur_file, strerror(errno)); + perror_msg("%s", cur_file); } else { 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) } if ((f = open(argv[1], O_RDWR)) == -1) { - error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno)); + perror_msg_and_die("cannot open %s", argv[1]); } if (ioctl(f, BLKFLSBUF) < 0) { - error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); + perror_msg_and_die("failed ioctl on %s", argv[1]); } /* Don't bother closing. Exit does * 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) file = fopen(cur_file, "r"); if (file == NULL) { if (!suppress_err_msgs) - error_msg("%s: %s\n", cur_file, strerror(errno)); + perror_msg("%s", cur_file); } else { 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) } head(len, fp); if (errno) { - error_msg("%s: %s\n", argv[optind], strerror(errno)); + perror_msg("%s", argv[optind]); status = EXIT_FAILURE; errno = 0; } diff --git a/insmod.c b/insmod.c index f2f1e8028..cbe00c2b4 100644 --- a/insmod.c +++ b/insmod.c @@ -78,7 +78,7 @@ #ifndef MODUTILS_MODULE_H #define MODUTILS_MODULE_H 1 -#ident "$Id: insmod.c,v 1.32 2000/12/13 16:41:29 andersen Exp $" +#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $" /* This file contains the structures used by the 2.0 and 2.1 kernels. We do not use the kernel headers directly because we do not wish @@ -284,7 +284,7 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H #define MODUTILS_OBJ_H 1 -#ident "$Id: insmod.c,v 1.32 2000/12/13 16:41:29 andersen Exp $" +#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $" /* The relocatable object is manipulated using elfin types. */ @@ -1562,7 +1562,7 @@ static int old_get_kernel_symbols(const char *m_name) nks = get_kernel_syms(NULL); if (nks < 0) { - error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); + perror_msg("get_kernel_syms: %s", m_name); return 0; } @@ -1743,7 +1743,7 @@ old_init_module(const char *m_name, struct obj_file *f, m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN : 0), &routines, symtab); if (ret) - error_msg("init_module: %s: %s\n", m_name, strerror(errno)); + perror_msg("init_module: %s", m_name); free(image); free(symtab); @@ -2055,7 +2055,7 @@ static int new_get_kernel_symbols(void) module_names = xrealloc(module_names, bufsize = ret); goto retry_modules_load; } - error_msg("QM_MODULES: %s\n", strerror(errno)); + perror_msg("QM_MODULES"); return 0; } @@ -2074,7 +2074,7 @@ static int new_get_kernel_symbols(void) /* The module was removed out from underneath us. */ continue; } - error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); + perror_msg("query_module: QM_INFO: %s", mn); return 0; } @@ -2089,7 +2089,7 @@ static int new_get_kernel_symbols(void) /* The module was removed out from underneath us. */ continue; default: - error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); + perror_msg("query_module: QM_SYMBOLS: %s", mn); return 0; } } @@ -2114,7 +2114,7 @@ static int new_get_kernel_symbols(void) syms = xrealloc(syms, bufsize = ret); goto retry_kern_sym_load; } - error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); + perror_msg("kernel: QM_SYMBOLS"); return 0; } nksyms = nsyms = ret; @@ -2295,7 +2295,7 @@ new_init_module(const char *m_name, struct obj_file *f, ret = new_sys_init_module(m_name, (struct new_module *) image); if (ret) - error_msg("init_module: %s: %s\n", m_name, strerror(errno)); + perror_msg("init_module: %s", m_name); free(image); @@ -2680,7 +2680,7 @@ struct obj_file *obj_load(FILE * fp) fseek(fp, 0, SEEK_SET); if (fread(&f->header, sizeof(f->header), 1, fp) != 1) { - error_msg("error reading ELF header: %s\n", strerror(errno)); + perror_msg("error reading ELF header"); return NULL; } @@ -2719,7 +2719,7 @@ struct obj_file *obj_load(FILE * fp) section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); fseek(fp, f->header.e_shoff, SEEK_SET); if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) { - error_msg("error reading ELF section headers: %s\n", strerror(errno)); + perror_msg("error reading ELF section headers"); return NULL; } @@ -2749,7 +2749,7 @@ struct obj_file *obj_load(FILE * fp) sec->contents = xmalloc(sec->header.sh_size); fseek(fp, sec->header.sh_offset, SEEK_SET); if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { - error_msg("error reading ELF section data: %s\n", strerror(errno)); + perror_msg("error reading ELF section data"); return NULL; } } else { @@ -3075,7 +3075,7 @@ extern int insmod_main( int argc, char **argv) m_size); goto out; default: - error_msg("create_module: %s: %s\n", m_name, strerror(errno)); + perror_msg("create_module: %s", m_name); goto out; } 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) int pid; if (!isdigit(**argv)) - error_msg_and_die( "Bad PID: %s\n", strerror(errno)); + perror_msg_and_die( "Bad PID"); pid = strtol(*argv, NULL, 0); if (kill(pid, sig) != 0) - error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno)); + perror_msg_and_die( "Could not kill pid '%d'", pid); argv++; } } @@ -229,7 +229,7 @@ extern int kill_main(int argc, char **argv) if (*pidList==myPid) continue; if (kill(*pidList, sig) != 0) - error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno)); + perror_msg_and_die( "Could not kill pid '%d'", *pidList); } /* Note that we don't bother to free the memory * 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) fd = open("/dev/tty", O_RDWR); if (fd < 0) { - error_msg("Error opening /dev/tty1: %s\n", strerror(errno)); - return EXIT_FAILURE; + perror_msg_and_die("Error opening /dev/tty1"); } if (screen_map_load(fd, stdin)) { - error_msg("Error loading acm: %s\n", strerror(errno)); - return EXIT_FAILURE; + perror_msg_and_die("Error loading acm"); } write(fd, "\033(K", 3); 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) #ifdef BB_FEATURE_LS_FOLLOWLINKS if (follow_links == TRUE) { if (stat(cur->fullname, &cur->dstat)) { - error_msg("%s: %s\n", cur->fullname, strerror(errno)); + perror_msg("%s", cur->fullname); status = EXIT_FAILURE; free(cur->fullname); free(cur); @@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur) } else #endif if (lstat(cur->fullname, &cur->dstat)) { - error_msg("%s: %s\n", cur->fullname, strerror(errno)); + perror_msg("%s", cur->fullname); status = EXIT_FAILURE; free(cur->fullname); free(cur); @@ -511,7 +511,7 @@ struct dnode **list_dir(char *path) nfiles= 0; dir = opendir(path); if (dir == NULL) { - error_msg("%s: %s\n", path, strerror(errno)); + perror_msg("%s", path); status = EXIT_FAILURE; return(NULL); /* could not open the dir */ } 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, } else { fp = fopen(filename, OPENOPTS(binary)); if (fp == NULL) { - error_msg("%s: %s\n", filename, strerror(errno)); + perror_msg("%s", filename); return FALSE; } } if (md5_stream(fp, md5_result)) { - error_msg("%s: %s\n", filename, strerror(errno)); + perror_msg("%s", filename); if (fp != stdin) fclose(fp); @@ -665,7 +665,7 @@ static int md5_file(const char *filename, } if (fp != stdin && fclose(fp) == EOF) { - error_msg("%s: %s\n", filename, strerror(errno)); + perror_msg("%s", filename); return FALSE; } @@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name) } else { checkfile_stream = fopen(checkfile_name, "r"); if (checkfile_stream == NULL) { - error_msg("%s: %s\n", checkfile_name, strerror(errno)); + perror_msg("%s", checkfile_name); return FALSE; } } @@ -775,7 +775,7 @@ static int md5_check(const char *checkfile_name) } if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) { - error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); + perror_msg("md5sum: %s", checkfile_name); return FALSE; } 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) buf = xrealloc(buf, bufsize); size = readlink(argv[1], buf, bufsize); if (size == -1) - error_msg_and_die("%s: %s\n", argv[1], strerror(errno)); + perror_msg_and_die("%s", argv[1]); } 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 @@ #ifndef MODUTILS_MODULE_H #define MODUTILS_MODULE_H 1 -#ident "$Id: insmod.c,v 1.32 2000/12/13 16:41:29 andersen Exp $" +#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $" /* This file contains the structures used by the 2.0 and 2.1 kernels. We do not use the kernel headers directly because we do not wish @@ -284,7 +284,7 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H #define MODUTILS_OBJ_H 1 -#ident "$Id: insmod.c,v 1.32 2000/12/13 16:41:29 andersen Exp $" +#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $" /* The relocatable object is manipulated using elfin types. */ @@ -1562,7 +1562,7 @@ static int old_get_kernel_symbols(const char *m_name) nks = get_kernel_syms(NULL); if (nks < 0) { - error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); + perror_msg("get_kernel_syms: %s", m_name); return 0; } @@ -1743,7 +1743,7 @@ old_init_module(const char *m_name, struct obj_file *f, m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN : 0), &routines, symtab); if (ret) - error_msg("init_module: %s: %s\n", m_name, strerror(errno)); + perror_msg("init_module: %s", m_name); free(image); free(symtab); @@ -2055,7 +2055,7 @@ static int new_get_kernel_symbols(void) module_names = xrealloc(module_names, bufsize = ret); goto retry_modules_load; } - error_msg("QM_MODULES: %s\n", strerror(errno)); + perror_msg("QM_MODULES"); return 0; } @@ -2074,7 +2074,7 @@ static int new_get_kernel_symbols(void) /* The module was removed out from underneath us. */ continue; } - error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); + perror_msg("query_module: QM_INFO: %s", mn); return 0; } @@ -2089,7 +2089,7 @@ static int new_get_kernel_symbols(void) /* The module was removed out from underneath us. */ continue; default: - error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); + perror_msg("query_module: QM_SYMBOLS: %s", mn); return 0; } } @@ -2114,7 +2114,7 @@ static int new_get_kernel_symbols(void) syms = xrealloc(syms, bufsize = ret); goto retry_kern_sym_load; } - error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); + perror_msg("kernel: QM_SYMBOLS"); return 0; } nksyms = nsyms = ret; @@ -2295,7 +2295,7 @@ new_init_module(const char *m_name, struct obj_file *f, ret = new_sys_init_module(m_name, (struct new_module *) image); if (ret) - error_msg("init_module: %s: %s\n", m_name, strerror(errno)); + perror_msg("init_module: %s", m_name); free(image); @@ -2680,7 +2680,7 @@ struct obj_file *obj_load(FILE * fp) fseek(fp, 0, SEEK_SET); if (fread(&f->header, sizeof(f->header), 1, fp) != 1) { - error_msg("error reading ELF header: %s\n", strerror(errno)); + perror_msg("error reading ELF header"); return NULL; } @@ -2719,7 +2719,7 @@ struct obj_file *obj_load(FILE * fp) section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); fseek(fp, f->header.e_shoff, SEEK_SET); if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) { - error_msg("error reading ELF section headers: %s\n", strerror(errno)); + perror_msg("error reading ELF section headers"); return NULL; } @@ -2749,7 +2749,7 @@ struct obj_file *obj_load(FILE * fp) sec->contents = xmalloc(sec->header.sh_size); fseek(fp, sec->header.sh_offset, SEEK_SET); if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { - error_msg("error reading ELF section data: %s\n", strerror(errno)); + perror_msg("error reading ELF section data"); return NULL; } } else { @@ -3075,7 +3075,7 @@ extern int insmod_main( int argc, char **argv) m_size); goto out; default: - error_msg("create_module: %s: %s\n", m_name, strerror(errno)); + perror_msg("create_module: %s", m_name); goto out; } 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, /* open device */ fd = open(device, O_RDONLY); if (fd < 0) - error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die("open failed for `%s'", device); /* How many filesystems? We need to know to allocate enough space */ numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS); if (numfilesystems<0) - error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno)); + perror_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS"); fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype)); /* Grab the list of available filesystems */ status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist); if (status<0) - error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno)); + perror_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS"); /* Walk the list trying to mount filesystems * that do not claim to be nodev filesystems */ @@ -307,8 +307,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, if (status == FALSE) { if (whineOnErrors == TRUE) { - error_msg("Mounting %s on %s failed: %s\n", - blockDevice, directory, strerror(errno)); + perror_msg("Mounting %s on %s failed", blockDevice, directory); } return (FALSE); } @@ -340,18 +339,18 @@ extern int mount_main(int argc, char **argv) /* open device */ fd = open(device, O_RDONLY); if (fd < 0) - error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die("open failed for `%s'", device); /* How many mounted filesystems? We need to know to * allocate enough space for later... */ numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS); if (numfilesystems<0) - error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno)); + perror_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS"); mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent)); /* Grab the list of mounted filesystems */ if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0) - error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno)); + perror_msg_and_die( "\nDEVMTAB_GET_MOUNTS"); for( i = 0 ; i < numfilesystems ; i++) { 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) fstabmount = TRUE; if (f == NULL) - error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno)); + perror_msg_and_die( "\nCannot read /etc/fstab"); while ((m = getmntent(f)) != NULL) { if (all == FALSE && directory == NULL && ( @@ -487,7 +486,7 @@ singlemount: rc = nfsmount (device, directory, &flags, &extra_opts, &string_flags, 1); if ( rc != 0) { - error_msg_and_die("nfsmount failed: %s\n", strerror(errno)); + perror_msg_and_die("nfsmount failed"); rc = EXIT_FAILURE; } } 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 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping.c,v 1.28 2000/12/07 19:56:48 markw Exp $ + * $Id: ping.c,v 1.29 2000/12/18 03:57:16 kraai Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -325,7 +325,7 @@ static void sendping(int junk) (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); if (i < 0) - error_msg_and_die("sendto: %s\n", strerror(errno)); + perror_msg_and_die("sendto"); else if ((size_t)i != sizeof(packet)) error_msg_and_die("ping wrote %d chars; %d expected\n", i, (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) if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0) { - error_msg_and_die("Unable to connect to remote host: %s\n", strerror(errno)); + perror_msg_and_die("Unable to connect to remote host"); } return s; } diff --git a/ping.c b/ping.c index ccc535b26..4be2120c8 100644 --- a/ping.c +++ b/ping.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping.c,v 1.28 2000/12/07 19:56:48 markw Exp $ + * $Id: ping.c,v 1.29 2000/12/18 03:57:16 kraai Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -325,7 +325,7 @@ static void sendping(int junk) (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); if (i < 0) - error_msg_and_die("sendto: %s\n", strerror(errno)); + perror_msg_and_die("sendto"); else if ((size_t)i != sizeof(packet)) error_msg_and_die("ping wrote %d chars; %d expected\n", i, (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) int pid; if (!isdigit(**argv)) - error_msg_and_die( "Bad PID: %s\n", strerror(errno)); + perror_msg_and_die( "Bad PID"); pid = strtol(*argv, NULL, 0); if (kill(pid, sig) != 0) - error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno)); + perror_msg_and_die( "Could not kill pid '%d'", pid); argv++; } } @@ -229,7 +229,7 @@ extern int kill_main(int argc, char **argv) if (*pidList==myPid) continue; if (kill(*pidList, sig) != 0) - error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno)); + perror_msg_and_die( "Could not kill pid '%d'", *pidList); } /* Note that we don't bother to free the memory * 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) /* open device */ fd = open(device, O_RDONLY); if (fd < 0) - error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die( "open failed for `%s'", device); /* Find out how many processes there are */ if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) - error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); + perror_msg_and_die( "\nDEVPS_GET_PID_LIST"); /* Allocate some memory -- grab a few extras just in case * some new processes start up while we wait. The kernel will @@ -231,7 +231,7 @@ extern int ps_main(int argc, char **argv) /* Now grab the pid list */ if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) - error_msg_and_die("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); + perror_msg_and_die("\nDEVPS_GET_PID_LIST"); #ifdef BB_FEATURE_AUTOWIDTH ioctl(fileno(stdout), TIOCGWINSZ, &win); @@ -247,7 +247,7 @@ extern int ps_main(int argc, char **argv) info.pid = pid_array[i]; if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) - error_msg_and_die("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno)); + perror_msg_and_die("\nDEVPS_GET_PID_INFO"); /* Make some adjustments as needed */ my_getpwuid(uidName, info.euid); @@ -277,7 +277,7 @@ extern int ps_main(int argc, char **argv) /* close device */ if (close (fd) != 0) - error_msg_and_die("close failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die("close failed for `%s'", device); exit (0); } 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) /* open device */ fd = open(device, O_RDONLY); if (fd < 0) - error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die( "open failed for `%s'", device); /* Find out how many processes there are */ if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) - error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); + perror_msg_and_die( "\nDEVPS_GET_PID_LIST"); /* Allocate some memory -- grab a few extras just in case * some new processes start up while we wait. The kernel will @@ -231,7 +231,7 @@ extern int ps_main(int argc, char **argv) /* Now grab the pid list */ if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) - error_msg_and_die("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); + perror_msg_and_die("\nDEVPS_GET_PID_LIST"); #ifdef BB_FEATURE_AUTOWIDTH ioctl(fileno(stdout), TIOCGWINSZ, &win); @@ -247,7 +247,7 @@ extern int ps_main(int argc, char **argv) info.pid = pid_array[i]; if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) - error_msg_and_die("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno)); + perror_msg_and_die("\nDEVPS_GET_PID_INFO"); /* Make some adjustments as needed */ my_getpwuid(uidName, info.euid); @@ -277,7 +277,7 @@ extern int ps_main(int argc, char **argv) /* close device */ if (close (fd) != 0) - error_msg_and_die("close failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die("close failed for `%s'", device); exit (0); } 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) char buf[BUFSIZ + 1]; if (getcwd(buf, sizeof(buf)) == NULL) - error_msg_and_die("%s\n", strerror(errno)); + perror_msg_and_die("getcwd"); - printf("%s\n", buf); + puts(buf); return EXIT_SUCCESS; } 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) int fd; if (!(h = gethostbyname(host))) { /* get the IP addr */ - error_msg("%s: %s\n", host, strerror(errno)); + perror_msg("%s", host); return(-1); } if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */ - error_msg("%s: %s\n", "time", strerror(errno)); + perror_msg("%s", "time"); return(-1); } if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */ - error_msg("%s: %s\n", "socket", strerror(errno)); + perror_msg("%s", "socket"); return(-1); } @@ -64,7 +64,7 @@ time_t askremotedate(char *host) sin.sin_family = AF_INET; if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */ - error_msg("%s: %s\n", host, strerror(errno)); + perror_msg("%s", host); close(fd); return(-1); } @@ -123,7 +123,7 @@ int rdate_main(int argc, char **argv) } if (setdate) { if (stime(&time) < 0) - error_msg_and_die("Could not set time of day: %s\n", strerror(errno)); + perror_msg_and_die("Could not set time of day"); } if (printdate) { 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) buf = xrealloc(buf, bufsize); size = readlink(argv[1], buf, bufsize); if (size == -1) - error_msg_and_die("%s: %s\n", argv[1], strerror(errno)); + perror_msg_and_die("%s", argv[1]); } 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) for (i = optind; i < argc; i++) { file = fopen(argv[i], "r"); if (file == NULL) { - error_msg("%s: %s\n", argv[i], strerror(errno)); + perror_msg("%s", argv[i]); } else { process_file(file); 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) /* Create the syslog file so realpath() can work. */ close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); if (realpath (_PATH_LOG, lfile) == NULL) - error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno)); + perror_msg_and_die ("Could not resolve path to " _PATH_LOG); unlink (lfile); @@ -321,14 +321,14 @@ static void doSyslogd (void) sunx.sun_family = AF_UNIX; strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) - error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno)); + perror_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG); addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) - error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno)); + perror_msg_and_die ("Could not connect to socket " _PATH_LOG); if (chmod (lfile, 0666) < 0) - error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno)); + perror_msg_and_die ("Could not set permission on " _PATH_LOG); FD_ZERO (&fds); FD_SET (sock_fd, &fds); @@ -351,7 +351,7 @@ static void doSyslogd (void) if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { if (errno == EINTR) continue; /* alarm may have happened. */ - error_msg_and_die ("select error: %s\n", strerror (errno)); + perror_msg_and_die ("select error"); } for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { @@ -365,7 +365,7 @@ static void doSyslogd (void) pid_t pid; if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { - error_msg_and_die ("accept error: %s\n", strerror (errno)); + perror_msg_and_die ("accept error"); } 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) /* Create the syslog file so realpath() can work. */ close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); if (realpath (_PATH_LOG, lfile) == NULL) - error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno)); + perror_msg_and_die ("Could not resolve path to " _PATH_LOG); unlink (lfile); @@ -321,14 +321,14 @@ static void doSyslogd (void) sunx.sun_family = AF_UNIX; strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) - error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno)); + perror_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG); addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) - error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno)); + perror_msg_and_die ("Could not connect to socket " _PATH_LOG); if (chmod (lfile, 0666) < 0) - error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno)); + perror_msg_and_die ("Could not set permission on " _PATH_LOG); FD_ZERO (&fds); FD_SET (sock_fd, &fds); @@ -351,7 +351,7 @@ static void doSyslogd (void) if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { if (errno == EINTR) continue; /* alarm may have happened. */ - error_msg_and_die ("select error: %s\n", strerror (errno)); + perror_msg_and_die ("select error"); } for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { @@ -365,7 +365,7 @@ static void doSyslogd (void) pid_t pid; if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { - error_msg_and_die ("accept error: %s\n", strerror (errno)); + perror_msg_and_die ("accept error"); } 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) else tarFd = open(tarName, O_RDONLY); if (tarFd < 0) - error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno)); + perror_msg_and_die("Error opening '%s'", tarName); #ifdef BB_FEATURE_TAR_GZIP /* unzip tarFd in a seperate process */ @@ -425,8 +425,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) return( TRUE); if (create_path(header->name, header->mode) != TRUE) { - error_msg("%s: Cannot mkdir: %s\n", - header->name, strerror(errno)); + perror_msg("%s: Cannot mkdir", header->name); return( FALSE); } /* make the final component, just in case it was @@ -445,8 +444,8 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag) return( TRUE); if (link(header->linkname, header->name) < 0) { - error_msg("%s: Cannot create hard link to '%s': %s\n", - header->name, header->linkname, strerror(errno)); + perror_msg("%s: Cannot create hard link to '%s'", header->name, + header->linkname); return( FALSE); } @@ -463,8 +462,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag) #ifdef S_ISLNK if (symlink(header->linkname, header->name) < 0) { - error_msg("%s: Cannot create symlink to '%s': %s\n", - header->name, header->linkname, strerror(errno)); + perror_msg("%s: Cannot create symlink to '%s'", header->name, + header->linkname); return( FALSE); } /* Try to change ownership of the symlink. @@ -493,14 +492,12 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag) if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) { if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) { - error_msg("%s: Cannot mknod: %s\n", - header->name, strerror(errno)); + perror_msg("%s: Cannot mknod", header->name); return( FALSE); } } else if (S_ISFIFO(header->mode)) { if (mkfifo(header->name, header->mode) < 0) { - error_msg("%s: Cannot mkfifo: %s\n", - header->name, strerror(errno)); + perror_msg("%s: Cannot mkfifo", header->name); return( FALSE); } } @@ -790,7 +787,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag, close(tarFd); if (status > 0) { /* Bummer - we read a partial header */ - error_msg( "Error reading tar file: %s\n", strerror(errno)); + perror_msg("Error reading tar file"); return ( FALSE); } else if (errorFlag==TRUE) { @@ -1007,7 +1004,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st header.typeflag = SYMTYPE; link_size = readlink(fileName, buffer, sizeof(buffer) - 1); if ( link_size < 0) { - error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); + perror_msg("Error reading symlink '%s'", header.name); return ( FALSE); } buffer[link_size] = '\0'; @@ -1165,7 +1162,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv, else tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (tbInfo.tarFd < 0) { - error_msg( "Error opening '%s': %s\n", tarName, strerror(errno)); + perror_msg( "Error opening '%s'", tarName); freeHardLinkInfo(&tbInfo.hlInfoHead); return ( FALSE); } 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) while (optind < argc) { if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) { nfiles--; - error_msg("%s: %s\n", argv[optind-1], strerror(errno)); + perror_msg("%s", argv[optind-1]); status = 1; } } 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) if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0) { - error_msg_and_die("Unable to connect to remote host: %s\n", strerror(errno)); + perror_msg_and_die("Unable to connect to remote host"); } return s; } 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) } if ((f = open(argv[1], O_RDWR)) == -1) { - error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno)); + perror_msg_and_die("cannot open %s", argv[1]); } if (ioctl(f, BLKFLSBUF) < 0) { - error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); + perror_msg_and_die("failed ioctl on %s", argv[1]); } /* Don't bother closing. Exit does * 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, /* open device */ fd = open(device, O_RDONLY); if (fd < 0) - error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die("open failed for `%s'", device); /* How many filesystems? We need to know to allocate enough space */ numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS); if (numfilesystems<0) - error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno)); + perror_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS"); fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype)); /* Grab the list of available filesystems */ status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist); if (status<0) - error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno)); + perror_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS"); /* Walk the list trying to mount filesystems * that do not claim to be nodev filesystems */ @@ -307,8 +307,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, if (status == FALSE) { if (whineOnErrors == TRUE) { - error_msg("Mounting %s on %s failed: %s\n", - blockDevice, directory, strerror(errno)); + perror_msg("Mounting %s on %s failed", blockDevice, directory); } return (FALSE); } @@ -340,18 +339,18 @@ extern int mount_main(int argc, char **argv) /* open device */ fd = open(device, O_RDONLY); if (fd < 0) - error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die("open failed for `%s'", device); /* How many mounted filesystems? We need to know to * allocate enough space for later... */ numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS); if (numfilesystems<0) - error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno)); + perror_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS"); mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent)); /* Grab the list of mounted filesystems */ if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0) - error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno)); + perror_msg_and_die( "\nDEVMTAB_GET_MOUNTS"); for( i = 0 ; i < numfilesystems ; i++) { 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) fstabmount = TRUE; if (f == NULL) - error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno)); + perror_msg_and_die( "\nCannot read /etc/fstab"); while ((m = getmntent(f)) != NULL) { if (all == FALSE && directory == NULL && ( @@ -487,7 +486,7 @@ singlemount: rc = nfsmount (device, directory, &flags, &extra_opts, &string_flags, 1); if ( rc != 0) { - error_msg_and_die("nfsmount failed: %s\n", strerror(errno)); + perror_msg_and_die("nfsmount failed"); rc = EXIT_FAILURE; } } 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) int fd; if (!(h = gethostbyname(host))) { /* get the IP addr */ - error_msg("%s: %s\n", host, strerror(errno)); + perror_msg("%s", host); return(-1); } if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */ - error_msg("%s: %s\n", "time", strerror(errno)); + perror_msg("%s", "time"); return(-1); } if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */ - error_msg("%s: %s\n", "socket", strerror(errno)); + perror_msg("%s", "socket"); return(-1); } @@ -64,7 +64,7 @@ time_t askremotedate(char *host) sin.sin_family = AF_INET; if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */ - error_msg("%s: %s\n", host, strerror(errno)); + perror_msg("%s", host); close(fd); return(-1); } @@ -123,7 +123,7 @@ int rdate_main(int argc, char **argv) } if (setdate) { if (stime(&time) < 0) - error_msg_and_die("Could not set time of day: %s\n", strerror(errno)); + perror_msg_and_die("Could not set time of day"); } if (printdate) { 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) /* open device */ fd = open(device, O_RDONLY); if (fd < 0) - error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); + perror_msg_and_die( "open failed for `%s'", device); /* Find out how many processes there are */ if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) - error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); + perror_msg_and_die( "\nDEVPS_GET_PID_LIST"); /* Allocate some memory -- grab a few extras just in case * some new processes start up while we wait. The kernel will @@ -1328,7 +1328,7 @@ extern pid_t* find_pid_by_name( char* pidName) /* Now grab the pid list */ if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) - error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); + perror_msg_and_die( "\nDEVPS_GET_PID_LIST"); /* Now search for a match */ for (i=1, j=0; i 0) { switch (opt) { case 'm': trans_ptr = uu_base64; break; - case 0: - break; - default: usage(uuencode_usage); } @@ -178,7 +175,7 @@ int uuencode_main (int argc, case 2: /* Optional first argument is input file. */ if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { - error_msg("%s: %s\n", argv[optind], strerror(errno)); + perror_msg("%s", argv[optind]); return EXIT_FAILURE; } mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);