From: Matt Kraai Date: Wed, 12 Jul 2000 17:02:35 +0000 (-0000) Subject: Always report the applet name when doing error reporting. X-Git-Tag: android-x86-2.2~9860 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=be84cd4ef66f8956eb4c7ff0542fd1ba823a70e7;p=android-x86%2Fexternal-busybox.git Always report the applet name when doing error reporting. --- diff --git a/ar.c b/ar.c index 27dfadd1d..a43cc1dff 100644 --- a/ar.c +++ b/ar.c @@ -158,12 +158,12 @@ static int copySubFile(int srcFd, int dstFd, int copySize) readSize = copySize; writeSize = fullRead(srcFd, buffer, readSize); if (writeSize <= 0) { - errorMsg(io_error, "copySubFile :", strerror(errno)); + errorMsg(io_error, "copySubFile", strerror(errno)); return (FALSE); } doneSize = fullWrite(dstFd, buffer, writeSize); if (doneSize <= 0) { - errorMsg(io_error, "copySubFile :", strerror(errno)); + errorMsg(io_error, "copySubFile", strerror(errno)); return (FALSE); } copySize -= doneSize; @@ -220,7 +220,7 @@ static int getArFd(char *filename) return (FALSE); } if (fullRead(arFd, arVersion, 8) <= 0) { - errorMsg( "ar: Unexpected EOF in archive\n"); + errorMsg( "Unexpected EOF in archive\n"); return (FALSE); } if (strncmp(arVersion,"!",7) != 0) { diff --git a/archival/ar.c b/archival/ar.c index 27dfadd1d..a43cc1dff 100644 --- a/archival/ar.c +++ b/archival/ar.c @@ -158,12 +158,12 @@ static int copySubFile(int srcFd, int dstFd, int copySize) readSize = copySize; writeSize = fullRead(srcFd, buffer, readSize); if (writeSize <= 0) { - errorMsg(io_error, "copySubFile :", strerror(errno)); + errorMsg(io_error, "copySubFile", strerror(errno)); return (FALSE); } doneSize = fullWrite(dstFd, buffer, writeSize); if (doneSize <= 0) { - errorMsg(io_error, "copySubFile :", strerror(errno)); + errorMsg(io_error, "copySubFile", strerror(errno)); return (FALSE); } copySize -= doneSize; @@ -220,7 +220,7 @@ static int getArFd(char *filename) return (FALSE); } if (fullRead(arFd, arVersion, 8) <= 0) { - errorMsg( "ar: Unexpected EOF in archive\n"); + errorMsg( "Unexpected EOF in archive\n"); return (FALSE); } if (strncmp(arVersion,"!",7) != 0) { diff --git a/archival/gunzip.c b/archival/gunzip.c index e6b8202c8..89e46a686 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c @@ -212,7 +212,7 @@ extern int method; /* compression method */ # define DECLARE(type, array, size) type * array # define ALLOC(type, array, size) { \ array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ - if (array == NULL) errorMsg(memory_exhausted, "gunzip"); \ + if (array == NULL) errorMsg(memory_exhausted); \ } # define FREE(array) {if (array != NULL) free(array), array=NULL;} #else @@ -930,7 +930,7 @@ int in, out; /* input and output file descriptors */ int res = inflate(); if (res == 3) { - errorMsg(memory_exhausted, "gunzip"); + errorMsg(memory_exhausted); } else if (res != 0) { errorMsg("invalid compressed data--format violated"); } diff --git a/archival/gzip.c b/archival/gzip.c index 9248cfecd..8bc67d9c6 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -127,7 +127,7 @@ extern int method; /* compression method */ # define DECLARE(type, array, size) type * array # define ALLOC(type, array, size) { \ array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ - if (array == NULL) errorMsg(memory_exhausted, "gzip"); \ + if (array == NULL) errorMsg(memory_exhausted); \ } # define FREE(array) {if (array != NULL) free(array), array=NULL;} #else @@ -3251,7 +3251,7 @@ char *env; /* name of environment variable */ nargv = (char **) calloc(*argcp + 1, sizeof(char *)); if (nargv == NULL) - errorMsg(memory_exhausted, "gzip"); + errorMsg(memory_exhausted); oargv = *argvp; *argvp = nargv; diff --git a/archival/tar.c b/archival/tar.c index af017d112..353694f33 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -330,7 +330,7 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag) } if ( (readSize = fullRead(header->tarFd, buffer, readSize)) <= 0 ) { /* Tarball seems to have a problem */ - errorMsg("tar: Unexpected EOF in archive\n"); + errorMsg("Unexpected EOF in archive\n"); return( FALSE); } if ( readSize < writeSize ) @@ -368,7 +368,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) return( TRUE); if (createPath(header->name, header->mode) != TRUE) { - errorMsg("tar: %s: Cannot mkdir: %s\n", + errorMsg("%s: Cannot mkdir: %s\n", header->name, strerror(errno)); return( FALSE); } @@ -388,7 +388,7 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag) return( TRUE); if (link(header->linkname, header->name) < 0) { - errorMsg("tar: %s: Cannot create hard link to '%s': %s\n", + errorMsg("%s: Cannot create hard link to '%s': %s\n", header->name, header->linkname, strerror(errno)); return( FALSE); } @@ -406,7 +406,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag) #ifdef S_ISLNK if (symlink(header->linkname, header->name) < 0) { - errorMsg("tar: %s: Cannot create symlink to '%s': %s\n", + errorMsg("%s: Cannot create symlink to '%s': %s\n", header->name, header->linkname, strerror(errno)); return( FALSE); } @@ -421,7 +421,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag) /* Do not change permissions or date on symlink, * since it changes the pointed to file instead. duh. */ #else - errorMsg("tar: %s: Cannot create symlink to '%s': %s\n", + errorMsg("%s: Cannot create symlink to '%s': %s\n", header->name, header->linkname, "symlinks not supported"); #endif @@ -436,13 +436,13 @@ 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) { - errorMsg("tar: %s: Cannot mknod: %s\n", + errorMsg("%s: Cannot mknod: %s\n", header->name, strerror(errno)); return( FALSE); } } else if (S_ISFIFO(header->mode)) { if (mkfifo(header->name, header->mode) < 0) { - errorMsg("tar: %s: Cannot mkfifo: %s\n", + errorMsg("%s: Cannot mkfifo: %s\n", header->name, strerror(errno)); return( FALSE); } @@ -490,7 +490,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header) ++*(header->name); if (alreadyWarned == FALSE) { - errorMsg("tar: Removing leading '/' from member names\n"); + errorMsg("Removing leading '/' from member names\n"); alreadyWarned = TRUE; } } @@ -695,7 +695,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag, return ( FALSE); } else if (errorFlag==TRUE) { - errorMsg( "tar: Error exit delayed from previous errors\n"); + errorMsg( "Error exit delayed from previous errors\n"); return( FALSE); } else return( status); @@ -705,7 +705,7 @@ endgame: close( tarFd); if ( *(header.name) == '\0' ) { if (errorFlag==TRUE) - errorMsg( "tar: Error exit delayed from previous errors\n"); + errorMsg( "Error exit delayed from previous errors\n"); else return( TRUE); } @@ -782,7 +782,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st if (*fileName=='/') { static int alreadyWarned=FALSE; if (alreadyWarned==FALSE) { - errorMsg("tar: Removing leading '/' from member names\n"); + errorMsg("Removing leading '/' from member names\n"); alreadyWarned=TRUE; } strncpy(header.name, fileName+1, sizeof(header.name)); @@ -854,7 +854,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st header.typeflag = REGTYPE; putOctal(header.size, sizeof(header.size), statbuf->st_size); } else { - errorMsg("tar: %s: Unknown file type\n", fileName); + errorMsg("%s: Unknown file type\n", fileName); return ( FALSE); } @@ -892,7 +892,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* /* It is against the rules to archive a socket */ if (S_ISSOCK(statbuf->st_mode)) { - errorMsg("tar: %s: socket ignored\n", fileName); + errorMsg("%s: socket ignored\n", fileName); return( TRUE); } @@ -901,7 +901,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* * the new tarball */ if (tbInfo->statBuf.st_dev == statbuf->st_dev && tbInfo->statBuf.st_ino == statbuf->st_ino) { - errorMsg("tar: %s: file is the archive; skipping\n", fileName); + errorMsg("%s: file is the archive; skipping\n", fileName); return( TRUE); } @@ -917,7 +917,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* /* open the file we want to archive, and make sure all is well */ if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { - errorMsg("tar: %s: Cannot open: %s\n", fileName, strerror(errno)); + errorMsg("%s: Cannot open: %s\n", fileName, strerror(errno)); return( FALSE); } @@ -955,7 +955,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag, /* Make sure there is at least one file to tar up. */ if (argc <= 0) - fatalError("tar: Cowardly refusing to create an empty archive\n"); + fatalError("Cowardly refusing to create an empty archive\n"); /* Open the tar file for writing. */ if (tostdoutFlag == TRUE) @@ -963,7 +963,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag, else tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (tbInfo.tarFd < 0) { - errorMsg( "tar: Error opening '%s': %s\n", tarName, strerror(errno)); + errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno)); return ( FALSE); } tbInfo.excludeList=excludeList; @@ -997,7 +997,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag, /* Hang up the tools, close up shop, head home */ close(tarFd); if (errorFlag == TRUE) { - errorMsg("tar: Error exit delayed from previous errors\n"); + errorMsg("Error exit delayed from previous errors\n"); return(FALSE); } return( TRUE); diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index a5d9af491..98b292568 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c @@ -87,7 +87,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk) case CHMOD_APP: /* Parse the specified modes */ if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) { - fatalError( "%s: unknown mode: %s\n", applet_name, theMode); + fatalError( "unknown mode: %s\n", theMode); } if (chmod(fileName, statbuf->st_mode) == 0) return (TRUE); @@ -169,15 +169,14 @@ int chmod_chown_chgrp_main(int argc, char **argv) if (*argv == p) uid = my_getpwnam(*argv); if (uid == -1) { - fatalError( "%s: unknown user name: %s\n", - applet_name, *argv); + fatalError( "unknown user name: %s\n", *argv); } } } /* Ok, ready to do the deed now */ if (argc <= 1) { - fatalError( "%s: too few arguments\n", applet_name); + fatalError( "too few arguments\n"); } while (argc-- > 1) { if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE, @@ -187,7 +186,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) exit(TRUE); bad_group: - fatalError( "%s: unknown group name: %s\n", applet_name, groupName); + fatalError( "unknown group name: %s\n", groupName); } /* diff --git a/chroot.c b/chroot.c index 1c64e08a9..95aed3d17 100644 --- a/chroot.c +++ b/chroot.c @@ -47,8 +47,7 @@ int chroot_main(int argc, char **argv) argv++; if (chroot(*argv) || (chdir("/"))) { - fatalError("chroot: cannot change root directory to %s: %s\n", - *argv, strerror(errno)); + fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno)); } argc--; @@ -62,8 +61,7 @@ int chroot_main(int argc, char **argv) prog = "/bin/sh"; execlp(prog, prog, NULL); } - fatalError("chroot: cannot execute %s: %s\n", - prog, strerror(errno)); + fatalError("cannot execute %s: %s\n", prog, strerror(errno)); } diff --git a/coreutils/chroot.c b/coreutils/chroot.c index 1c64e08a9..95aed3d17 100644 --- a/coreutils/chroot.c +++ b/coreutils/chroot.c @@ -47,8 +47,7 @@ int chroot_main(int argc, char **argv) argv++; if (chroot(*argv) || (chdir("/"))) { - fatalError("chroot: cannot change root directory to %s: %s\n", - *argv, strerror(errno)); + fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno)); } argc--; @@ -62,8 +61,7 @@ int chroot_main(int argc, char **argv) prog = "/bin/sh"; execlp(prog, prog, NULL); } - fatalError("chroot: cannot execute %s: %s\n", - prog, strerror(errno)); + fatalError("cannot execute %s: %s\n", prog, strerror(errno)); } diff --git a/coreutils/date.c b/coreutils/date.c index 9e8e3f3eb..bc6d13137 100644 --- a/coreutils/date.c +++ b/coreutils/date.c @@ -66,7 +66,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string) &(tm_time->tm_min), &(tm_time->tm_year)); if (nr < 4 || nr > 5) { - fatalError(invalid_date, "date", t_string); + fatalError(invalid_date, t_string); } /* correct for century - minor Y2K problem here? */ @@ -150,7 +150,7 @@ struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string) } - fatalError(invalid_date, "date", t_string); + fatalError(invalid_date, t_string); } @@ -186,7 +186,7 @@ int date_main(int argc, char **argv) case 'u': utc = 1; if (putenv("TZ=UTC0") != 0) - fatalError(memory_exhausted, "date"); + fatalError(memory_exhausted); break; case 'd': use_arg = 1; @@ -236,12 +236,12 @@ int date_main(int argc, char **argv) /* Correct any day of week and day of year etc fields */ tm = mktime(&tm_time); if (tm < 0) - fatalError(invalid_date, "date", date_str); + fatalError(invalid_date, date_str); /* if setting time, set it */ if (set_time) { if (stime(&tm) < 0) { - fatalError("date: can't set date.\n"); + fatalError("can't set date.\n"); } } } diff --git a/coreutils/md5sum.c b/coreutils/md5sum.c index f4a8b99d0..e6f1c86b4 100644 --- a/coreutils/md5sum.c +++ b/coreutils/md5sum.c @@ -708,13 +708,13 @@ static int md5_file(const char *filename, } else { fp = fopen(filename, OPENOPTS(binary)); if (fp == NULL) { - errorMsg("md5sum: %s: %s\n", filename, strerror(errno)); + errorMsg("%s: %s\n", filename, strerror(errno)); return FALSE; } } if (md5_stream(fp, md5_result)) { - errorMsg("md5sum: %s: %s\n", filename, strerror(errno)); + errorMsg("%s: %s\n", filename, strerror(errno)); if (fp != stdin) fclose(fp); @@ -722,7 +722,7 @@ static int md5_file(const char *filename, } if (fp != stdin && fclose(fp) == EOF) { - errorMsg("md5sum: %s: %s\n", filename, strerror(errno)); + errorMsg("%s: %s\n", filename, strerror(errno)); return FALSE; } @@ -746,7 +746,7 @@ static int md5_check(const char *checkfile_name) } else { checkfile_stream = fopen(checkfile_name, "r"); if (checkfile_stream == NULL) { - errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); + errorMsg("%s: %s\n", checkfile_name, strerror(errno)); return FALSE; } } diff --git a/coreutils/pwd.c b/coreutils/pwd.c index 87553b3de..f0c923b7b 100644 --- a/coreutils/pwd.c +++ b/coreutils/pwd.c @@ -31,7 +31,7 @@ extern int pwd_main(int argc, char **argv) char buf[BUFSIZ + 1]; if (getcwd(buf, sizeof(buf)) == NULL) - fatalError("pwd: %s\n", strerror(errno)); + fatalError("%s\n", strerror(errno)); printf("%s\n", buf); return(TRUE); diff --git a/coreutils/touch.c b/coreutils/touch.c index f52bb0284..ac275423c 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c @@ -70,12 +70,12 @@ extern int touch_main(int argc, char **argv) if (create == FALSE && errno == ENOENT) exit(TRUE); else { - fatalError("touch: %s", strerror(errno)); + fatalError("%s", strerror(errno)); } } close(fd); if (utime(*argv, NULL)) { - fatalError("touch: %s", strerror(errno)); + fatalError("%s", strerror(errno)); } argc--; argv++; diff --git a/coreutils/tr.c b/coreutils/tr.c index 5a8116db0..293bbce6b 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c @@ -189,7 +189,7 @@ extern int tr_main(int argc, char **argv) complement(input); if (argv[index] != NULL) { if (*argv[index] == '\0') - fatalError("tr: STRING2 cannot be empty\n"); + fatalError("STRING2 cannot be empty\n"); expand(argv[index], output); map(input, output); } diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index ac33762b0..12a71a573 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c @@ -286,7 +286,7 @@ static int decode (const char *inname, && (freopen (outname, "w", stdout) == NULL || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) )) { - errorMsg("uudeoce %s: %s %s\n", outname, inname, strerror(errno)); /* */ + errorMsg("%s: %s %s\n", outname, inname, strerror(errno)); /* */ return FALSE; } @@ -340,7 +340,7 @@ int uudecode_main (int argc, if (decode (argv[optind], outname) != 0) exit_status = FALSE; } else { - errorMsg("uudecode: %s: %s\n", argv[optind], strerror(errno)); + errorMsg("%s: %s\n", argv[optind], strerror(errno)); exit_status = FALSE; } optind++; diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index e4fc1a0bc..e107a01e7 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c @@ -217,7 +217,7 @@ int uuencode_main (int argc, case 2: /* Optional first argument is input file. */ if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { - errorMsg("uuencode: %s: %s\n", argv[optind], strerror(errno)); + errorMsg("%s: %s\n", argv[optind], strerror(errno)); exit FALSE; } mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); diff --git a/date.c b/date.c index 9e8e3f3eb..bc6d13137 100644 --- a/date.c +++ b/date.c @@ -66,7 +66,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string) &(tm_time->tm_min), &(tm_time->tm_year)); if (nr < 4 || nr > 5) { - fatalError(invalid_date, "date", t_string); + fatalError(invalid_date, t_string); } /* correct for century - minor Y2K problem here? */ @@ -150,7 +150,7 @@ struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string) } - fatalError(invalid_date, "date", t_string); + fatalError(invalid_date, t_string); } @@ -186,7 +186,7 @@ int date_main(int argc, char **argv) case 'u': utc = 1; if (putenv("TZ=UTC0") != 0) - fatalError(memory_exhausted, "date"); + fatalError(memory_exhausted); break; case 'd': use_arg = 1; @@ -236,12 +236,12 @@ int date_main(int argc, char **argv) /* Correct any day of week and day of year etc fields */ tm = mktime(&tm_time); if (tm < 0) - fatalError(invalid_date, "date", date_str); + fatalError(invalid_date, date_str); /* if setting time, set it */ if (set_time) { if (stime(&tm) < 0) { - fatalError("date: can't set date.\n"); + fatalError("can't set date.\n"); } } } diff --git a/editors/sed.c b/editors/sed.c index b6bfcdb68..9e4a002d8 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -196,7 +196,7 @@ static int get_address(const char *str, int *line, regex_t **regex) else if (my_str[idx] == '/') { idx = index_of_next_unescaped_slash(idx, my_str); if (idx == -1) - fatalError("sed: unterminated match expression\n"); + fatalError("unterminated match expression\n"); my_str[idx] = '\0'; *regex = (regex_t *)xmalloc(sizeof(regex_t)); if (bb_regcomp(*regex, my_str+1, REG_NEWLINE) != 0) { @@ -243,9 +243,9 @@ static void parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) /* last part (mandatory) will be a command */ if (cmdstr[idx] == '\0') - fatalError("sed: missing command\n"); + fatalError("missing command\n"); if (!strchr("pds", cmdstr[idx])) /* <-- XXX add new commands here */ - fatalError("sed: invalid command\n"); + fatalError("invalid command\n"); sed_cmd->cmd = cmdstr[idx]; /* special-case handling for 's' */ if (sed_cmd->cmd == 's') { @@ -259,20 +259,20 @@ static void parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) /* verify that we have an 's' followed by a 'slash' */ if (cmdstr[++idx] != '/') - fatalError("sed: bad format in substitution expression\n"); + fatalError("bad format in substitution expression\n"); /* save the match string */ oldidx = idx+1; idx = index_of_next_unescaped_slash(idx, cmdstr); if (idx == -1) - fatalError("sed: bad format in substitution expression\n"); + fatalError("bad format in substitution expression\n"); match = strdup_substr(cmdstr, oldidx, idx); /* save the replacement string */ oldidx = idx+1; idx = index_of_next_unescaped_slash(idx, cmdstr); if (idx == -1) - fatalError("sed: bad format in substitution expression\n"); + fatalError("bad format in substitution expression\n"); sed_cmd->replace = strdup_substr(cmdstr, oldidx, idx); /* process the flags */ @@ -285,7 +285,7 @@ static void parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) cflags |= REG_ICASE; break; default: - fatalError("sed: bad option in substitution expression\n"); + fatalError("bad option in substitution expression\n"); } } diff --git a/freeramdisk.c b/freeramdisk.c index a6fa2431f..927c16946 100644 --- a/freeramdisk.c +++ b/freeramdisk.c @@ -52,10 +52,10 @@ freeramdisk_main(int argc, char **argv) } if ((f = open(argv[1], O_RDWR)) == -1) { - fatalError( "freeramdisk: cannot open %s: %s\n", argv[1], strerror(errno)); + fatalError( "cannot open %s: %s\n", argv[1], strerror(errno)); } if (ioctl(f, BLKFLSBUF) < 0) { - fatalError( "freeramdisk: failed ioctl on %s: %s\n", argv[1], strerror(errno)); + fatalError( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); } /* Don't bother closing. Exit does * that, so we can save a few bytes */ diff --git a/gunzip.c b/gunzip.c index e6b8202c8..89e46a686 100644 --- a/gunzip.c +++ b/gunzip.c @@ -212,7 +212,7 @@ extern int method; /* compression method */ # define DECLARE(type, array, size) type * array # define ALLOC(type, array, size) { \ array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ - if (array == NULL) errorMsg(memory_exhausted, "gunzip"); \ + if (array == NULL) errorMsg(memory_exhausted); \ } # define FREE(array) {if (array != NULL) free(array), array=NULL;} #else @@ -930,7 +930,7 @@ int in, out; /* input and output file descriptors */ int res = inflate(); if (res == 3) { - errorMsg(memory_exhausted, "gunzip"); + errorMsg(memory_exhausted); } else if (res != 0) { errorMsg("invalid compressed data--format violated"); } diff --git a/gzip.c b/gzip.c index 9248cfecd..8bc67d9c6 100644 --- a/gzip.c +++ b/gzip.c @@ -127,7 +127,7 @@ extern int method; /* compression method */ # define DECLARE(type, array, size) type * array # define ALLOC(type, array, size) { \ array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ - if (array == NULL) errorMsg(memory_exhausted, "gzip"); \ + if (array == NULL) errorMsg(memory_exhausted); \ } # define FREE(array) {if (array != NULL) free(array), array=NULL;} #else @@ -3251,7 +3251,7 @@ char *env; /* name of environment variable */ nargv = (char **) calloc(*argcp + 1, sizeof(char *)); if (nargv == NULL) - errorMsg(memory_exhausted, "gzip"); + errorMsg(memory_exhausted); oargv = *argvp; *argvp = nargv; diff --git a/lash.c b/lash.c index 60d67e9e8..4620ae3ce 100644 --- a/lash.c +++ b/lash.c @@ -850,7 +850,7 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) #endif execvp(newJob.progs[i].argv[0], newJob.progs[i].argv); - fatalError("sh: %s: %s\n", newJob.progs[i].argv[0], + fatalError("%s: %s\n", newJob.progs[i].argv[0], strerror(errno)); } @@ -1043,7 +1043,7 @@ int shell_main(int argc, char **argv) /* initialize the cwd */ cwd = (char *) calloc(BUFSIZ, sizeof(char)); if (cwd == 0) { - fatalError("sh: out of memory\n"); + fatalError("out of memory\n"); } getcwd(cwd, sizeof(char)*BUFSIZ); @@ -1065,7 +1065,7 @@ int shell_main(int argc, char **argv) int i; local_pending_command = (char *) calloc(BUFSIZ, sizeof(char)); if (local_pending_command == 0) { - fatalError("sh: out of memory\n"); + fatalError("out of memory\n"); } for(i=2; i @@ -336,7 +336,7 @@ static void sendping(int ign) (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); if (i < 0) - fatalError("ping: sendto: %s\n", strerror(errno)); + fatalError("sendto: %s\n", strerror(errno)); else if (i != sizeof(packet)) fatalError("ping wrote %d chars; %d expected\n", i, (int)sizeof(packet)); diff --git a/ping.c b/ping.c index c560a7ce2..0359abbd1 100644 --- a/ping.c +++ b/ping.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping.c,v 1.19 2000/07/09 06:59:58 andersen Exp $ + * $Id: ping.c,v 1.20 2000/07/12 17:02:35 kraai Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -336,7 +336,7 @@ static void sendping(int ign) (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); if (i < 0) - fatalError("ping: sendto: %s\n", strerror(errno)); + fatalError("sendto: %s\n", strerror(errno)); else if (i != sizeof(packet)) fatalError("ping wrote %d chars; %d expected\n", i, (int)sizeof(packet)); diff --git a/pwd.c b/pwd.c index 87553b3de..f0c923b7b 100644 --- a/pwd.c +++ b/pwd.c @@ -31,7 +31,7 @@ extern int pwd_main(int argc, char **argv) char buf[BUFSIZ + 1]; if (getcwd(buf, sizeof(buf)) == NULL) - fatalError("pwd: %s\n", strerror(errno)); + fatalError("%s\n", strerror(errno)); printf("%s\n", buf); return(TRUE); diff --git a/sed.c b/sed.c index b6bfcdb68..9e4a002d8 100644 --- a/sed.c +++ b/sed.c @@ -196,7 +196,7 @@ static int get_address(const char *str, int *line, regex_t **regex) else if (my_str[idx] == '/') { idx = index_of_next_unescaped_slash(idx, my_str); if (idx == -1) - fatalError("sed: unterminated match expression\n"); + fatalError("unterminated match expression\n"); my_str[idx] = '\0'; *regex = (regex_t *)xmalloc(sizeof(regex_t)); if (bb_regcomp(*regex, my_str+1, REG_NEWLINE) != 0) { @@ -243,9 +243,9 @@ static void parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) /* last part (mandatory) will be a command */ if (cmdstr[idx] == '\0') - fatalError("sed: missing command\n"); + fatalError("missing command\n"); if (!strchr("pds", cmdstr[idx])) /* <-- XXX add new commands here */ - fatalError("sed: invalid command\n"); + fatalError("invalid command\n"); sed_cmd->cmd = cmdstr[idx]; /* special-case handling for 's' */ if (sed_cmd->cmd == 's') { @@ -259,20 +259,20 @@ static void parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) /* verify that we have an 's' followed by a 'slash' */ if (cmdstr[++idx] != '/') - fatalError("sed: bad format in substitution expression\n"); + fatalError("bad format in substitution expression\n"); /* save the match string */ oldidx = idx+1; idx = index_of_next_unescaped_slash(idx, cmdstr); if (idx == -1) - fatalError("sed: bad format in substitution expression\n"); + fatalError("bad format in substitution expression\n"); match = strdup_substr(cmdstr, oldidx, idx); /* save the replacement string */ oldidx = idx+1; idx = index_of_next_unescaped_slash(idx, cmdstr); if (idx == -1) - fatalError("sed: bad format in substitution expression\n"); + fatalError("bad format in substitution expression\n"); sed_cmd->replace = strdup_substr(cmdstr, oldidx, idx); /* process the flags */ @@ -285,7 +285,7 @@ static void parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) cflags |= REG_ICASE; break; default: - fatalError("sed: bad option in substitution expression\n"); + fatalError("bad option in substitution expression\n"); } } diff --git a/sh.c b/sh.c index 60d67e9e8..4620ae3ce 100644 --- a/sh.c +++ b/sh.c @@ -850,7 +850,7 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) #endif execvp(newJob.progs[i].argv[0], newJob.progs[i].argv); - fatalError("sh: %s: %s\n", newJob.progs[i].argv[0], + fatalError("%s: %s\n", newJob.progs[i].argv[0], strerror(errno)); } @@ -1043,7 +1043,7 @@ int shell_main(int argc, char **argv) /* initialize the cwd */ cwd = (char *) calloc(BUFSIZ, sizeof(char)); if (cwd == 0) { - fatalError("sh: out of memory\n"); + fatalError("out of memory\n"); } getcwd(cwd, sizeof(char)*BUFSIZ); @@ -1065,7 +1065,7 @@ int shell_main(int argc, char **argv) int i; local_pending_command = (char *) calloc(BUFSIZ, sizeof(char)); if (local_pending_command == 0) { - fatalError("sh: out of memory\n"); + fatalError("out of memory\n"); } for(i=2; itarFd, buffer, readSize)) <= 0 ) { /* Tarball seems to have a problem */ - errorMsg("tar: Unexpected EOF in archive\n"); + errorMsg("Unexpected EOF in archive\n"); return( FALSE); } if ( readSize < writeSize ) @@ -368,7 +368,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag) return( TRUE); if (createPath(header->name, header->mode) != TRUE) { - errorMsg("tar: %s: Cannot mkdir: %s\n", + errorMsg("%s: Cannot mkdir: %s\n", header->name, strerror(errno)); return( FALSE); } @@ -388,7 +388,7 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag) return( TRUE); if (link(header->linkname, header->name) < 0) { - errorMsg("tar: %s: Cannot create hard link to '%s': %s\n", + errorMsg("%s: Cannot create hard link to '%s': %s\n", header->name, header->linkname, strerror(errno)); return( FALSE); } @@ -406,7 +406,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag) #ifdef S_ISLNK if (symlink(header->linkname, header->name) < 0) { - errorMsg("tar: %s: Cannot create symlink to '%s': %s\n", + errorMsg("%s: Cannot create symlink to '%s': %s\n", header->name, header->linkname, strerror(errno)); return( FALSE); } @@ -421,7 +421,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag) /* Do not change permissions or date on symlink, * since it changes the pointed to file instead. duh. */ #else - errorMsg("tar: %s: Cannot create symlink to '%s': %s\n", + errorMsg("%s: Cannot create symlink to '%s': %s\n", header->name, header->linkname, "symlinks not supported"); #endif @@ -436,13 +436,13 @@ 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) { - errorMsg("tar: %s: Cannot mknod: %s\n", + errorMsg("%s: Cannot mknod: %s\n", header->name, strerror(errno)); return( FALSE); } } else if (S_ISFIFO(header->mode)) { if (mkfifo(header->name, header->mode) < 0) { - errorMsg("tar: %s: Cannot mkfifo: %s\n", + errorMsg("%s: Cannot mkfifo: %s\n", header->name, strerror(errno)); return( FALSE); } @@ -490,7 +490,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header) ++*(header->name); if (alreadyWarned == FALSE) { - errorMsg("tar: Removing leading '/' from member names\n"); + errorMsg("Removing leading '/' from member names\n"); alreadyWarned = TRUE; } } @@ -695,7 +695,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag, return ( FALSE); } else if (errorFlag==TRUE) { - errorMsg( "tar: Error exit delayed from previous errors\n"); + errorMsg( "Error exit delayed from previous errors\n"); return( FALSE); } else return( status); @@ -705,7 +705,7 @@ endgame: close( tarFd); if ( *(header.name) == '\0' ) { if (errorFlag==TRUE) - errorMsg( "tar: Error exit delayed from previous errors\n"); + errorMsg( "Error exit delayed from previous errors\n"); else return( TRUE); } @@ -782,7 +782,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st if (*fileName=='/') { static int alreadyWarned=FALSE; if (alreadyWarned==FALSE) { - errorMsg("tar: Removing leading '/' from member names\n"); + errorMsg("Removing leading '/' from member names\n"); alreadyWarned=TRUE; } strncpy(header.name, fileName+1, sizeof(header.name)); @@ -854,7 +854,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st header.typeflag = REGTYPE; putOctal(header.size, sizeof(header.size), statbuf->st_size); } else { - errorMsg("tar: %s: Unknown file type\n", fileName); + errorMsg("%s: Unknown file type\n", fileName); return ( FALSE); } @@ -892,7 +892,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* /* It is against the rules to archive a socket */ if (S_ISSOCK(statbuf->st_mode)) { - errorMsg("tar: %s: socket ignored\n", fileName); + errorMsg("%s: socket ignored\n", fileName); return( TRUE); } @@ -901,7 +901,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* * the new tarball */ if (tbInfo->statBuf.st_dev == statbuf->st_dev && tbInfo->statBuf.st_ino == statbuf->st_ino) { - errorMsg("tar: %s: file is the archive; skipping\n", fileName); + errorMsg("%s: file is the archive; skipping\n", fileName); return( TRUE); } @@ -917,7 +917,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* /* open the file we want to archive, and make sure all is well */ if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { - errorMsg("tar: %s: Cannot open: %s\n", fileName, strerror(errno)); + errorMsg("%s: Cannot open: %s\n", fileName, strerror(errno)); return( FALSE); } @@ -955,7 +955,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag, /* Make sure there is at least one file to tar up. */ if (argc <= 0) - fatalError("tar: Cowardly refusing to create an empty archive\n"); + fatalError("Cowardly refusing to create an empty archive\n"); /* Open the tar file for writing. */ if (tostdoutFlag == TRUE) @@ -963,7 +963,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag, else tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (tbInfo.tarFd < 0) { - errorMsg( "tar: Error opening '%s': %s\n", tarName, strerror(errno)); + errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno)); return ( FALSE); } tbInfo.excludeList=excludeList; @@ -997,7 +997,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag, /* Hang up the tools, close up shop, head home */ close(tarFd); if (errorFlag == TRUE) { - errorMsg("tar: Error exit delayed from previous errors\n"); + errorMsg("Error exit delayed from previous errors\n"); return(FALSE); } return( TRUE); diff --git a/touch.c b/touch.c index f52bb0284..ac275423c 100644 --- a/touch.c +++ b/touch.c @@ -70,12 +70,12 @@ extern int touch_main(int argc, char **argv) if (create == FALSE && errno == ENOENT) exit(TRUE); else { - fatalError("touch: %s", strerror(errno)); + fatalError("%s", strerror(errno)); } } close(fd); if (utime(*argv, NULL)) { - fatalError("touch: %s", strerror(errno)); + fatalError("%s", strerror(errno)); } argc--; argv++; diff --git a/tr.c b/tr.c index 5a8116db0..293bbce6b 100644 --- a/tr.c +++ b/tr.c @@ -189,7 +189,7 @@ extern int tr_main(int argc, char **argv) complement(input); if (argv[index] != NULL) { if (*argv[index] == '\0') - fatalError("tr: STRING2 cannot be empty\n"); + fatalError("STRING2 cannot be empty\n"); expand(argv[index], output); map(input, output); } diff --git a/umount.c b/umount.c index fc9b466c6..59dcb6651 100644 --- a/umount.c +++ b/umount.c @@ -201,7 +201,7 @@ static int do_umount(const char *name, int useMtab) if (status != 0 && doForce == TRUE) { status = umount2(blockDevice, MNT_FORCE); if (status != 0) { - fatalError("umount: forced umount of %s failed!\n", blockDevice); + fatalError("forced umount of %s failed!\n", blockDevice); } } #endif diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c index a6fa2431f..927c16946 100644 --- a/util-linux/freeramdisk.c +++ b/util-linux/freeramdisk.c @@ -52,10 +52,10 @@ freeramdisk_main(int argc, char **argv) } if ((f = open(argv[1], O_RDWR)) == -1) { - fatalError( "freeramdisk: cannot open %s: %s\n", argv[1], strerror(errno)); + fatalError( "cannot open %s: %s\n", argv[1], strerror(errno)); } if (ioctl(f, BLKFLSBUF) < 0) { - fatalError( "freeramdisk: failed ioctl on %s: %s\n", argv[1], strerror(errno)); + fatalError( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); } /* 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 66599a618..900ab30a7 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -193,7 +193,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, #endif if (errno == EPERM) { - fatalError("mount: permission denied. Are you root?\n"); + fatalError("permission denied. Are you root?\n"); } return (FALSE); diff --git a/util-linux/umount.c b/util-linux/umount.c index fc9b466c6..59dcb6651 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c @@ -201,7 +201,7 @@ static int do_umount(const char *name, int useMtab) if (status != 0 && doForce == TRUE) { status = umount2(blockDevice, MNT_FORCE); if (status != 0) { - fatalError("umount: forced umount of %s failed!\n", blockDevice); + fatalError("forced umount of %s failed!\n", blockDevice); } } #endif diff --git a/utility.c b/utility.c index 0f78f287f..6d1e1d4bb 100644 --- a/utility.c +++ b/utility.c @@ -94,6 +94,7 @@ extern void errorMsg(const char *s, ...) va_start(p, s); fflush(stdout); + fprintf(stderr, "%s: ", applet_name); vfprintf(stderr, s, p); va_end(p); fflush(stderr); @@ -105,6 +106,7 @@ extern void fatalError(const char *s, ...) va_start(p, s); fflush(stdout); + fprintf(stderr, "%s: ", applet_name); vfprintf(stderr, s, p); va_end(p); fflush(stderr); @@ -1360,7 +1362,7 @@ extern pid_t* findPidByName( char* pidName) && (strlen(pidName) == strlen(info.command_line))) { pidList=realloc( pidList, sizeof(pid_t) * (j+2)); if (pidList==NULL) - fatalError(memory_exhausted, ""); + fatalError(memory_exhausted); pidList[j++]=info.pid; } } @@ -1433,7 +1435,7 @@ extern pid_t* findPidByName( char* pidName) && (strlen(pidName) == strlen(p))) { pidList=realloc( pidList, sizeof(pid_t) * (i+2)); if (pidList==NULL) - fatalError(memory_exhausted, ""); + fatalError(memory_exhausted); pidList[i++]=strtol(next->d_name, NULL, 0); } } @@ -1450,7 +1452,7 @@ extern void *xmalloc(size_t size) void *cp = malloc(size); if (cp == NULL) - fatalError(memory_exhausted, ""); + fatalError(memory_exhausted); return cp; } @@ -1464,7 +1466,7 @@ extern char * xstrdup (const char *s) { t = strdup (s); if (t == NULL) - fatalError(memory_exhausted, ""); + fatalError(memory_exhausted); return t; } diff --git a/uudecode.c b/uudecode.c index ac33762b0..12a71a573 100644 --- a/uudecode.c +++ b/uudecode.c @@ -286,7 +286,7 @@ static int decode (const char *inname, && (freopen (outname, "w", stdout) == NULL || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) )) { - errorMsg("uudeoce %s: %s %s\n", outname, inname, strerror(errno)); /* */ + errorMsg("%s: %s %s\n", outname, inname, strerror(errno)); /* */ return FALSE; } @@ -340,7 +340,7 @@ int uudecode_main (int argc, if (decode (argv[optind], outname) != 0) exit_status = FALSE; } else { - errorMsg("uudecode: %s: %s\n", argv[optind], strerror(errno)); + errorMsg("%s: %s\n", argv[optind], strerror(errno)); exit_status = FALSE; } optind++; diff --git a/uuencode.c b/uuencode.c index e4fc1a0bc..e107a01e7 100644 --- a/uuencode.c +++ b/uuencode.c @@ -217,7 +217,7 @@ int uuencode_main (int argc, case 2: /* Optional first argument is input file. */ if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { - errorMsg("uuencode: %s: %s\n", argv[optind], strerror(errno)); + errorMsg("%s: %s\n", argv[optind], strerror(errno)); exit FALSE; } mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);