From d537a95fdbc0b4a5f38edea8593b4c085fdd7fcb Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Fri, 14 Jul 2000 01:51:25 +0000 Subject: [PATCH] Use errorMsg rather than fprintf. --- applets/busybox.c | 5 ++- archival/gunzip.c | 7 ++-- busybox.c | 5 ++- chmod_chown_chgrp.c | 6 +-- console-tools/deallocvt.c | 8 ++-- console-tools/dumpkmap.c | 4 +- console-tools/loadacm.c | 18 ++++----- console-tools/loadfont.c | 18 ++++----- console-tools/loadkmap.c | 10 ++--- coreutils/cut.c | 24 ++++++------ coreutils/dd.c | 8 ++-- coreutils/df.c | 2 +- coreutils/du.c | 6 +-- coreutils/head.c | 7 ++-- coreutils/ln.c | 3 +- coreutils/logname.c | 2 +- coreutils/mkdir.c | 6 +-- coreutils/rmdir.c | 2 +- coreutils/sort.c | 4 +- coreutils/tail.c | 5 +-- coreutils/tee.c | 4 +- coreutils/uniq.c | 6 +-- coreutils/whoami.c | 3 +- cp_mv.c | 39 +++++++++----------- cut.c | 24 ++++++------ dc.c | 6 +-- dd.c | 8 ++-- deallocvt.c | 8 ++-- df.c | 2 +- du.c | 6 +-- dumpkmap.c | 4 +- editors/sed.c | 6 +-- fbset.c | 2 +- findutils/grep.c | 2 +- fsck_minix.c | 2 +- grep.c | 2 +- gunzip.c | 7 ++-- head.c | 7 ++-- hostname.c | 5 +-- insmod.c | 77 +++++++++++++++++---------------------- lash.c | 20 +++++----- ln.c | 3 +- loadacm.c | 18 ++++----- loadfont.c | 18 ++++----- loadkmap.c | 10 ++--- logger.c | 6 +-- logname.c | 2 +- messages.c | 10 ++--- miscutils/dc.c | 6 +-- miscutils/mt.c | 2 +- mkdir.c | 6 +-- mkfs_minix.c | 6 +-- mkswap.c | 33 +++++++---------- modutils/insmod.c | 77 +++++++++++++++++---------------------- mount.c | 8 ++-- mt.c | 2 +- networking/hostname.c | 5 +-- networking/ping.c | 16 ++++---- nfsmount.c | 34 ++++++----------- ping.c | 16 ++++---- procps/ps.c | 6 +-- ps.c | 6 +-- rmdir.c | 2 +- sed.c | 6 +-- sh.c | 20 +++++----- shell/lash.c | 20 +++++----- sort.c | 4 +- sysklogd/logger.c | 6 +-- tail.c | 5 +-- tee.c | 4 +- umount.c | 8 ++-- uniq.c | 6 +-- util-linux/fbset.c | 2 +- util-linux/fsck_minix.c | 2 +- util-linux/mkfs_minix.c | 6 +-- util-linux/mkswap.c | 33 +++++++---------- util-linux/mount.c | 8 ++-- util-linux/nfsmount.c | 34 ++++++----------- util-linux/umount.c | 8 ++-- utility.c | 7 ++-- whoami.c | 3 +- 81 files changed, 391 insertions(+), 473 deletions(-) diff --git a/applets/busybox.c b/applets/busybox.c index a355cdd1d..15f8e3f24 100644 --- a/applets/busybox.c +++ b/applets/busybox.c @@ -392,7 +392,7 @@ static char *busybox_fullpath() if (len != -1) { path[len] = 0; } else { - fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno)); + errorMsg("%s: %s\n", proc, strerror(errno)); return NULL; } return strdup(path); @@ -422,7 +422,7 @@ static int install_links(const char *busybox, int use_symbolic_links) puts(command); #endif if (rc) { - fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno)); + errorMsg("%s: %s\n", command, strerror(errno)); } } return rc; @@ -438,6 +438,7 @@ int main(int argc, char **argv) { char *s; const struct BB_applet *a = applets; + applet_name = "busybox"; #ifdef BB_FEATURE_INSTALLER /* diff --git a/archival/gunzip.c b/archival/gunzip.c index 89e46a686..de68bd19b 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c @@ -659,7 +659,7 @@ int gunzip_main(int argc, char **argv) if (*argv == '\0') usage(gunzip_usage); if (strlen(*argv) > MAX_PATH_LEN) { - fprintf(stderr, name_too_long, "gunzip"); + errorMsg(name_too_long); exit(WARNING); } strcpy(ifname, *argv); @@ -698,7 +698,7 @@ int gunzip_main(int argc, char **argv) /* And get to work */ if (strlen(ifname) > MAX_PATH_LEN - 4) { - fprintf(stderr, name_too_long, "gunzip"); + errorMsg(name_too_long); exit(WARNING); } strcpy(ofname, ifname); @@ -780,8 +780,7 @@ int in; /* input file descriptor */ method = (int) get_byte(); if (method != DEFLATED) { - fprintf(stderr, - "unknown method %d -- get newer version of gzip\n", + errorMsg("unknown method %d -- get newer version of gzip\n", method); exit_code = ERROR; return -1; diff --git a/busybox.c b/busybox.c index a355cdd1d..15f8e3f24 100644 --- a/busybox.c +++ b/busybox.c @@ -392,7 +392,7 @@ static char *busybox_fullpath() if (len != -1) { path[len] = 0; } else { - fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno)); + errorMsg("%s: %s\n", proc, strerror(errno)); return NULL; } return strdup(path); @@ -422,7 +422,7 @@ static int install_links(const char *busybox, int use_symbolic_links) puts(command); #endif if (rc) { - fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno)); + errorMsg("%s: %s\n", command, strerror(errno)); } } return rc; @@ -438,6 +438,7 @@ int main(int argc, char **argv) { char *s; const struct BB_applet *a = applets; + applet_name = "busybox"; #ifdef BB_FEATURE_INSTALLER /* diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index 98b292568..cf6a50895 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c @@ -123,7 +123,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) recursiveFlag = TRUE; break; default: - fprintf(stderr, invalid_option, applet_name, **argv); + errorMsg(invalid_option, **argv); usage(appUsage); } } @@ -131,7 +131,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) } if (argc == 0 || *argv == NULL) { - fprintf(stderr, too_few_args, applet_name); + errorMsg(too_few_args); usage(appUsage); } @@ -176,7 +176,7 @@ int chmod_chown_chgrp_main(int argc, char **argv) /* Ok, ready to do the deed now */ if (argc <= 1) { - fatalError( "too few arguments\n"); + fatalError(too_few_args); } while (argc-- > 1) { if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE, diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c index 53d4d9a7c..906f3a9fa 100644 --- a/console-tools/deallocvt.c +++ b/console-tools/deallocvt.c @@ -39,14 +39,12 @@ int deallocvt_main(int argc, char *argv[]) for (i = 1; i < argc; i++) { num = atoi(argv[i]); if (num == 0) - fprintf(stderr, "%s: 0: illegal VT number\n", applet_name); + errorMsg("0: illegal VT number\n"); else if (num == 1) - fprintf(stderr, "%s: VT 1 cannot be deallocated\n", - applet_name); + errorMsg("VT 1 cannot be deallocated\n"); else if (ioctl(fd, VT_DISALLOCATE, num)) { perror("VT_DISALLOCATE"); - fprintf(stderr, "%s: could not deallocate console %d\n", - applet_name, num); + errorMsg("could not deallocate console %d\n", num); exit( FALSE); } } diff --git a/console-tools/dumpkmap.c b/console-tools/dumpkmap.c index a497a07d1..f18050529 100644 --- a/console-tools/dumpkmap.c +++ b/console-tools/dumpkmap.c @@ -58,7 +58,7 @@ int dumpkmap_main(int argc, char **argv) fd = open("/dev/tty0", O_RDWR); if (fd < 0) { - fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); + errorMsg("Error opening /dev/tty0: %s\n", strerror(errno)); return 1; } @@ -86,7 +86,7 @@ int dumpkmap_main(int argc, char **argv) ke.kb_table = i; if (ioctl(fd, KDGKBENT, &ke) < 0) { - fprintf(stderr, "ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value); + errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value); } else { write(1,&ke.kb_value,2); diff --git a/console-tools/loadacm.c b/console-tools/loadacm.c index a64c691d2..9eebf3bb5 100644 --- a/console-tools/loadacm.c +++ b/console-tools/loadacm.c @@ -46,12 +46,12 @@ int loadacm_main(int argc, char **argv) fd = open("/dev/tty", O_RDWR); if (fd < 0) { - fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno)); + errorMsg("Error opening /dev/tty1: %s\n", strerror(errno)); return( FALSE); } if (screen_map_load(fd, stdin)) { - fprintf(stderr, "Error loading acm: %s\n", strerror(errno)); + errorMsg("Error loading acm: %s\n", strerror(errno)); return( FALSE); } @@ -79,8 +79,7 @@ int screen_map_load(int fd, FILE * fp) if (parse_failed) { if (-1 == fseek(fp, 0, SEEK_SET)) { if (errno == ESPIPE) - fprintf(stderr, - "16bit screen-map MUST be a regular file.\n"), + errorMsg("16bit screen-map MUST be a regular file.\n"), exit(1); else perror("fseek failed reading binary 16bit screen-map"), @@ -91,7 +90,7 @@ int screen_map_load(int fd, FILE * fp) perror("Cannot read [new] map from file"), exit(1); #if 0 else - fprintf(stderr, "Input screen-map is binary.\n"); + errorMsg("Input screen-map is binary.\n"); #endif } @@ -108,8 +107,7 @@ int screen_map_load(int fd, FILE * fp) /* rewind... */ if (-1 == fseek(fp, 0, SEEK_SET)) { if (errno == ESPIPE) - fprintf(stderr, - "Assuming 8bit screen-map - MUST be a regular file.\n"), + errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"), exit(1); else perror("fseek failed assuming 8bit screen-map"), exit(1); @@ -122,7 +120,7 @@ int screen_map_load(int fd, FILE * fp) if (-1 == fseek(fp, 0, SEEK_SET)) { if (errno == ESPIPE) /* should not - it succedeed above */ - fprintf(stderr, "fseek() returned ESPIPE !\n"), + errorMsg("fseek() returned ESPIPE !\n"), exit(1); else perror("fseek for binary 8bit screen-map"), exit(1); @@ -132,7 +130,7 @@ int screen_map_load(int fd, FILE * fp) perror("Cannot read [old] map from file"), exit(1); #if 0 else - fprintf(stderr, "Input screen-map is binary.\n"); + errorMsg("Input screen-map is binary.\n"); #endif } @@ -141,7 +139,7 @@ int screen_map_load(int fd, FILE * fp) else return 0; } - fprintf(stderr, "Error parsing symbolic map\n"); + errorMsg("Error parsing symbolic map\n"); return(1); } diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c index 7eaf40e82..b3f9f4f11 100644 --- a/console-tools/loadfont.c +++ b/console-tools/loadfont.c @@ -56,7 +56,7 @@ extern int loadfont_main(int argc, char **argv) fd = open("/dev/tty0", O_RDWR); if (fd < 0) { - fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); + errorMsg("Error opening /dev/tty0: %s\n", strerror(errno)); return( FALSE); } loadnewfont(fd); @@ -72,7 +72,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize) memset(buf, 0, sizeof(buf)); if (unit < 1 || unit > 32) { - fprintf(stderr, "Bad character size %d\n", unit); + errorMsg("Bad character size %d\n", unit); exit(1); } @@ -112,7 +112,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) up = (struct unipair *) malloc(maxct * sizeof(struct unipair)); if (!up) { - fprintf(stderr, "Out of memory?\n"); + errorMsg("Out of memory?\n"); exit(1); } for (glyph = 0; glyph < fontsize; glyph++) { @@ -137,8 +137,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) if (ioctl(fd, PIO_UNIMAPCLR, &advice)) { #ifdef ENOIOCTLCMD if (errno == ENOIOCTLCMD) { - fprintf(stderr, "It seems this kernel is older than 1.1.92\n"); - fprintf(stderr, "No Unicode mapping table loaded.\n"); + errorMsg("It seems this kernel is older than 1.1.92\n"); + errorMsg("No Unicode mapping table loaded.\n"); } else #endif perror("PIO_UNIMAPCLR"); @@ -198,13 +198,13 @@ static void loadnewfont(int fd) goto no_psf; if (psfhdr.mode > PSF_MAXMODE) { - fprintf(stderr, "Unsupported psf file mode\n"); + errorMsg("Unsupported psf file mode\n"); exit(1); } fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); #if !defined( PIO_FONTX ) || defined( __sparc__ ) if (fontsize != 256) { - fprintf(stderr, "Only fontsize 256 supported\n"); + errorMsg("Only fontsize 256 supported\n"); exit(1); } #endif @@ -214,7 +214,7 @@ static void loadnewfont(int fd) head = head0 + fontsize * unit; if (head > inputlth || (!hastable && head != inputlth)) { - fprintf(stderr, "Input file: bad length\n"); + errorMsg("Input file: bad length\n"); exit(1); } do_loadfont(fd, inbuf + head0, unit, fontsize); @@ -231,7 +231,7 @@ static void loadnewfont(int fd) } else { /* bare font */ if (inputlth & 0377) { - fprintf(stderr, "Bad input file size\n"); + errorMsg("Bad input file size\n"); exit(1); } offset = 0; diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c index c2e4c94ed..72247a6e4 100644 --- a/console-tools/loadkmap.c +++ b/console-tools/loadkmap.c @@ -59,25 +59,25 @@ int loadkmap_main(int argc, char **argv) fd = open("/dev/tty0", O_RDWR); if (fd < 0) { - fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); + errorMsg("Error opening /dev/tty0: %s\n", strerror(errno)); exit(FALSE); } read(0, buff, 7); if (0 != strncmp(buff, magic, 7)) { - fprintf(stderr, "This is not a valid binary keymap.\n"); + errorMsg("This is not a valid binary keymap.\n"); exit(FALSE); } if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) { - fprintf(stderr, "Error reading keymap flags: %s\n", + errorMsg("Error reading keymap flags: %s\n", strerror(errno)); exit(FALSE); } ibuff = (u_short *) malloc(ibuffsz); if (!ibuff) { - fprintf(stderr, "Out of memory.\n"); + errorMsg("Out of memory.\n"); exit(FALSE); } @@ -87,7 +87,7 @@ int loadkmap_main(int argc, char **argv) while (pos < ibuffsz) { if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0) { - fprintf(stderr, "Error reading keymap: %s\n", + errorMsg("Error reading keymap: %s\n", strerror(errno)); exit(FALSE); } diff --git a/coreutils/cut.c b/coreutils/cut.c index 820074e60..783d526a5 100644 --- a/coreutils/cut.c +++ b/coreutils/cut.c @@ -84,13 +84,13 @@ void cut(void); void warn(int warn_number, char *option) { static char *warn_msg[] = { - "%s: Option -%s allowed only with -f\n", - "%s: -%s overrides earlier option\n", - "%s: -%s not allowed in current mode\n", - "%s: Cannot open %s\n" + "Option -%s allowed only with -f\n", + "-%s overrides earlier option\n", + "-%s not allowed in current mode\n", + "Cannot open %s\n" }; - fprintf(stderr, warn_msg[warn_number], applet_name, option); + errorMsg(warn_msg[warn_number], option); exit_status = warn_number + 1; } @@ -98,15 +98,15 @@ void warn(int warn_number, char *option) void cuterror(int err) { static char *err_mes[] = { - "%s: syntax error\n", - "%s: position must be >0\n", - "%s: line longer than BUFSIZ\n", - "%s: range must not decrease from left to right\n", - "%s: MAX_FIELD exceeded\n", - "%s: MAX_ARGS exceeded\n" + "syntax error\n", + "position must be >0\n", + "line longer than BUFSIZ\n", + "range must not decrease from left to right\n", + "MAX_FIELD exceeded\n", + "MAX_ARGS exceeded\n" }; - fprintf(stderr, err_mes[err - 101], applet_name); + errorMsg(err_mes[err - 101]); exit(err); } diff --git a/coreutils/dd.c b/coreutils/dd.c index 5d9993d8b..6261dfef5 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c @@ -86,26 +86,26 @@ extern int dd_main(int argc, char **argv) else if (strncmp("count", *argv, 5) == 0) { count = getNum((strchr(*argv, '=')) + 1); if (count <= 0) { - fprintf(stderr, "Bad count value %s\n", *argv); + errorMsg("Bad count value %s\n", *argv); goto usage; } } else if (strncmp(*argv, "bs", 2) == 0) { blockSize = getNum((strchr(*argv, '=')) + 1); if (blockSize <= 0) { - fprintf(stderr, "Bad block size value %s\n", *argv); + errorMsg("Bad block size value %s\n", *argv); goto usage; } } else if (strncmp(*argv, "skip", 4) == 0) { skipBlocks = getNum((strchr(*argv, '=')) + 1); if (skipBlocks <= 0) { - fprintf(stderr, "Bad skip value %s\n", *argv); + errorMsg("Bad skip value %s\n", *argv); goto usage; } } else if (strncmp(*argv, "seek", 4) == 0) { seekBlocks = getNum((strchr(*argv, '=')) + 1); if (seekBlocks <= 0) { - fprintf(stderr, "Bad seek value %s\n", *argv); + errorMsg("Bad seek value %s\n", *argv); goto usage; } diff --git a/coreutils/df.c b/coreutils/df.c index ba3227f30..62226ceb8 100644 --- a/coreutils/df.c +++ b/coreutils/df.c @@ -82,7 +82,7 @@ extern int df_main(int argc, char **argv) } while (argc > 1) { if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { - fprintf(stderr, "%s: can't find mount point.\n", argv[1]); + errorMsg("%s: can't find mount point.\n", argv[1]); exit(FALSE); } status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); diff --git a/coreutils/du.c b/coreutils/du.c index b8e296ddd..b1ca95436 100644 --- a/coreutils/du.c +++ b/coreutils/du.c @@ -108,7 +108,7 @@ static long du(char *filename) } if (len + strlen(name) + 1 > BUFSIZ) { - fprintf(stderr, name_too_long, "du"); + errorMsg(name_too_long); du_depth--; return 0; } @@ -158,7 +158,7 @@ int du_main(int argc, char **argv) usage(du_usage); break; default: - fprintf(stderr, "du: invalid option -- %c\n", opt); + errorMsg("invalid option -- %c\n", opt); usage(du_usage); } } else { @@ -184,7 +184,7 @@ int du_main(int argc, char **argv) return(0); } -/* $Id: du.c,v 1.20 2000/06/19 17:25:39 andersen Exp $ */ +/* $Id: du.c,v 1.21 2000/07/14 01:51:25 kraai Exp $ */ /* Local Variables: c-file-style: "linux" diff --git a/coreutils/head.c b/coreutils/head.c index f42f4837d..b82678dc2 100644 --- a/coreutils/head.c +++ b/coreutils/head.c @@ -75,7 +75,7 @@ int head_main(int argc, char **argv) case 'h': usage(head_usage); default: - fprintf(stderr, "head: invalid option -- %c\n", opt); + errorMsg("invalid option -- %c\n", opt); usage(head_usage); } } else { @@ -95,8 +95,7 @@ int head_main(int argc, char **argv) src = fopen(argv[i], "r"); if (!src) { - fprintf(stderr, "head: %s: %s\n", argv[i], - strerror(errno)); + errorMsg("%s: %s\n", argv[i], strerror(errno)); } else { /* emulating GNU behaviour */ if (need_headers) { @@ -112,4 +111,4 @@ int head_main(int argc, char **argv) return(0); } -/* $Id: head.c,v 1.11 2000/06/19 17:25:39 andersen Exp $ */ +/* $Id: head.c,v 1.12 2000/07/14 01:51:25 kraai Exp $ */ diff --git a/coreutils/ln.c b/coreutils/ln.c index ac1f68e00..9f7774380 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c @@ -23,7 +23,6 @@ #include "internal.h" #define BB_DECLARE_EXTERN -#define bb_need_name_too_long #define bb_need_not_a_directory #include "messages.c" @@ -92,7 +91,7 @@ extern int ln_main(int argc, char **argv) linkIntoDirFlag = isDirectory(linkName, followLinks, NULL); if ((argc >= 3) && linkIntoDirFlag == FALSE) { - fprintf(stderr, not_a_directory, "ln", linkName); + errorMsg(not_a_directory, linkName); exit FALSE; } diff --git a/coreutils/logname.c b/coreutils/logname.c index 4b4483cc1..12ebfbde6 100644 --- a/coreutils/logname.c +++ b/coreutils/logname.c @@ -41,6 +41,6 @@ extern int logname_main(int argc, char **argv) puts(user); exit(TRUE); } - fprintf(stderr, "no login name\n"); + errorMsg("no login name\n"); return(FALSE); } diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index b18c949b8..f6e08cadc 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c @@ -62,7 +62,7 @@ extern int mkdir_main(int argc, char **argv) /* Find the specified modes */ mode = 0; if (parse_mode(*(++argv), &mode) == FALSE) { - fprintf(stderr, "Unknown mode: %s\n", *argv); + errorMsg("Unknown mode: %s\n", *argv); exit FALSE; } /* Set the umask for this process so it doesn't @@ -91,13 +91,13 @@ extern int mkdir_main(int argc, char **argv) char buf[BUFSIZ + 1]; if (strlen(*argv) > BUFSIZ - 1) { - fprintf(stderr, name_too_long, "mkdir"); + errorMsg(name_too_long); exit FALSE; } strcpy(buf, *argv); status = stat(buf, &statBuf); if (parentFlag == FALSE && status != -1 && errno != ENOENT) { - fprintf(stderr, "%s: File exists\n", buf); + errorMsg("%s: File exists\n", buf); exit FALSE; } if (parentFlag == TRUE) { diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c index c88f42cf5..4edb9b6b3 100644 --- a/coreutils/rmdir.c +++ b/coreutils/rmdir.c @@ -40,7 +40,7 @@ extern int rmdir_main(int argc, char **argv) while (--argc > 0) { if (rmdir(*(++argv)) == -1) { - fprintf(stderr, "%s: %s\n", applet_name, strerror(errno)); + errorMsg("%s\n", strerror(errno)); exit(FALSE); } } diff --git a/coreutils/sort.c b/coreutils/sort.c index a28122d51..c754989ea 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c @@ -263,7 +263,7 @@ int sort_main(int argc, char **argv) break; #endif default: - fprintf(stderr, "sort: invalid option -- %c\n", opt); + errorMsg("invalid option -- %c\n", opt); usage(sort_usage); } } else { @@ -304,4 +304,4 @@ int sort_main(int argc, char **argv) return(0); } -/* $Id: sort.c,v 1.18 2000/06/28 22:15:26 markw Exp $ */ +/* $Id: sort.c,v 1.19 2000/07/14 01:51:25 kraai Exp $ */ diff --git a/coreutils/tail.c b/coreutils/tail.c index 3189d204f..601f0873d 100644 --- a/coreutils/tail.c +++ b/coreutils/tail.c @@ -375,7 +375,7 @@ extern int tail_main(int argc, char **argv) usage(tail_usage); default: if ((n_units = atoi(&argv[i][1])) < 1) { - fprintf(stderr, "tail: invalid option -- %c\n", opt); + errorMsg("invalid option -- %c\n", opt); usage(tail_usage); } } @@ -386,8 +386,7 @@ extern int tail_main(int argc, char **argv) if (i + 1 < argc) { if (forever) { - fprintf(stderr, - "tail: option -f is invalid with multiple files\n"); + errorMsg("option -f is invalid with multiple files\n"); usage(tail_usage); } print_headers = 1; diff --git a/coreutils/tee.c b/coreutils/tee.c index c9b5410d3..67b42a24d 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c @@ -104,7 +104,7 @@ int tee_main(int argc, char **argv) /* init FILE pointers */ FileList = calloc(FL_MAX, sizeof(FILE*)); if (!FileList) { - fprintf(stderr, "tee: %s\n", strerror(errno)); + errorMsg("%s\n", strerror(errno)); exit(1); } FL_end = 0; @@ -133,4 +133,4 @@ int tee_main(int argc, char **argv) return(0); } -/* $Id: tee.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */ +/* $Id: tee.c,v 1.12 2000/07/14 01:51:25 kraai Exp $ */ diff --git a/coreutils/uniq.c b/coreutils/uniq.c index 64acf046a..16b257670 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c @@ -127,11 +127,11 @@ set_file_pointers(int schema, FILE ** in, FILE ** out, char **argv) break; } if (*in == NULL) { - fprintf(stderr, "uniq: %s: %s\n", argv[0], strerror(errno)); + errorMsg("%s: %s\n", argv[0], strerror(errno)); return errno; } if (*out == NULL) { - fprintf(stderr, "uniq: %s: %s\n", argv[1], strerror(errno)); + errorMsg("%s: %s\n", argv[1], strerror(errno)); return errno; } return 0; @@ -187,4 +187,4 @@ int uniq_main(int argc, char **argv) return(0); } -/* $Id: uniq.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */ +/* $Id: uniq.c,v 1.12 2000/07/14 01:51:25 kraai Exp $ */ diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 983c6725d..01dff81f9 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c @@ -43,7 +43,6 @@ extern int whoami_main(int argc, char **argv) puts(user); exit(TRUE); } - fprintf(stderr, "%s: cannot find username for UID %u\n", applet_name, - (unsigned) uid); + errorMsg("cannot find username for UID %u\n", (unsigned) uid); return(FALSE); } diff --git a/cp_mv.c b/cp_mv.c index cd061befb..6550e1c39 100644 --- a/cp_mv.c +++ b/cp_mv.c @@ -89,8 +89,7 @@ static void name_too_long__exit (void) __attribute__((noreturn)); static void name_too_long__exit (void) { - fprintf(stderr, name_too_long, applet_name); - exit(FALSE); + fatalError(name_too_long); } static void @@ -124,14 +123,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) if (srcDirFlag == TRUE) { if (recursiveFlag == FALSE) { - fprintf(stderr, omitting_directory, applet_name, baseSrcName); + errorMsg(omitting_directory, baseSrcName); return TRUE; } srcBasename = (strstr(fileName, baseSrcName) + strlen(baseSrcName)); if (destLen + strlen(srcBasename) > BUFSIZ) { - fprintf(stderr, name_too_long, applet_name); + errorMsg(name_too_long); return FALSE; } strcat(destName, srcBasename); @@ -145,8 +144,8 @@ 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) { - fprintf(stderr, "%s: rename(%s, %s): %s\n", - applet_name, fileName, destName, strerror(errno)); + errorMsg("rename(%s, %s): %s\n", fileName, destName, + strerror(errno)); goto do_copyFile; /* Try anyway... */ } else if (errno == EXDEV) @@ -158,8 +157,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) { - fprintf(stderr, "%s: link(%s, %s): %s\n", - applet_name, name, destName, strerror(errno)); + errorMsg("link(%s, %s): %s\n", name, destName, strerror(errno)); return FALSE; } return TRUE; @@ -178,11 +176,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk) if (S_ISDIR(statbuf->st_mode)) { if (rmdir(fileName) < 0) { - fprintf(stderr, "%s: rmdir(%s): %s\n", applet_name, fileName, strerror(errno)); + errorMsg("rmdir(%s): %s\n", fileName, strerror(errno)); status = FALSE; } } else if (unlink(fileName) < 0) { - fprintf(stderr, "%s: unlink(%s): %s\n", applet_name, fileName, strerror(errno)); + errorMsg("unlink(%s): %s\n", fileName, strerror(errno)); status = FALSE; } return status; @@ -236,7 +234,7 @@ extern int cp_mv_main(int argc, char **argv) if (strlen(argv[argc - 1]) > BUFSIZ) { - fprintf(stderr, name_too_long, "cp"); + errorMsg(name_too_long); goto exit_false; } strcpy(baseDestName, argv[argc - 1]); @@ -246,7 +244,7 @@ extern int cp_mv_main(int argc, char **argv) destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf); if ((argc > 3) && destDirFlag == FALSE) { - fprintf(stderr, not_a_directory, "cp", baseDestName); + errorMsg(not_a_directory, baseDestName); goto exit_false; } @@ -272,29 +270,28 @@ extern int cp_mv_main(int argc, char **argv) char *pushd, *d, *p; if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { - fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno)); + errorMsg("getcwd(): %s\n", strerror(errno)); continue; } if (chdir(baseDestName) < 0) { - fprintf(stderr, "%s: chdir(%s): %s\n", applet_name, baseSrcName, strerror(errno)); + errorMsg("chdir(%s): %s\n", baseSrcName, strerror(errno)); continue; } if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { - fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno)); + errorMsg("getcwd(): %s\n", strerror(errno)); continue; } while (!state && *d != '\0') { if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ - fprintf(stderr, "%s: stat(%s) :%s\n", applet_name, d, strerror(errno)); + errorMsg("stat(%s): %s\n", d, strerror(errno)); state = -1; continue; } if ((sb.st_ino == srcStatBuf.st_ino) && (sb.st_dev == srcStatBuf.st_dev)) { - fprintf(stderr, - "%s: Cannot %s `%s' " - "into a subdirectory of itself, `%s/%s'\n", - applet_name, applet_name, baseSrcName, baseDestName, baseSrcName); + errorMsg("Cannot %s `%s' into a subdirectory of itself, " + "`%s/%s'\n", applet_name, baseSrcName, + baseDestName, baseSrcName); state = -1; continue; } @@ -303,7 +300,7 @@ extern int cp_mv_main(int argc, char **argv) } } if (chdir(pushd) < 0) { - fprintf(stderr, "%s: chdir(%s): %s\n", applet_name, pushd, strerror(errno)); + errorMsg("chdir(%s): %s\n", pushd, strerror(errno)); free(pushd); free(d); continue; diff --git a/cut.c b/cut.c index 820074e60..783d526a5 100644 --- a/cut.c +++ b/cut.c @@ -84,13 +84,13 @@ void cut(void); void warn(int warn_number, char *option) { static char *warn_msg[] = { - "%s: Option -%s allowed only with -f\n", - "%s: -%s overrides earlier option\n", - "%s: -%s not allowed in current mode\n", - "%s: Cannot open %s\n" + "Option -%s allowed only with -f\n", + "-%s overrides earlier option\n", + "-%s not allowed in current mode\n", + "Cannot open %s\n" }; - fprintf(stderr, warn_msg[warn_number], applet_name, option); + errorMsg(warn_msg[warn_number], option); exit_status = warn_number + 1; } @@ -98,15 +98,15 @@ void warn(int warn_number, char *option) void cuterror(int err) { static char *err_mes[] = { - "%s: syntax error\n", - "%s: position must be >0\n", - "%s: line longer than BUFSIZ\n", - "%s: range must not decrease from left to right\n", - "%s: MAX_FIELD exceeded\n", - "%s: MAX_ARGS exceeded\n" + "syntax error\n", + "position must be >0\n", + "line longer than BUFSIZ\n", + "range must not decrease from left to right\n", + "MAX_FIELD exceeded\n", + "MAX_ARGS exceeded\n" }; - fprintf(stderr, err_mes[err - 101], applet_name); + errorMsg(err_mes[err - 101]); exit(err); } diff --git a/dc.c b/dc.c index 5bf3bc984..7b13cb943 100644 --- a/dc.c +++ b/dc.c @@ -22,7 +22,7 @@ static unsigned int pointer; static void push(double a) { if (pointer >= (sizeof(stack) / sizeof(*stack))) { - fprintf(stderr, "dc: stack overflow\n"); + errorMsg("stack overflow\n"); exit(-1); } else stack[pointer++] = a; @@ -31,7 +31,7 @@ static void push(double a) static double pop() { if (pointer == 0) { - fprintf(stderr, "dc: stack underflow\n"); + errorMsg("stack underflow\n"); exit(-1); } return stack[--pointer]; @@ -132,7 +132,7 @@ static void stack_machine(const char *argument) } o++; } - fprintf(stderr, "dc: %s: syntax error.\n", argument); + errorMsg("%s: syntax error.\n", argument); exit(-1); } diff --git a/dd.c b/dd.c index 5d9993d8b..6261dfef5 100644 --- a/dd.c +++ b/dd.c @@ -86,26 +86,26 @@ extern int dd_main(int argc, char **argv) else if (strncmp("count", *argv, 5) == 0) { count = getNum((strchr(*argv, '=')) + 1); if (count <= 0) { - fprintf(stderr, "Bad count value %s\n", *argv); + errorMsg("Bad count value %s\n", *argv); goto usage; } } else if (strncmp(*argv, "bs", 2) == 0) { blockSize = getNum((strchr(*argv, '=')) + 1); if (blockSize <= 0) { - fprintf(stderr, "Bad block size value %s\n", *argv); + errorMsg("Bad block size value %s\n", *argv); goto usage; } } else if (strncmp(*argv, "skip", 4) == 0) { skipBlocks = getNum((strchr(*argv, '=')) + 1); if (skipBlocks <= 0) { - fprintf(stderr, "Bad skip value %s\n", *argv); + errorMsg("Bad skip value %s\n", *argv); goto usage; } } else if (strncmp(*argv, "seek", 4) == 0) { seekBlocks = getNum((strchr(*argv, '=')) + 1); if (seekBlocks <= 0) { - fprintf(stderr, "Bad seek value %s\n", *argv); + errorMsg("Bad seek value %s\n", *argv); goto usage; } diff --git a/deallocvt.c b/deallocvt.c index 53d4d9a7c..906f3a9fa 100644 --- a/deallocvt.c +++ b/deallocvt.c @@ -39,14 +39,12 @@ int deallocvt_main(int argc, char *argv[]) for (i = 1; i < argc; i++) { num = atoi(argv[i]); if (num == 0) - fprintf(stderr, "%s: 0: illegal VT number\n", applet_name); + errorMsg("0: illegal VT number\n"); else if (num == 1) - fprintf(stderr, "%s: VT 1 cannot be deallocated\n", - applet_name); + errorMsg("VT 1 cannot be deallocated\n"); else if (ioctl(fd, VT_DISALLOCATE, num)) { perror("VT_DISALLOCATE"); - fprintf(stderr, "%s: could not deallocate console %d\n", - applet_name, num); + errorMsg("could not deallocate console %d\n", num); exit( FALSE); } } diff --git a/df.c b/df.c index ba3227f30..62226ceb8 100644 --- a/df.c +++ b/df.c @@ -82,7 +82,7 @@ extern int df_main(int argc, char **argv) } while (argc > 1) { if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { - fprintf(stderr, "%s: can't find mount point.\n", argv[1]); + errorMsg("%s: can't find mount point.\n", argv[1]); exit(FALSE); } status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); diff --git a/du.c b/du.c index b8e296ddd..b1ca95436 100644 --- a/du.c +++ b/du.c @@ -108,7 +108,7 @@ static long du(char *filename) } if (len + strlen(name) + 1 > BUFSIZ) { - fprintf(stderr, name_too_long, "du"); + errorMsg(name_too_long); du_depth--; return 0; } @@ -158,7 +158,7 @@ int du_main(int argc, char **argv) usage(du_usage); break; default: - fprintf(stderr, "du: invalid option -- %c\n", opt); + errorMsg("invalid option -- %c\n", opt); usage(du_usage); } } else { @@ -184,7 +184,7 @@ int du_main(int argc, char **argv) return(0); } -/* $Id: du.c,v 1.20 2000/06/19 17:25:39 andersen Exp $ */ +/* $Id: du.c,v 1.21 2000/07/14 01:51:25 kraai Exp $ */ /* Local Variables: c-file-style: "linux" diff --git a/dumpkmap.c b/dumpkmap.c index a497a07d1..f18050529 100644 --- a/dumpkmap.c +++ b/dumpkmap.c @@ -58,7 +58,7 @@ int dumpkmap_main(int argc, char **argv) fd = open("/dev/tty0", O_RDWR); if (fd < 0) { - fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); + errorMsg("Error opening /dev/tty0: %s\n", strerror(errno)); return 1; } @@ -86,7 +86,7 @@ int dumpkmap_main(int argc, char **argv) ke.kb_table = i; if (ioctl(fd, KDGKBENT, &ke) < 0) { - fprintf(stderr, "ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value); + errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value); } else { write(1,&ke.kb_value,2); diff --git a/editors/sed.c b/editors/sed.c index 770a56eeb..3a7360fc5 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -207,8 +207,8 @@ static int get_address(const char *str, int *line, regex_t **regex) idx++; /* so it points to the next character after the last '/' */ } else { - fprintf(stderr, "sed.c:get_address: no address found in string\n"); - fprintf(stderr, "\t(you probably didn't check the string you passed me)\n"); + errorMsg("get_address: no address found in string\n" + "\t(you probably didn't check the string you passed me)\n"); idx = -1; } @@ -612,7 +612,7 @@ extern int sed_main(int argc, char **argv) for (i = optind; i < argc; i++) { file = fopen(argv[i], "r"); if (file == NULL) { - fprintf(stderr, "sed: %s: %s\n", argv[i], strerror(errno)); + errorMsg("%s: %s\n", argv[i], strerror(errno)); } else { process_file(file); fclose(file); diff --git a/fbset.c b/fbset.c index 9fde6a19d..2fcc7c294 100644 --- a/fbset.c +++ b/fbset.c @@ -387,7 +387,7 @@ extern int fbset_main(int argc, char **argv) PERROR("fbset(ioctl)"); if (g_options & OPT_READMODE) { if (!readmode(&var, modefile, mode)) { - fprintf(stderr, "Unknown video mode `%s'\n", mode); + errorMsg("Unknown video mode `%s'\n", mode); exit(1); } } diff --git a/findutils/grep.c b/findutils/grep.c index 77b510002..03945fa25 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -165,7 +165,7 @@ extern int grep_main(int argc, char **argv) file = fopen(cur_file, "r"); if (file == NULL) { if (!suppress_err_msgs) - fprintf(stderr, "grep: %s: %s\n", cur_file, strerror(errno)); + errorMsg("%s: %s\n", cur_file, strerror(errno)); } else { grep_file(file); fclose(file); diff --git a/fsck_minix.c b/fsck_minix.c index 685e0ee6c..74281a71e 100644 --- a/fsck_minix.c +++ b/fsck_minix.c @@ -311,7 +311,7 @@ static void show_usage(void) static void die(const char *str) { - fprintf(stderr, "%s: %s\n", applet_name, str); + errorMsg("%s\n", str); leave(8); } diff --git a/grep.c b/grep.c index 77b510002..03945fa25 100644 --- a/grep.c +++ b/grep.c @@ -165,7 +165,7 @@ extern int grep_main(int argc, char **argv) file = fopen(cur_file, "r"); if (file == NULL) { if (!suppress_err_msgs) - fprintf(stderr, "grep: %s: %s\n", cur_file, strerror(errno)); + errorMsg("%s: %s\n", cur_file, strerror(errno)); } else { grep_file(file); fclose(file); diff --git a/gunzip.c b/gunzip.c index 89e46a686..de68bd19b 100644 --- a/gunzip.c +++ b/gunzip.c @@ -659,7 +659,7 @@ int gunzip_main(int argc, char **argv) if (*argv == '\0') usage(gunzip_usage); if (strlen(*argv) > MAX_PATH_LEN) { - fprintf(stderr, name_too_long, "gunzip"); + errorMsg(name_too_long); exit(WARNING); } strcpy(ifname, *argv); @@ -698,7 +698,7 @@ int gunzip_main(int argc, char **argv) /* And get to work */ if (strlen(ifname) > MAX_PATH_LEN - 4) { - fprintf(stderr, name_too_long, "gunzip"); + errorMsg(name_too_long); exit(WARNING); } strcpy(ofname, ifname); @@ -780,8 +780,7 @@ int in; /* input file descriptor */ method = (int) get_byte(); if (method != DEFLATED) { - fprintf(stderr, - "unknown method %d -- get newer version of gzip\n", + errorMsg("unknown method %d -- get newer version of gzip\n", method); exit_code = ERROR; return -1; diff --git a/head.c b/head.c index f42f4837d..b82678dc2 100644 --- a/head.c +++ b/head.c @@ -75,7 +75,7 @@ int head_main(int argc, char **argv) case 'h': usage(head_usage); default: - fprintf(stderr, "head: invalid option -- %c\n", opt); + errorMsg("invalid option -- %c\n", opt); usage(head_usage); } } else { @@ -95,8 +95,7 @@ int head_main(int argc, char **argv) src = fopen(argv[i], "r"); if (!src) { - fprintf(stderr, "head: %s: %s\n", argv[i], - strerror(errno)); + errorMsg("%s: %s\n", argv[i], strerror(errno)); } else { /* emulating GNU behaviour */ if (need_headers) { @@ -112,4 +111,4 @@ int head_main(int argc, char **argv) return(0); } -/* $Id: head.c,v 1.11 2000/06/19 17:25:39 andersen Exp $ */ +/* $Id: head.c,v 1.12 2000/07/14 01:51:25 kraai Exp $ */ diff --git a/hostname.c b/hostname.c index e909138e4..60f66c073 100644 --- a/hostname.c +++ b/hostname.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: hostname.c,v 1.10 2000/06/19 17:25:39 andersen Exp $ + * $Id: hostname.c,v 1.11 2000/07/14 01:51:25 kraai Exp $ * Mini hostname implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -55,8 +55,7 @@ void do_sethostname(char *s, int isfile) if (!isfile) { if (sethostname(s, strlen(s)) < 0) { if (errno == EPERM) - fprintf(stderr, - "hostname: you must be root to change the hostname\n"); + errorMsg("you must be root to change the hostname\n"); else perror("sethostname"); exit(1); diff --git a/insmod.c b/insmod.c index 7e90dfbd9..b3d5ac837 100644 --- a/insmod.c +++ b/insmod.c @@ -70,7 +70,7 @@ #ifndef MODUTILS_MODULE_H #define MODUTILS_MODULE_H 1 -#ident "$Id: insmod.c,v 1.15 2000/07/11 17:52:22 andersen Exp $" +#ident "$Id: insmod.c,v 1.16 2000/07/14 01:51:25 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 @@ -276,7 +276,7 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H #define MODUTILS_OBJ_H 1 -#ident "$Id: insmod.c,v 1.15 2000/07/11 17:52:22 andersen Exp $" +#ident "$Id: insmod.c,v 1.16 2000/07/14 01:51:25 kraai Exp $" /* The relocatable object is manipulated using elfin types. */ @@ -938,7 +938,7 @@ struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name, /* Don't report an error if the symbol is coming from the kernel or some external module. */ if (secidx <= SHN_HIRESERVE) - fprintf(stderr, "%s multiply defined\n", name); + errorMsg("%s multiply defined\n", name); return sym; } } @@ -1201,7 +1201,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Also check that the parameter was not resolved from the kernel. */ if (sym == NULL || sym->secidx > SHN_HIRESERVE) { - fprintf(stderr, "symbol for parameter %s not found\n", p); + errorMsg("symbol for parameter %s not found\n", p); return 0; } @@ -1214,7 +1214,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv) str = alloca(strlen(q)); for (r = str, q++; *q != '"'; ++q, ++r) { if (*q == '\0') { - fprintf(stderr, "improperly terminated string argument for %s\n", p); + errorMsg("improperly terminated string argument for %s\n", p); return 0; } else if (*q == '\\') switch (*++q) { @@ -1567,7 +1567,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) p = get_modinfo_value(f, key); key += 5; if (p == NULL) { - fprintf(stderr, "invalid parameter %s\n", key); + errorMsg("invalid parameter %s\n", key); return 0; } @@ -1575,7 +1575,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Also check that the parameter was not resolved from the kernel. */ if (sym == NULL || sym->secidx > SHN_HIRESERVE) { - fprintf(stderr, "symbol for parameter %s not found\n", key); + errorMsg("symbol for parameter %s not found\n", key); return 0; } @@ -1603,8 +1603,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) str = alloca(strlen(q)); for (r = str, q++; *q != '"'; ++q, ++r) { if (*q == '\0') { - fprintf(stderr, - "improperly terminated string argument for %s\n", + errorMsg("improperly terminated string argument for %s\n", key); return 0; } else if (*q == '\\') @@ -1698,8 +1697,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Get the size of each member */ /* Probably we should do that outside the loop ? */ if (!isdigit(*(p + 1))) { - fprintf(stderr, - "parameter type 'c' for %s must be followed by" + errorMsg("parameter type 'c' for %s must be followed by" " the maximum size\n", key); return 0; } @@ -1707,8 +1705,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Check length */ if (strlen(str) >= charssize) { - fprintf(stderr, - "string too long for %s (max %ld)\n", key, + errorMsg("string too long for %s (max %ld)\n", key, charssize - 1); return 0; } @@ -1737,8 +1734,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) break; default: - fprintf(stderr, "unknown parameter type '%c' for %s\n", - *p, key); + errorMsg("unknown parameter type '%c' for %s\n", *p, key); return 0; } } @@ -1757,22 +1753,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) case ',': if (++n > max) { - fprintf(stderr, "too many values for %s (max %d)\n", - key, max); + errorMsg("too many values for %s (max %d)\n", key, max); return 0; } ++q; break; default: - fprintf(stderr, "invalid argument syntax for %s\n", key); + errorMsg("invalid argument syntax for %s\n", key); return 0; } } end_of_arg: if (n < min) { - fprintf(stderr, "too few values for %s (min %d)\n", key, min); + errorMsg("too few values for %s (min %d)\n", key, min); return 0; } @@ -2157,7 +2152,7 @@ int obj_check_undefineds(struct obj_file *f) sym->secidx = SHN_ABS; sym->value = 0; } else { - fprintf(stderr, "unresolved symbol %s\n", sym->name); + errorMsg("unresolved symbol %s\n", sym->name); ret = 0; } } @@ -2380,11 +2375,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base) errmsg = "Unhandled relocation"; bad_reloc: if (extsym) { - fprintf(stderr, "%s of type %ld for %s\n", errmsg, + errorMsg("%s of type %ld for %s\n", errmsg, (long) ELFW(R_TYPE) (rel->r_info), strtab + extsym->st_name); } else { - fprintf(stderr, "%s of type %ld\n", errmsg, + errorMsg("%s of type %ld\n", errmsg, (long) ELFW(R_TYPE) (rel->r_info)); } ret = 0; @@ -2469,25 +2464,25 @@ struct obj_file *obj_load(FILE * fp) || f->header.e_ident[EI_MAG1] != ELFMAG1 || f->header.e_ident[EI_MAG2] != ELFMAG2 || f->header.e_ident[EI_MAG3] != ELFMAG3) { - fprintf(stderr, "not an ELF file\n"); + errorMsg("not an ELF file\n"); return NULL; } if (f->header.e_ident[EI_CLASS] != ELFCLASSM || f->header.e_ident[EI_DATA] != ELFDATAM || f->header.e_ident[EI_VERSION] != EV_CURRENT || !MATCH_MACHINE(f->header.e_machine)) { - fprintf(stderr, "ELF file not for this architecture\n"); + errorMsg("ELF file not for this architecture\n"); return NULL; } if (f->header.e_type != ET_REL) { - fprintf(stderr, "ELF file not a relocatable object\n"); + errorMsg("ELF file not a relocatable object\n"); return NULL; } /* Read the section headers. */ if (f->header.e_shentsize != sizeof(ElfW(Shdr))) { - fprintf(stderr, "section header size mismatch: %lu != %lu\n", + errorMsg("section header size mismatch: %lu != %lu\n", (unsigned long) f->header.e_shentsize, (unsigned long) sizeof(ElfW(Shdr))); return NULL; @@ -2540,13 +2535,11 @@ struct obj_file *obj_load(FILE * fp) #if SHT_RELM == SHT_REL case SHT_RELA: - fprintf(stderr, - "RELA relocations not supported on this architecture\n"); + errorMsg("RELA relocations not supported on this architecture\n"); return NULL; #else case SHT_REL: - fprintf(stderr, - "REL relocations not supported on this architecture\n"); + errorMsg("REL relocations not supported on this architecture\n"); return NULL; #endif @@ -2559,7 +2552,7 @@ struct obj_file *obj_load(FILE * fp) break; } - fprintf(stderr, "can't handle sections of type %ld\n", + errorMsg("can't handle sections of type %ld\n", (long) sec->header.sh_type); return NULL; } @@ -2588,7 +2581,7 @@ struct obj_file *obj_load(FILE * fp) ElfW(Sym) * sym; if (sec->header.sh_entsize != sizeof(ElfW(Sym))) { - fprintf(stderr, "symbol size mismatch: %lu != %lu\n", + errorMsg("symbol size mismatch: %lu != %lu\n", (unsigned long) sec->header.sh_entsize, (unsigned long) sizeof(ElfW(Sym))); return NULL; @@ -2620,8 +2613,7 @@ struct obj_file *obj_load(FILE * fp) case SHT_RELM: if (sec->header.sh_entsize != sizeof(ElfW(RelM))) { - fprintf(stderr, - "relocation entry size mismatch: %lu != %lu\n", + errorMsg("relocation entry size mismatch: %lu != %lu\n", (unsigned long) sec->header.sh_entsize, (unsigned long) sizeof(ElfW(RelM))); return NULL; @@ -2754,20 +2746,20 @@ extern int insmod_main( int argc, char **argv) } else { m_version = old_get_module_version(f, m_strversion); if (m_version == -1) { - fprintf(stderr, - "couldn't find the kernel version the module was compiled for\n"); + errorMsg("couldn't find the kernel version the module was " + "compiled for\n"); goto out; } } if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { if (flag_force_load) { - fprintf(stderr, "Warning: kernel-module version mismatch\n" + errorMsg("Warning: kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" "\twhile this kernel is version %s\n", m_filename, m_strversion, k_strversion); } else { - fprintf(stderr, "kernel-module version mismatch\n" + errorMsg("kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" "\twhile this kernel is version %s.\n", m_filename, m_strversion, k_strversion); @@ -2785,7 +2777,7 @@ extern int insmod_main( int argc, char **argv) goto out; k_crcs = new_is_kernel_checksummed(); #else - fprintf(stderr, "Not configured to support new kernels\n"); + errorMsg("Not configured to support new kernels\n"); goto out; #endif } else { @@ -2794,7 +2786,7 @@ extern int insmod_main( int argc, char **argv) goto out; k_crcs = old_is_kernel_checksummed(); #else - fprintf(stderr, "Not configured to support old kernels\n"); + errorMsg("Not configured to support old kernels\n"); goto out; #endif } @@ -2851,11 +2843,10 @@ extern int insmod_main( int argc, char **argv) case 0: break; case EEXIST: - fprintf(stderr, "A module named %s already exists\n", m_name); + errorMsg("A module named %s already exists\n", m_name); goto out; case ENOMEM: - fprintf(stderr, - "Can't allocate kernel memory for module; needed %lu bytes\n", + errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n", m_size); goto out; default: diff --git a/lash.c b/lash.c index f4564f7f7..048394ab6 100644 --- a/lash.c +++ b/lash.c @@ -207,12 +207,12 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList) if (!jobList->head) { if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) { - fprintf(stderr, "%s: exactly one argument is expected\n", + errorMsg("%s: exactly one argument is expected\n", cmd->progs[0].argv[0]); return FALSE; } if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) { - fprintf(stderr, "%s: bad argument '%s'\n", + errorMsg("%s: bad argument '%s'\n", cmd->progs[0].argv[0], cmd->progs[0].argv[1]); return FALSE; for (job = jobList->head; job; job = job->next) { @@ -226,7 +226,7 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList) } if (!job) { - fprintf(stderr, "%s: unknown job %d\n", + errorMsg("%s: unknown job %d\n", cmd->progs[0].argv[0], jobNum); return FALSE; } @@ -519,7 +519,7 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr, rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult); if (rc == GLOB_NOSPACE) { - fprintf(stderr, "out of space during glob operation\n"); + errorMsg("out of space during glob operation\n"); return; } else if (rc == GLOB_NOMATCH || (!rc && (prog->globResult.gl_pathc - i) == 1 && @@ -607,7 +607,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi if (*src == '\\') { src++; if (!*src) { - fprintf(stderr, "character expected after \\\n"); + errorMsg("character expected after \\\n"); freeJob(job); return 1; } @@ -686,7 +686,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi chptr++; if (!*chptr) { - fprintf(stderr, "file name expected after %c\n", *src); + errorMsg("file name expected after %c\n", *src); freeJob(job); job->numProgs=0; return 1; @@ -705,7 +705,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi if (*prog->argv[argc]) argc++; if (!argc) { - fprintf(stderr, "empty command in pipe1.\n"); + errorMsg("empty command in pipe1\n"); freeJob(job); job->numProgs=0; return 1; @@ -731,7 +731,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi src++; if (!*src) { - fprintf(stderr, "empty command in pipe2\n"); + errorMsg("empty command in pipe2\n"); freeJob(job); job->numProgs=0; return 1; @@ -750,7 +750,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi case '\\': src++; if (!*src) { - fprintf(stderr, "character expected after \\\n"); + errorMsg("character expected after \\\n"); freeJob(job); return 1; } @@ -965,7 +965,7 @@ static int setupRedirections(struct childProgram *prog) if (openfd < 0) { /* this could get lost if stderr has been redirected, but bash and ash both lose it as well (though zsh doesn't!) */ - fprintf(stderr, "error opening %s: %s\n", redir->filename, + errorMsg("error opening %s: %s\n", redir->filename, strerror(errno)); return 1; } diff --git a/ln.c b/ln.c index ac1f68e00..9f7774380 100644 --- a/ln.c +++ b/ln.c @@ -23,7 +23,6 @@ #include "internal.h" #define BB_DECLARE_EXTERN -#define bb_need_name_too_long #define bb_need_not_a_directory #include "messages.c" @@ -92,7 +91,7 @@ extern int ln_main(int argc, char **argv) linkIntoDirFlag = isDirectory(linkName, followLinks, NULL); if ((argc >= 3) && linkIntoDirFlag == FALSE) { - fprintf(stderr, not_a_directory, "ln", linkName); + errorMsg(not_a_directory, linkName); exit FALSE; } diff --git a/loadacm.c b/loadacm.c index a64c691d2..9eebf3bb5 100644 --- a/loadacm.c +++ b/loadacm.c @@ -46,12 +46,12 @@ int loadacm_main(int argc, char **argv) fd = open("/dev/tty", O_RDWR); if (fd < 0) { - fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno)); + errorMsg("Error opening /dev/tty1: %s\n", strerror(errno)); return( FALSE); } if (screen_map_load(fd, stdin)) { - fprintf(stderr, "Error loading acm: %s\n", strerror(errno)); + errorMsg("Error loading acm: %s\n", strerror(errno)); return( FALSE); } @@ -79,8 +79,7 @@ int screen_map_load(int fd, FILE * fp) if (parse_failed) { if (-1 == fseek(fp, 0, SEEK_SET)) { if (errno == ESPIPE) - fprintf(stderr, - "16bit screen-map MUST be a regular file.\n"), + errorMsg("16bit screen-map MUST be a regular file.\n"), exit(1); else perror("fseek failed reading binary 16bit screen-map"), @@ -91,7 +90,7 @@ int screen_map_load(int fd, FILE * fp) perror("Cannot read [new] map from file"), exit(1); #if 0 else - fprintf(stderr, "Input screen-map is binary.\n"); + errorMsg("Input screen-map is binary.\n"); #endif } @@ -108,8 +107,7 @@ int screen_map_load(int fd, FILE * fp) /* rewind... */ if (-1 == fseek(fp, 0, SEEK_SET)) { if (errno == ESPIPE) - fprintf(stderr, - "Assuming 8bit screen-map - MUST be a regular file.\n"), + errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"), exit(1); else perror("fseek failed assuming 8bit screen-map"), exit(1); @@ -122,7 +120,7 @@ int screen_map_load(int fd, FILE * fp) if (-1 == fseek(fp, 0, SEEK_SET)) { if (errno == ESPIPE) /* should not - it succedeed above */ - fprintf(stderr, "fseek() returned ESPIPE !\n"), + errorMsg("fseek() returned ESPIPE !\n"), exit(1); else perror("fseek for binary 8bit screen-map"), exit(1); @@ -132,7 +130,7 @@ int screen_map_load(int fd, FILE * fp) perror("Cannot read [old] map from file"), exit(1); #if 0 else - fprintf(stderr, "Input screen-map is binary.\n"); + errorMsg("Input screen-map is binary.\n"); #endif } @@ -141,7 +139,7 @@ int screen_map_load(int fd, FILE * fp) else return 0; } - fprintf(stderr, "Error parsing symbolic map\n"); + errorMsg("Error parsing symbolic map\n"); return(1); } diff --git a/loadfont.c b/loadfont.c index 7eaf40e82..b3f9f4f11 100644 --- a/loadfont.c +++ b/loadfont.c @@ -56,7 +56,7 @@ extern int loadfont_main(int argc, char **argv) fd = open("/dev/tty0", O_RDWR); if (fd < 0) { - fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); + errorMsg("Error opening /dev/tty0: %s\n", strerror(errno)); return( FALSE); } loadnewfont(fd); @@ -72,7 +72,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize) memset(buf, 0, sizeof(buf)); if (unit < 1 || unit > 32) { - fprintf(stderr, "Bad character size %d\n", unit); + errorMsg("Bad character size %d\n", unit); exit(1); } @@ -112,7 +112,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) up = (struct unipair *) malloc(maxct * sizeof(struct unipair)); if (!up) { - fprintf(stderr, "Out of memory?\n"); + errorMsg("Out of memory?\n"); exit(1); } for (glyph = 0; glyph < fontsize; glyph++) { @@ -137,8 +137,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize) if (ioctl(fd, PIO_UNIMAPCLR, &advice)) { #ifdef ENOIOCTLCMD if (errno == ENOIOCTLCMD) { - fprintf(stderr, "It seems this kernel is older than 1.1.92\n"); - fprintf(stderr, "No Unicode mapping table loaded.\n"); + errorMsg("It seems this kernel is older than 1.1.92\n"); + errorMsg("No Unicode mapping table loaded.\n"); } else #endif perror("PIO_UNIMAPCLR"); @@ -198,13 +198,13 @@ static void loadnewfont(int fd) goto no_psf; if (psfhdr.mode > PSF_MAXMODE) { - fprintf(stderr, "Unsupported psf file mode\n"); + errorMsg("Unsupported psf file mode\n"); exit(1); } fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); #if !defined( PIO_FONTX ) || defined( __sparc__ ) if (fontsize != 256) { - fprintf(stderr, "Only fontsize 256 supported\n"); + errorMsg("Only fontsize 256 supported\n"); exit(1); } #endif @@ -214,7 +214,7 @@ static void loadnewfont(int fd) head = head0 + fontsize * unit; if (head > inputlth || (!hastable && head != inputlth)) { - fprintf(stderr, "Input file: bad length\n"); + errorMsg("Input file: bad length\n"); exit(1); } do_loadfont(fd, inbuf + head0, unit, fontsize); @@ -231,7 +231,7 @@ static void loadnewfont(int fd) } else { /* bare font */ if (inputlth & 0377) { - fprintf(stderr, "Bad input file size\n"); + errorMsg("Bad input file size\n"); exit(1); } offset = 0; diff --git a/loadkmap.c b/loadkmap.c index c2e4c94ed..72247a6e4 100644 --- a/loadkmap.c +++ b/loadkmap.c @@ -59,25 +59,25 @@ int loadkmap_main(int argc, char **argv) fd = open("/dev/tty0", O_RDWR); if (fd < 0) { - fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); + errorMsg("Error opening /dev/tty0: %s\n", strerror(errno)); exit(FALSE); } read(0, buff, 7); if (0 != strncmp(buff, magic, 7)) { - fprintf(stderr, "This is not a valid binary keymap.\n"); + errorMsg("This is not a valid binary keymap.\n"); exit(FALSE); } if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) { - fprintf(stderr, "Error reading keymap flags: %s\n", + errorMsg("Error reading keymap flags: %s\n", strerror(errno)); exit(FALSE); } ibuff = (u_short *) malloc(ibuffsz); if (!ibuff) { - fprintf(stderr, "Out of memory.\n"); + errorMsg("Out of memory.\n"); exit(FALSE); } @@ -87,7 +87,7 @@ int loadkmap_main(int argc, char **argv) while (pos < ibuffsz) { if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0) { - fprintf(stderr, "Error reading keymap: %s\n", + errorMsg("Error reading keymap: %s\n", strerror(errno)); exit(FALSE); } diff --git a/logger.c b/logger.c index d32ccaaf3..71d703085 100644 --- a/logger.c +++ b/logger.c @@ -96,7 +96,7 @@ static int pencode(char *s) *s = '\0'; fac = decode(save, facilitynames); if (fac < 0) { - fprintf(stderr, "unknown facility name: %s\n", save); + errorMsg("unknown facility name: %s\n", save); exit(FALSE); } *s++ = '.'; @@ -105,7 +105,7 @@ static int pencode(char *s) } lev = decode(s, prioritynames); if (lev < 0) { - fprintf(stderr, "unknown priority name: %s\n", save); + errorMsg("unknown priority name: %s\n", save); exit(FALSE); } return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)); @@ -166,7 +166,7 @@ extern int logger_main(int argc, char **argv) if (argc >= 1) { message = *argv; } else { - fprintf(stderr, "No message\n"); + errorMsg("No message\n"); exit(FALSE); } } diff --git a/logname.c b/logname.c index 4b4483cc1..12ebfbde6 100644 --- a/logname.c +++ b/logname.c @@ -41,6 +41,6 @@ extern int logname_main(int argc, char **argv) puts(user); exit(TRUE); } - fprintf(stderr, "no login name\n"); + errorMsg("no login name\n"); return(FALSE); } diff --git a/messages.c b/messages.c index f2374eeb5..428db9eaa 100644 --- a/messages.c +++ b/messages.c @@ -48,13 +48,13 @@ #if defined bb_need_name_too_long || ! defined BB_DECLARE_EXTERN - BB_DEF_MESSAGE(name_too_long, "%s: file name too long\n") + BB_DEF_MESSAGE(name_too_long, "file name too long\n") #endif #if defined bb_need_omitting_directory || ! defined BB_DECLARE_EXTERN - BB_DEF_MESSAGE(omitting_directory, "%s: %s: omitting directory\n") + BB_DEF_MESSAGE(omitting_directory, "%s: omitting directory\n") #endif #if defined bb_need_not_a_directory || ! defined BB_DECLARE_EXTERN - BB_DEF_MESSAGE(not_a_directory, "%s: %s: not a directory\n") + BB_DEF_MESSAGE(not_a_directory, "%s: not a directory\n") #endif #if defined bb_need_memory_exhausted || ! defined BB_DECLARE_EXTERN BB_DEF_MESSAGE(memory_exhausted, "memory exhausted\n") @@ -63,7 +63,7 @@ BB_DEF_MESSAGE(invalid_date, "invalid date `%s'\n") #endif #if defined bb_need_invalid_option || ! defined BB_DECLARE_EXTERN - BB_DEF_MESSAGE(invalid_option, "%s: invalid option -- %c\n") + BB_DEF_MESSAGE(invalid_option, "invalid option -- %c\n") #endif #if defined bb_need_io_error || ! defined BB_DECLARE_EXTERN BB_DEF_MESSAGE(io_error, "%s: input/output error -- %s\n") @@ -75,7 +75,7 @@ BB_DEF_MESSAGE(write_error, "Write Error\n") #endif #if defined bb_need_too_few_args || ! defined BB_DECLARE_EXTERN - BB_DEF_MESSAGE(too_few_args, "%s: too few arguments\n") + BB_DEF_MESSAGE(too_few_args, "too few arguments\n") #endif diff --git a/miscutils/dc.c b/miscutils/dc.c index 5bf3bc984..7b13cb943 100644 --- a/miscutils/dc.c +++ b/miscutils/dc.c @@ -22,7 +22,7 @@ static unsigned int pointer; static void push(double a) { if (pointer >= (sizeof(stack) / sizeof(*stack))) { - fprintf(stderr, "dc: stack overflow\n"); + errorMsg("stack overflow\n"); exit(-1); } else stack[pointer++] = a; @@ -31,7 +31,7 @@ static void push(double a) static double pop() { if (pointer == 0) { - fprintf(stderr, "dc: stack underflow\n"); + errorMsg("stack underflow\n"); exit(-1); } return stack[--pointer]; @@ -132,7 +132,7 @@ static void stack_machine(const char *argument) } o++; } - fprintf(stderr, "dc: %s: syntax error.\n", argument); + errorMsg("%s: syntax error.\n", argument); exit(-1); } diff --git a/miscutils/mt.c b/miscutils/mt.c index 304d66485..4ab478270 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c @@ -81,7 +81,7 @@ extern int mt_main(int argc, char **argv) } if (code->name == 0) { - fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); + errorMsg("unrecognized opcode %s.\n", argv[1]); exit (FALSE); } diff --git a/mkdir.c b/mkdir.c index b18c949b8..f6e08cadc 100644 --- a/mkdir.c +++ b/mkdir.c @@ -62,7 +62,7 @@ extern int mkdir_main(int argc, char **argv) /* Find the specified modes */ mode = 0; if (parse_mode(*(++argv), &mode) == FALSE) { - fprintf(stderr, "Unknown mode: %s\n", *argv); + errorMsg("Unknown mode: %s\n", *argv); exit FALSE; } /* Set the umask for this process so it doesn't @@ -91,13 +91,13 @@ extern int mkdir_main(int argc, char **argv) char buf[BUFSIZ + 1]; if (strlen(*argv) > BUFSIZ - 1) { - fprintf(stderr, name_too_long, "mkdir"); + errorMsg(name_too_long); exit FALSE; } strcpy(buf, *argv); status = stat(buf, &statBuf); if (parentFlag == FALSE && status != -1 && errno != ENOENT) { - fprintf(stderr, "%s: File exists\n", buf); + errorMsg("%s: File exists\n", buf); exit FALSE; } if (parentFlag == TRUE) { diff --git a/mkfs_minix.c b/mkfs_minix.c index b6f958f46..e4dedaf82 100644 --- a/mkfs_minix.c +++ b/mkfs_minix.c @@ -263,7 +263,7 @@ static unsigned long req_nr_inodes = 0; */ static volatile void die(char *str) { - fprintf(stderr, "%s: %s\n", applet_name, str); + errorMsg("%s\n", str); exit(8); } @@ -814,8 +814,8 @@ extern int mkfs_minix_main(int argc, char **argv) #ifdef HAVE_MINIX2 version2 = 1; #else - fprintf(stderr, "%s: not compiled with minix v2 support\n", - applet_name, device_name); + errorMsg("%s: not compiled with minix v2 support\n", + device_name); exit(-1); #endif break; diff --git a/mkswap.c b/mkswap.c index 20096361f..5a33945c8 100644 --- a/mkswap.c +++ b/mkswap.c @@ -116,7 +116,7 @@ static void init_signature_page() #ifdef PAGE_SIZE if (pagesize != PAGE_SIZE) - fprintf(stderr, "Assuming pages of size %d\n", pagesize); + errorMsg("Assuming pages of size %d\n", pagesize); #endif signature_page = (int *) xmalloc(pagesize); memset(signature_page, 0, pagesize); @@ -204,7 +204,7 @@ static int bit_test_and_clear(unsigned int *addr, unsigned int nr) void die(const char *str) { - fprintf(stderr, "%s: %s\n", applet_name, str); + errorMsg("%s\n", str); exit(FALSE); } @@ -345,18 +345,14 @@ int mkswap_main(int argc, char **argv) } } if (!device_name) { - fprintf(stderr, - "%s: error: Nowhere to set up swap on?\n", applet_name); + errorMsg("error: Nowhere to set up swap on?\n"); usage(mkswap_usage); } sz = get_size(device_name); if (!PAGES) { PAGES = sz; } else if (PAGES > sz && !force) { - fprintf(stderr, - "%s: error: " - "size %ld is larger than device size %d\n", - applet_name, + errorMsg("error: size %ld is larger than device size %d\n", PAGES * (pagesize / 1024), sz * (pagesize / 1024)); exit(FALSE); } @@ -372,14 +368,12 @@ int mkswap_main(int argc, char **argv) version = 1; } if (version != 0 && version != 1) { - fprintf(stderr, "%s: error: unknown version %d\n", - applet_name, version); + errorMsg("error: unknown version %d\n", version); usage(mkswap_usage); } if (PAGES < 10) { - fprintf(stderr, - "%s: error: swap area needs to be at least %ldkB\n", - applet_name, (long) (10 * pagesize / 1024)); + errorMsg("error: swap area needs to be at least %ldkB\n", + (long) (10 * pagesize / 1024)); usage(mkswap_usage); } #if 0 @@ -397,8 +391,8 @@ int mkswap_main(int argc, char **argv) #endif if (PAGES > maxpages) { PAGES = maxpages; - fprintf(stderr, "%s: warning: truncating swap area to %ldkB\n", - applet_name, PAGES * pagesize / 1024); + errorMsg("warning: truncating swap area to %ldkB\n", + PAGES * pagesize / 1024); } DEV = open(device_name, O_RDWR); @@ -424,11 +418,10 @@ int mkswap_main(int argc, char **argv) for (sum = 0; q >= (unsigned short *) buffer;) sum ^= *q--; if (!sum) { - fprintf(stderr, "\ -%s: Device '%s' contains a valid Sun disklabel.\n\ -This probably means creating v0 swap would destroy your partition table\n\ -No swap created. If you really want to create swap v0 on that device, use\n\ -the -f option to force it.\n", applet_name, device_name); + errorMsg("Device '%s' contains a valid Sun disklabel.\n" +"This probably means creating v0 swap would destroy your partition table\n" +"No swap created. If you really want to create swap v0 on that device, use\n" +"the -f option to force it.\n", device_name); exit(FALSE); } } diff --git a/modutils/insmod.c b/modutils/insmod.c index 7e90dfbd9..b3d5ac837 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -70,7 +70,7 @@ #ifndef MODUTILS_MODULE_H #define MODUTILS_MODULE_H 1 -#ident "$Id: insmod.c,v 1.15 2000/07/11 17:52:22 andersen Exp $" +#ident "$Id: insmod.c,v 1.16 2000/07/14 01:51:25 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 @@ -276,7 +276,7 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H #define MODUTILS_OBJ_H 1 -#ident "$Id: insmod.c,v 1.15 2000/07/11 17:52:22 andersen Exp $" +#ident "$Id: insmod.c,v 1.16 2000/07/14 01:51:25 kraai Exp $" /* The relocatable object is manipulated using elfin types. */ @@ -938,7 +938,7 @@ struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name, /* Don't report an error if the symbol is coming from the kernel or some external module. */ if (secidx <= SHN_HIRESERVE) - fprintf(stderr, "%s multiply defined\n", name); + errorMsg("%s multiply defined\n", name); return sym; } } @@ -1201,7 +1201,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Also check that the parameter was not resolved from the kernel. */ if (sym == NULL || sym->secidx > SHN_HIRESERVE) { - fprintf(stderr, "symbol for parameter %s not found\n", p); + errorMsg("symbol for parameter %s not found\n", p); return 0; } @@ -1214,7 +1214,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv) str = alloca(strlen(q)); for (r = str, q++; *q != '"'; ++q, ++r) { if (*q == '\0') { - fprintf(stderr, "improperly terminated string argument for %s\n", p); + errorMsg("improperly terminated string argument for %s\n", p); return 0; } else if (*q == '\\') switch (*++q) { @@ -1567,7 +1567,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) p = get_modinfo_value(f, key); key += 5; if (p == NULL) { - fprintf(stderr, "invalid parameter %s\n", key); + errorMsg("invalid parameter %s\n", key); return 0; } @@ -1575,7 +1575,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Also check that the parameter was not resolved from the kernel. */ if (sym == NULL || sym->secidx > SHN_HIRESERVE) { - fprintf(stderr, "symbol for parameter %s not found\n", key); + errorMsg("symbol for parameter %s not found\n", key); return 0; } @@ -1603,8 +1603,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) str = alloca(strlen(q)); for (r = str, q++; *q != '"'; ++q, ++r) { if (*q == '\0') { - fprintf(stderr, - "improperly terminated string argument for %s\n", + errorMsg("improperly terminated string argument for %s\n", key); return 0; } else if (*q == '\\') @@ -1698,8 +1697,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Get the size of each member */ /* Probably we should do that outside the loop ? */ if (!isdigit(*(p + 1))) { - fprintf(stderr, - "parameter type 'c' for %s must be followed by" + errorMsg("parameter type 'c' for %s must be followed by" " the maximum size\n", key); return 0; } @@ -1707,8 +1705,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) /* Check length */ if (strlen(str) >= charssize) { - fprintf(stderr, - "string too long for %s (max %ld)\n", key, + errorMsg("string too long for %s (max %ld)\n", key, charssize - 1); return 0; } @@ -1737,8 +1734,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) break; default: - fprintf(stderr, "unknown parameter type '%c' for %s\n", - *p, key); + errorMsg("unknown parameter type '%c' for %s\n", *p, key); return 0; } } @@ -1757,22 +1753,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv) case ',': if (++n > max) { - fprintf(stderr, "too many values for %s (max %d)\n", - key, max); + errorMsg("too many values for %s (max %d)\n", key, max); return 0; } ++q; break; default: - fprintf(stderr, "invalid argument syntax for %s\n", key); + errorMsg("invalid argument syntax for %s\n", key); return 0; } } end_of_arg: if (n < min) { - fprintf(stderr, "too few values for %s (min %d)\n", key, min); + errorMsg("too few values for %s (min %d)\n", key, min); return 0; } @@ -2157,7 +2152,7 @@ int obj_check_undefineds(struct obj_file *f) sym->secidx = SHN_ABS; sym->value = 0; } else { - fprintf(stderr, "unresolved symbol %s\n", sym->name); + errorMsg("unresolved symbol %s\n", sym->name); ret = 0; } } @@ -2380,11 +2375,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base) errmsg = "Unhandled relocation"; bad_reloc: if (extsym) { - fprintf(stderr, "%s of type %ld for %s\n", errmsg, + errorMsg("%s of type %ld for %s\n", errmsg, (long) ELFW(R_TYPE) (rel->r_info), strtab + extsym->st_name); } else { - fprintf(stderr, "%s of type %ld\n", errmsg, + errorMsg("%s of type %ld\n", errmsg, (long) ELFW(R_TYPE) (rel->r_info)); } ret = 0; @@ -2469,25 +2464,25 @@ struct obj_file *obj_load(FILE * fp) || f->header.e_ident[EI_MAG1] != ELFMAG1 || f->header.e_ident[EI_MAG2] != ELFMAG2 || f->header.e_ident[EI_MAG3] != ELFMAG3) { - fprintf(stderr, "not an ELF file\n"); + errorMsg("not an ELF file\n"); return NULL; } if (f->header.e_ident[EI_CLASS] != ELFCLASSM || f->header.e_ident[EI_DATA] != ELFDATAM || f->header.e_ident[EI_VERSION] != EV_CURRENT || !MATCH_MACHINE(f->header.e_machine)) { - fprintf(stderr, "ELF file not for this architecture\n"); + errorMsg("ELF file not for this architecture\n"); return NULL; } if (f->header.e_type != ET_REL) { - fprintf(stderr, "ELF file not a relocatable object\n"); + errorMsg("ELF file not a relocatable object\n"); return NULL; } /* Read the section headers. */ if (f->header.e_shentsize != sizeof(ElfW(Shdr))) { - fprintf(stderr, "section header size mismatch: %lu != %lu\n", + errorMsg("section header size mismatch: %lu != %lu\n", (unsigned long) f->header.e_shentsize, (unsigned long) sizeof(ElfW(Shdr))); return NULL; @@ -2540,13 +2535,11 @@ struct obj_file *obj_load(FILE * fp) #if SHT_RELM == SHT_REL case SHT_RELA: - fprintf(stderr, - "RELA relocations not supported on this architecture\n"); + errorMsg("RELA relocations not supported on this architecture\n"); return NULL; #else case SHT_REL: - fprintf(stderr, - "REL relocations not supported on this architecture\n"); + errorMsg("REL relocations not supported on this architecture\n"); return NULL; #endif @@ -2559,7 +2552,7 @@ struct obj_file *obj_load(FILE * fp) break; } - fprintf(stderr, "can't handle sections of type %ld\n", + errorMsg("can't handle sections of type %ld\n", (long) sec->header.sh_type); return NULL; } @@ -2588,7 +2581,7 @@ struct obj_file *obj_load(FILE * fp) ElfW(Sym) * sym; if (sec->header.sh_entsize != sizeof(ElfW(Sym))) { - fprintf(stderr, "symbol size mismatch: %lu != %lu\n", + errorMsg("symbol size mismatch: %lu != %lu\n", (unsigned long) sec->header.sh_entsize, (unsigned long) sizeof(ElfW(Sym))); return NULL; @@ -2620,8 +2613,7 @@ struct obj_file *obj_load(FILE * fp) case SHT_RELM: if (sec->header.sh_entsize != sizeof(ElfW(RelM))) { - fprintf(stderr, - "relocation entry size mismatch: %lu != %lu\n", + errorMsg("relocation entry size mismatch: %lu != %lu\n", (unsigned long) sec->header.sh_entsize, (unsigned long) sizeof(ElfW(RelM))); return NULL; @@ -2754,20 +2746,20 @@ extern int insmod_main( int argc, char **argv) } else { m_version = old_get_module_version(f, m_strversion); if (m_version == -1) { - fprintf(stderr, - "couldn't find the kernel version the module was compiled for\n"); + errorMsg("couldn't find the kernel version the module was " + "compiled for\n"); goto out; } } if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { if (flag_force_load) { - fprintf(stderr, "Warning: kernel-module version mismatch\n" + errorMsg("Warning: kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" "\twhile this kernel is version %s\n", m_filename, m_strversion, k_strversion); } else { - fprintf(stderr, "kernel-module version mismatch\n" + errorMsg("kernel-module version mismatch\n" "\t%s was compiled for kernel version %s\n" "\twhile this kernel is version %s.\n", m_filename, m_strversion, k_strversion); @@ -2785,7 +2777,7 @@ extern int insmod_main( int argc, char **argv) goto out; k_crcs = new_is_kernel_checksummed(); #else - fprintf(stderr, "Not configured to support new kernels\n"); + errorMsg("Not configured to support new kernels\n"); goto out; #endif } else { @@ -2794,7 +2786,7 @@ extern int insmod_main( int argc, char **argv) goto out; k_crcs = old_is_kernel_checksummed(); #else - fprintf(stderr, "Not configured to support old kernels\n"); + errorMsg("Not configured to support old kernels\n"); goto out; #endif } @@ -2851,11 +2843,10 @@ extern int insmod_main( int argc, char **argv) case 0: break; case EEXIST: - fprintf(stderr, "A module named %s already exists\n", m_name); + errorMsg("A module named %s already exists\n", m_name); goto out; case ENOMEM: - fprintf(stderr, - "Can't allocate kernel memory for module; needed %lu bytes\n", + errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n", m_size); goto out; default: diff --git a/mount.c b/mount.c index 900ab30a7..455e4a1c1 100644 --- a/mount.c +++ b/mount.c @@ -157,15 +157,15 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, specialfile = find_unused_loop_device(); if (specialfile == NULL) { - fprintf(stderr, "Could not find a spare loop device\n"); + errorMsg("Could not find a spare loop device\n"); return (FALSE); } if (set_loop(specialfile, lofile, 0, &loro)) { - fprintf(stderr, "Could not setup loop device\n"); + errorMsg("Could not setup loop device\n"); return (FALSE); } if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */ - fprintf(stderr, "WARNING: loop device is read-only\n"); + errorMsg("WARNING: loop device is read-only\n"); flags &= ~MS_RDONLY; } } @@ -329,7 +329,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, if (status == FALSE) { if (whineOnErrors == TRUE) { - fprintf(stderr, "Mounting %s on %s failed: %s\n", + errorMsg("Mounting %s on %s failed: %s\n", blockDevice, directory, strerror(errno)); } return (FALSE); diff --git a/mt.c b/mt.c index 304d66485..4ab478270 100644 --- a/mt.c +++ b/mt.c @@ -81,7 +81,7 @@ extern int mt_main(int argc, char **argv) } if (code->name == 0) { - fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); + errorMsg("unrecognized opcode %s.\n", argv[1]); exit (FALSE); } diff --git a/networking/hostname.c b/networking/hostname.c index e909138e4..60f66c073 100644 --- a/networking/hostname.c +++ b/networking/hostname.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: hostname.c,v 1.10 2000/06/19 17:25:39 andersen Exp $ + * $Id: hostname.c,v 1.11 2000/07/14 01:51:25 kraai Exp $ * Mini hostname implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -55,8 +55,7 @@ void do_sethostname(char *s, int isfile) if (!isfile) { if (sethostname(s, strlen(s)) < 0) { if (errno == EPERM) - fprintf(stderr, - "hostname: you must be root to change the hostname\n"); + errorMsg("you must be root to change the hostname\n"); else perror("sethostname"); exit(1); diff --git a/networking/ping.c b/networking/ping.c index 0359abbd1..52cb07be7 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping.c,v 1.20 2000/07/12 17:02:35 kraai Exp $ + * $Id: ping.c,v 1.21 2000/07/14 01:51:25 kraai Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -208,7 +208,7 @@ static void ping(const char *host) pingaddr.sin_family = AF_INET; if (!(h = gethostbyname(host))) { - fprintf(stderr, "ping: unknown host %s\n", host); + errorMsg("unknown host %s\n", host); exit(1); } memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); @@ -225,7 +225,7 @@ static void ping(const char *host) if (c < 0 || c != sizeof(packet)) { if (c < 0) perror("ping: sendto"); - fprintf(stderr, "ping: write incomplete\n"); + errorMsg("write incomplete\n"); exit(1); } @@ -433,8 +433,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) printf("\n"); } else if (icmppkt->icmp_type != ICMP_ECHO) - fprintf(stderr, - "Warning: Got ICMP %d (%s)\n", + errorMsg("Warning: Got ICMP %d (%s)\n", icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); } @@ -452,7 +451,7 @@ static void ping(const char *host) if ((pingsock = socket(AF_INET, SOCK_RAW, (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */ if (errno == EPERM) { - fprintf(stderr, "ping: permission denied. (are you root?)\n"); + errorMsg("permission denied. (are you root?)\n"); } else { perror("ping: creating a raw socket"); } @@ -466,13 +465,12 @@ static void ping(const char *host) pingaddr.sin_family = AF_INET; if (!(h = gethostbyname(host))) { - fprintf(stderr, "ping: unknown host %s\n", host); + errorMsg("unknown host %s\n", host); exit(1); } if (h->h_addrtype != AF_INET) { - fprintf(stderr, - "ping: unknown address type; only AF_INET is currently supported.\n"); + errorMsg("unknown address type; only AF_INET is currently supported.\n"); exit(1); } diff --git a/nfsmount.c b/nfsmount.c index 8cdfebfce..ad0b5842d 100644 --- a/nfsmount.c +++ b/nfsmount.c @@ -312,8 +312,7 @@ int nfsmount(const char *spec, const char *node, int *flags, msock = fsock = -1; mclient = NULL; if (strlen(spec) >= sizeof(hostdir)) { - fprintf(stderr, _("mount: " - "excessively long host:dir argument\n")); + errorMsg("excessively long host:dir argument\n"); goto fail; } strcpy(hostdir, spec); @@ -325,12 +324,10 @@ int nfsmount(const char *spec, const char *node, int *flags, until they can be fully supported. (mack@sgi.com) */ if ((s = strchr(hostdir, ','))) { *s = '\0'; - fprintf(stderr, _("mount: warning: " - "multiple hostnames not supported\n")); + errorMsg("warning: multiple hostnames not supported\n"); } } else { - fprintf(stderr, _("mount: " - "directory to mount not in host:dir format\n")); + errorMsg("directory to mount not in host:dir format\n"); goto fail; } @@ -340,13 +337,11 @@ int nfsmount(const char *spec, const char *node, int *flags, #endif { if ((hp = gethostbyname(hostname)) == NULL) { - fprintf(stderr, _("mount: can't get address for %s\n"), - hostname); + errorMsg("can't get address for %s\n", hostname); goto fail; } else { if (hp->h_length > sizeof(struct in_addr)) { - fprintf(stderr, - _("mount: got bad hp->h_length\n")); + errorMsg("got bad hp->h_length\n"); hp->h_length = sizeof(struct in_addr); } memcpy(&server_addr.sin_addr, @@ -363,8 +358,7 @@ int nfsmount(const char *spec, const char *node, int *flags, if (!old_opts) old_opts = ""; if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) { - fprintf(stderr, _("mount: " - "excessively long option argument\n")); + errorMsg("excessively long option argument\n"); goto fail; } sprintf(new_opts, "%s%saddr=%s", @@ -524,11 +518,11 @@ int nfsmount(const char *spec, const char *node, int *flags, data.flags |= (nolock ? NFS_MOUNT_NONLM : 0); #endif if (nfsvers > MAX_NFSPROT) { - fprintf(stderr, "NFSv%d not supported!\n", nfsvers); + errorMsg("NFSv%d not supported!\n", nfsvers); return 0; } if (mountvers > MAX_NFSPROT) { - fprintf(stderr, "NFSv%d not supported!\n", nfsvers); + errorMsg("NFSv%d not supported!\n", nfsvers); return 0; } if (nfsvers && !mountvers) @@ -588,13 +582,11 @@ int nfsmount(const char *spec, const char *node, int *flags, mount_server_addr.sin_addr.s_addr = inet_addr(hostname); } else { if ((hp = gethostbyname(mounthost)) == NULL) { - fprintf(stderr, _("mount: can't get address for %s\n"), - hostname); + errorMsg("can't get address for %s\n", hostname); goto fail; } else { if (hp->h_length > sizeof(struct in_addr)) { - fprintf(stderr, - _("mount: got bad hp->h_length?\n")); + errorMsg("got bad hp->h_length?\n"); hp->h_length = sizeof(struct in_addr); } mount_server_addr.sin_family = AF_INET; @@ -729,8 +721,7 @@ int nfsmount(const char *spec, const char *node, int *flags, if (nfsvers == 2) { if (status.nfsv2.fhs_status != 0) { - fprintf(stderr, - "mount: %s:%s failed, reason given by server: %s\n", + errorMsg("%s:%s failed, reason given by server: %s\n", hostname, dirname, nfs_strerror(status.nfsv2.fhs_status)); goto fail; @@ -748,8 +739,7 @@ int nfsmount(const char *spec, const char *node, int *flags, #if NFS_MOUNT_VERSION >= 4 fhandle3 *fhandle; if (status.nfsv3.fhs_status != 0) { - fprintf(stderr, - "mount: %s:%s failed, reason given by server: %s\n", + errorMsg("%s:%s failed, reason given by server: %s\n", hostname, dirname, nfs_strerror(status.nfsv3.fhs_status)); goto fail; diff --git a/ping.c b/ping.c index 0359abbd1..52cb07be7 100644 --- a/ping.c +++ b/ping.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping.c,v 1.20 2000/07/12 17:02:35 kraai Exp $ + * $Id: ping.c,v 1.21 2000/07/14 01:51:25 kraai Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung @@ -208,7 +208,7 @@ static void ping(const char *host) pingaddr.sin_family = AF_INET; if (!(h = gethostbyname(host))) { - fprintf(stderr, "ping: unknown host %s\n", host); + errorMsg("unknown host %s\n", host); exit(1); } memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); @@ -225,7 +225,7 @@ static void ping(const char *host) if (c < 0 || c != sizeof(packet)) { if (c < 0) perror("ping: sendto"); - fprintf(stderr, "ping: write incomplete\n"); + errorMsg("write incomplete\n"); exit(1); } @@ -433,8 +433,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) printf("\n"); } else if (icmppkt->icmp_type != ICMP_ECHO) - fprintf(stderr, - "Warning: Got ICMP %d (%s)\n", + errorMsg("Warning: Got ICMP %d (%s)\n", icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); } @@ -452,7 +451,7 @@ static void ping(const char *host) if ((pingsock = socket(AF_INET, SOCK_RAW, (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */ if (errno == EPERM) { - fprintf(stderr, "ping: permission denied. (are you root?)\n"); + errorMsg("permission denied. (are you root?)\n"); } else { perror("ping: creating a raw socket"); } @@ -466,13 +465,12 @@ static void ping(const char *host) pingaddr.sin_family = AF_INET; if (!(h = gethostbyname(host))) { - fprintf(stderr, "ping: unknown host %s\n", host); + errorMsg("unknown host %s\n", host); exit(1); } if (h->h_addrtype != AF_INET) { - fprintf(stderr, - "ping: unknown address type; only AF_INET is currently supported.\n"); + errorMsg("unknown address type; only AF_INET is currently supported.\n"); exit(1); } diff --git a/procps/ps.c b/procps/ps.c index a8d000546..682135944 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -97,20 +97,20 @@ static void parse_proc_status(char *S, proc_t * P) if (tmp) sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid); else - fprintf(stderr, "Internal error!\n"); + errorMsg("Internal error!\n"); /* For busybox, ignoring effective, saved, etc */ tmp = strstr(S, "Uid:"); if (tmp) sscanf(tmp, "Uid:\t%d", &P->ruid); else - fprintf(stderr, "Internal error!\n"); + errorMsg("Internal error!\n"); tmp = strstr(S, "Gid:"); if (tmp) sscanf(tmp, "Gid:\t%d", &P->rgid); else - fprintf(stderr, "Internal error!\n"); + errorMsg("Internal error!\n"); } diff --git a/ps.c b/ps.c index a8d000546..682135944 100644 --- a/ps.c +++ b/ps.c @@ -97,20 +97,20 @@ static void parse_proc_status(char *S, proc_t * P) if (tmp) sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid); else - fprintf(stderr, "Internal error!\n"); + errorMsg("Internal error!\n"); /* For busybox, ignoring effective, saved, etc */ tmp = strstr(S, "Uid:"); if (tmp) sscanf(tmp, "Uid:\t%d", &P->ruid); else - fprintf(stderr, "Internal error!\n"); + errorMsg("Internal error!\n"); tmp = strstr(S, "Gid:"); if (tmp) sscanf(tmp, "Gid:\t%d", &P->rgid); else - fprintf(stderr, "Internal error!\n"); + errorMsg("Internal error!\n"); } diff --git a/rmdir.c b/rmdir.c index c88f42cf5..4edb9b6b3 100644 --- a/rmdir.c +++ b/rmdir.c @@ -40,7 +40,7 @@ extern int rmdir_main(int argc, char **argv) while (--argc > 0) { if (rmdir(*(++argv)) == -1) { - fprintf(stderr, "%s: %s\n", applet_name, strerror(errno)); + errorMsg("%s\n", strerror(errno)); exit(FALSE); } } diff --git a/sed.c b/sed.c index 770a56eeb..3a7360fc5 100644 --- a/sed.c +++ b/sed.c @@ -207,8 +207,8 @@ static int get_address(const char *str, int *line, regex_t **regex) idx++; /* so it points to the next character after the last '/' */ } else { - fprintf(stderr, "sed.c:get_address: no address found in string\n"); - fprintf(stderr, "\t(you probably didn't check the string you passed me)\n"); + errorMsg("get_address: no address found in string\n" + "\t(you probably didn't check the string you passed me)\n"); idx = -1; } @@ -612,7 +612,7 @@ extern int sed_main(int argc, char **argv) for (i = optind; i < argc; i++) { file = fopen(argv[i], "r"); if (file == NULL) { - fprintf(stderr, "sed: %s: %s\n", argv[i], strerror(errno)); + errorMsg("%s: %s\n", argv[i], strerror(errno)); } else { process_file(file); fclose(file); diff --git a/sh.c b/sh.c index f4564f7f7..048394ab6 100644 --- a/sh.c +++ b/sh.c @@ -207,12 +207,12 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList) if (!jobList->head) { if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) { - fprintf(stderr, "%s: exactly one argument is expected\n", + errorMsg("%s: exactly one argument is expected\n", cmd->progs[0].argv[0]); return FALSE; } if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) { - fprintf(stderr, "%s: bad argument '%s'\n", + errorMsg("%s: bad argument '%s'\n", cmd->progs[0].argv[0], cmd->progs[0].argv[1]); return FALSE; for (job = jobList->head; job; job = job->next) { @@ -226,7 +226,7 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList) } if (!job) { - fprintf(stderr, "%s: unknown job %d\n", + errorMsg("%s: unknown job %d\n", cmd->progs[0].argv[0], jobNum); return FALSE; } @@ -519,7 +519,7 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr, rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult); if (rc == GLOB_NOSPACE) { - fprintf(stderr, "out of space during glob operation\n"); + errorMsg("out of space during glob operation\n"); return; } else if (rc == GLOB_NOMATCH || (!rc && (prog->globResult.gl_pathc - i) == 1 && @@ -607,7 +607,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi if (*src == '\\') { src++; if (!*src) { - fprintf(stderr, "character expected after \\\n"); + errorMsg("character expected after \\\n"); freeJob(job); return 1; } @@ -686,7 +686,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi chptr++; if (!*chptr) { - fprintf(stderr, "file name expected after %c\n", *src); + errorMsg("file name expected after %c\n", *src); freeJob(job); job->numProgs=0; return 1; @@ -705,7 +705,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi if (*prog->argv[argc]) argc++; if (!argc) { - fprintf(stderr, "empty command in pipe1.\n"); + errorMsg("empty command in pipe1\n"); freeJob(job); job->numProgs=0; return 1; @@ -731,7 +731,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi src++; if (!*src) { - fprintf(stderr, "empty command in pipe2\n"); + errorMsg("empty command in pipe2\n"); freeJob(job); job->numProgs=0; return 1; @@ -750,7 +750,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi case '\\': src++; if (!*src) { - fprintf(stderr, "character expected after \\\n"); + errorMsg("character expected after \\\n"); freeJob(job); return 1; } @@ -965,7 +965,7 @@ static int setupRedirections(struct childProgram *prog) if (openfd < 0) { /* this could get lost if stderr has been redirected, but bash and ash both lose it as well (though zsh doesn't!) */ - fprintf(stderr, "error opening %s: %s\n", redir->filename, + errorMsg("error opening %s: %s\n", redir->filename, strerror(errno)); return 1; } diff --git a/shell/lash.c b/shell/lash.c index f4564f7f7..048394ab6 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -207,12 +207,12 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList) if (!jobList->head) { if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) { - fprintf(stderr, "%s: exactly one argument is expected\n", + errorMsg("%s: exactly one argument is expected\n", cmd->progs[0].argv[0]); return FALSE; } if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) { - fprintf(stderr, "%s: bad argument '%s'\n", + errorMsg("%s: bad argument '%s'\n", cmd->progs[0].argv[0], cmd->progs[0].argv[1]); return FALSE; for (job = jobList->head; job; job = job->next) { @@ -226,7 +226,7 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList) } if (!job) { - fprintf(stderr, "%s: unknown job %d\n", + errorMsg("%s: unknown job %d\n", cmd->progs[0].argv[0], jobNum); return FALSE; } @@ -519,7 +519,7 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr, rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult); if (rc == GLOB_NOSPACE) { - fprintf(stderr, "out of space during glob operation\n"); + errorMsg("out of space during glob operation\n"); return; } else if (rc == GLOB_NOMATCH || (!rc && (prog->globResult.gl_pathc - i) == 1 && @@ -607,7 +607,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi if (*src == '\\') { src++; if (!*src) { - fprintf(stderr, "character expected after \\\n"); + errorMsg("character expected after \\\n"); freeJob(job); return 1; } @@ -686,7 +686,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi chptr++; if (!*chptr) { - fprintf(stderr, "file name expected after %c\n", *src); + errorMsg("file name expected after %c\n", *src); freeJob(job); job->numProgs=0; return 1; @@ -705,7 +705,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi if (*prog->argv[argc]) argc++; if (!argc) { - fprintf(stderr, "empty command in pipe1.\n"); + errorMsg("empty command in pipe1\n"); freeJob(job); job->numProgs=0; return 1; @@ -731,7 +731,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi src++; if (!*src) { - fprintf(stderr, "empty command in pipe2\n"); + errorMsg("empty command in pipe2\n"); freeJob(job); job->numProgs=0; return 1; @@ -750,7 +750,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi case '\\': src++; if (!*src) { - fprintf(stderr, "character expected after \\\n"); + errorMsg("character expected after \\\n"); freeJob(job); return 1; } @@ -965,7 +965,7 @@ static int setupRedirections(struct childProgram *prog) if (openfd < 0) { /* this could get lost if stderr has been redirected, but bash and ash both lose it as well (though zsh doesn't!) */ - fprintf(stderr, "error opening %s: %s\n", redir->filename, + errorMsg("error opening %s: %s\n", redir->filename, strerror(errno)); return 1; } diff --git a/sort.c b/sort.c index a28122d51..c754989ea 100644 --- a/sort.c +++ b/sort.c @@ -263,7 +263,7 @@ int sort_main(int argc, char **argv) break; #endif default: - fprintf(stderr, "sort: invalid option -- %c\n", opt); + errorMsg("invalid option -- %c\n", opt); usage(sort_usage); } } else { @@ -304,4 +304,4 @@ int sort_main(int argc, char **argv) return(0); } -/* $Id: sort.c,v 1.18 2000/06/28 22:15:26 markw Exp $ */ +/* $Id: sort.c,v 1.19 2000/07/14 01:51:25 kraai Exp $ */ diff --git a/sysklogd/logger.c b/sysklogd/logger.c index d32ccaaf3..71d703085 100644 --- a/sysklogd/logger.c +++ b/sysklogd/logger.c @@ -96,7 +96,7 @@ static int pencode(char *s) *s = '\0'; fac = decode(save, facilitynames); if (fac < 0) { - fprintf(stderr, "unknown facility name: %s\n", save); + errorMsg("unknown facility name: %s\n", save); exit(FALSE); } *s++ = '.'; @@ -105,7 +105,7 @@ static int pencode(char *s) } lev = decode(s, prioritynames); if (lev < 0) { - fprintf(stderr, "unknown priority name: %s\n", save); + errorMsg("unknown priority name: %s\n", save); exit(FALSE); } return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)); @@ -166,7 +166,7 @@ extern int logger_main(int argc, char **argv) if (argc >= 1) { message = *argv; } else { - fprintf(stderr, "No message\n"); + errorMsg("No message\n"); exit(FALSE); } } diff --git a/tail.c b/tail.c index 3189d204f..601f0873d 100644 --- a/tail.c +++ b/tail.c @@ -375,7 +375,7 @@ extern int tail_main(int argc, char **argv) usage(tail_usage); default: if ((n_units = atoi(&argv[i][1])) < 1) { - fprintf(stderr, "tail: invalid option -- %c\n", opt); + errorMsg("invalid option -- %c\n", opt); usage(tail_usage); } } @@ -386,8 +386,7 @@ extern int tail_main(int argc, char **argv) if (i + 1 < argc) { if (forever) { - fprintf(stderr, - "tail: option -f is invalid with multiple files\n"); + errorMsg("option -f is invalid with multiple files\n"); usage(tail_usage); } print_headers = 1; diff --git a/tee.c b/tee.c index c9b5410d3..67b42a24d 100644 --- a/tee.c +++ b/tee.c @@ -104,7 +104,7 @@ int tee_main(int argc, char **argv) /* init FILE pointers */ FileList = calloc(FL_MAX, sizeof(FILE*)); if (!FileList) { - fprintf(stderr, "tee: %s\n", strerror(errno)); + errorMsg("%s\n", strerror(errno)); exit(1); } FL_end = 0; @@ -133,4 +133,4 @@ int tee_main(int argc, char **argv) return(0); } -/* $Id: tee.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */ +/* $Id: tee.c,v 1.12 2000/07/14 01:51:25 kraai Exp $ */ diff --git a/umount.c b/umount.c index 59dcb6651..1b250fd3a 100644 --- a/umount.c +++ b/umount.c @@ -101,7 +101,7 @@ void mtab_read(void) return; if ((fp = setmntent(mtab_file, "r")) == NULL) { - fprintf(stderr, "Cannot open %s\n", mtab_file); + errorMsg("Cannot open %s\n", mtab_file); return; } while ((e = getmntent(fp))) { @@ -209,11 +209,9 @@ static int do_umount(const char *name, int useMtab) status = mount(blockDevice, name, NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); if (status == 0) { - fprintf(stderr, "umount: %s busy - remounted read-only\n", - blockDevice); + errorMsg("%s busy - remounted read-only\n", blockDevice); } else { - fprintf(stderr, "umount: Cannot remount %s read-only\n", - blockDevice); + errorMsg("Cannot remount %s read-only\n", blockDevice); } } if (status == 0) { diff --git a/uniq.c b/uniq.c index 64acf046a..16b257670 100644 --- a/uniq.c +++ b/uniq.c @@ -127,11 +127,11 @@ set_file_pointers(int schema, FILE ** in, FILE ** out, char **argv) break; } if (*in == NULL) { - fprintf(stderr, "uniq: %s: %s\n", argv[0], strerror(errno)); + errorMsg("%s: %s\n", argv[0], strerror(errno)); return errno; } if (*out == NULL) { - fprintf(stderr, "uniq: %s: %s\n", argv[1], strerror(errno)); + errorMsg("%s: %s\n", argv[1], strerror(errno)); return errno; } return 0; @@ -187,4 +187,4 @@ int uniq_main(int argc, char **argv) return(0); } -/* $Id: uniq.c,v 1.11 2000/06/19 17:25:40 andersen Exp $ */ +/* $Id: uniq.c,v 1.12 2000/07/14 01:51:25 kraai Exp $ */ diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 9fde6a19d..2fcc7c294 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c @@ -387,7 +387,7 @@ extern int fbset_main(int argc, char **argv) PERROR("fbset(ioctl)"); if (g_options & OPT_READMODE) { if (!readmode(&var, modefile, mode)) { - fprintf(stderr, "Unknown video mode `%s'\n", mode); + errorMsg("Unknown video mode `%s'\n", mode); exit(1); } } diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index 685e0ee6c..74281a71e 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c @@ -311,7 +311,7 @@ static void show_usage(void) static void die(const char *str) { - fprintf(stderr, "%s: %s\n", applet_name, str); + errorMsg("%s\n", str); leave(8); } diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index b6f958f46..e4dedaf82 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c @@ -263,7 +263,7 @@ static unsigned long req_nr_inodes = 0; */ static volatile void die(char *str) { - fprintf(stderr, "%s: %s\n", applet_name, str); + errorMsg("%s\n", str); exit(8); } @@ -814,8 +814,8 @@ extern int mkfs_minix_main(int argc, char **argv) #ifdef HAVE_MINIX2 version2 = 1; #else - fprintf(stderr, "%s: not compiled with minix v2 support\n", - applet_name, device_name); + errorMsg("%s: not compiled with minix v2 support\n", + device_name); exit(-1); #endif break; diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 20096361f..5a33945c8 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c @@ -116,7 +116,7 @@ static void init_signature_page() #ifdef PAGE_SIZE if (pagesize != PAGE_SIZE) - fprintf(stderr, "Assuming pages of size %d\n", pagesize); + errorMsg("Assuming pages of size %d\n", pagesize); #endif signature_page = (int *) xmalloc(pagesize); memset(signature_page, 0, pagesize); @@ -204,7 +204,7 @@ static int bit_test_and_clear(unsigned int *addr, unsigned int nr) void die(const char *str) { - fprintf(stderr, "%s: %s\n", applet_name, str); + errorMsg("%s\n", str); exit(FALSE); } @@ -345,18 +345,14 @@ int mkswap_main(int argc, char **argv) } } if (!device_name) { - fprintf(stderr, - "%s: error: Nowhere to set up swap on?\n", applet_name); + errorMsg("error: Nowhere to set up swap on?\n"); usage(mkswap_usage); } sz = get_size(device_name); if (!PAGES) { PAGES = sz; } else if (PAGES > sz && !force) { - fprintf(stderr, - "%s: error: " - "size %ld is larger than device size %d\n", - applet_name, + errorMsg("error: size %ld is larger than device size %d\n", PAGES * (pagesize / 1024), sz * (pagesize / 1024)); exit(FALSE); } @@ -372,14 +368,12 @@ int mkswap_main(int argc, char **argv) version = 1; } if (version != 0 && version != 1) { - fprintf(stderr, "%s: error: unknown version %d\n", - applet_name, version); + errorMsg("error: unknown version %d\n", version); usage(mkswap_usage); } if (PAGES < 10) { - fprintf(stderr, - "%s: error: swap area needs to be at least %ldkB\n", - applet_name, (long) (10 * pagesize / 1024)); + errorMsg("error: swap area needs to be at least %ldkB\n", + (long) (10 * pagesize / 1024)); usage(mkswap_usage); } #if 0 @@ -397,8 +391,8 @@ int mkswap_main(int argc, char **argv) #endif if (PAGES > maxpages) { PAGES = maxpages; - fprintf(stderr, "%s: warning: truncating swap area to %ldkB\n", - applet_name, PAGES * pagesize / 1024); + errorMsg("warning: truncating swap area to %ldkB\n", + PAGES * pagesize / 1024); } DEV = open(device_name, O_RDWR); @@ -424,11 +418,10 @@ int mkswap_main(int argc, char **argv) for (sum = 0; q >= (unsigned short *) buffer;) sum ^= *q--; if (!sum) { - fprintf(stderr, "\ -%s: Device '%s' contains a valid Sun disklabel.\n\ -This probably means creating v0 swap would destroy your partition table\n\ -No swap created. If you really want to create swap v0 on that device, use\n\ -the -f option to force it.\n", applet_name, device_name); + errorMsg("Device '%s' contains a valid Sun disklabel.\n" +"This probably means creating v0 swap would destroy your partition table\n" +"No swap created. If you really want to create swap v0 on that device, use\n" +"the -f option to force it.\n", device_name); exit(FALSE); } } diff --git a/util-linux/mount.c b/util-linux/mount.c index 900ab30a7..455e4a1c1 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -157,15 +157,15 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, specialfile = find_unused_loop_device(); if (specialfile == NULL) { - fprintf(stderr, "Could not find a spare loop device\n"); + errorMsg("Could not find a spare loop device\n"); return (FALSE); } if (set_loop(specialfile, lofile, 0, &loro)) { - fprintf(stderr, "Could not setup loop device\n"); + errorMsg("Could not setup loop device\n"); return (FALSE); } if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */ - fprintf(stderr, "WARNING: loop device is read-only\n"); + errorMsg("WARNING: loop device is read-only\n"); flags &= ~MS_RDONLY; } } @@ -329,7 +329,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType, if (status == FALSE) { if (whineOnErrors == TRUE) { - fprintf(stderr, "Mounting %s on %s failed: %s\n", + errorMsg("Mounting %s on %s failed: %s\n", blockDevice, directory, strerror(errno)); } return (FALSE); diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c index 8cdfebfce..ad0b5842d 100644 --- a/util-linux/nfsmount.c +++ b/util-linux/nfsmount.c @@ -312,8 +312,7 @@ int nfsmount(const char *spec, const char *node, int *flags, msock = fsock = -1; mclient = NULL; if (strlen(spec) >= sizeof(hostdir)) { - fprintf(stderr, _("mount: " - "excessively long host:dir argument\n")); + errorMsg("excessively long host:dir argument\n"); goto fail; } strcpy(hostdir, spec); @@ -325,12 +324,10 @@ int nfsmount(const char *spec, const char *node, int *flags, until they can be fully supported. (mack@sgi.com) */ if ((s = strchr(hostdir, ','))) { *s = '\0'; - fprintf(stderr, _("mount: warning: " - "multiple hostnames not supported\n")); + errorMsg("warning: multiple hostnames not supported\n"); } } else { - fprintf(stderr, _("mount: " - "directory to mount not in host:dir format\n")); + errorMsg("directory to mount not in host:dir format\n"); goto fail; } @@ -340,13 +337,11 @@ int nfsmount(const char *spec, const char *node, int *flags, #endif { if ((hp = gethostbyname(hostname)) == NULL) { - fprintf(stderr, _("mount: can't get address for %s\n"), - hostname); + errorMsg("can't get address for %s\n", hostname); goto fail; } else { if (hp->h_length > sizeof(struct in_addr)) { - fprintf(stderr, - _("mount: got bad hp->h_length\n")); + errorMsg("got bad hp->h_length\n"); hp->h_length = sizeof(struct in_addr); } memcpy(&server_addr.sin_addr, @@ -363,8 +358,7 @@ int nfsmount(const char *spec, const char *node, int *flags, if (!old_opts) old_opts = ""; if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) { - fprintf(stderr, _("mount: " - "excessively long option argument\n")); + errorMsg("excessively long option argument\n"); goto fail; } sprintf(new_opts, "%s%saddr=%s", @@ -524,11 +518,11 @@ int nfsmount(const char *spec, const char *node, int *flags, data.flags |= (nolock ? NFS_MOUNT_NONLM : 0); #endif if (nfsvers > MAX_NFSPROT) { - fprintf(stderr, "NFSv%d not supported!\n", nfsvers); + errorMsg("NFSv%d not supported!\n", nfsvers); return 0; } if (mountvers > MAX_NFSPROT) { - fprintf(stderr, "NFSv%d not supported!\n", nfsvers); + errorMsg("NFSv%d not supported!\n", nfsvers); return 0; } if (nfsvers && !mountvers) @@ -588,13 +582,11 @@ int nfsmount(const char *spec, const char *node, int *flags, mount_server_addr.sin_addr.s_addr = inet_addr(hostname); } else { if ((hp = gethostbyname(mounthost)) == NULL) { - fprintf(stderr, _("mount: can't get address for %s\n"), - hostname); + errorMsg("can't get address for %s\n", hostname); goto fail; } else { if (hp->h_length > sizeof(struct in_addr)) { - fprintf(stderr, - _("mount: got bad hp->h_length?\n")); + errorMsg("got bad hp->h_length?\n"); hp->h_length = sizeof(struct in_addr); } mount_server_addr.sin_family = AF_INET; @@ -729,8 +721,7 @@ int nfsmount(const char *spec, const char *node, int *flags, if (nfsvers == 2) { if (status.nfsv2.fhs_status != 0) { - fprintf(stderr, - "mount: %s:%s failed, reason given by server: %s\n", + errorMsg("%s:%s failed, reason given by server: %s\n", hostname, dirname, nfs_strerror(status.nfsv2.fhs_status)); goto fail; @@ -748,8 +739,7 @@ int nfsmount(const char *spec, const char *node, int *flags, #if NFS_MOUNT_VERSION >= 4 fhandle3 *fhandle; if (status.nfsv3.fhs_status != 0) { - fprintf(stderr, - "mount: %s:%s failed, reason given by server: %s\n", + errorMsg("%s:%s failed, reason given by server: %s\n", hostname, dirname, nfs_strerror(status.nfsv3.fhs_status)); goto fail; diff --git a/util-linux/umount.c b/util-linux/umount.c index 59dcb6651..1b250fd3a 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c @@ -101,7 +101,7 @@ void mtab_read(void) return; if ((fp = setmntent(mtab_file, "r")) == NULL) { - fprintf(stderr, "Cannot open %s\n", mtab_file); + errorMsg("Cannot open %s\n", mtab_file); return; } while ((e = getmntent(fp))) { @@ -209,11 +209,9 @@ static int do_umount(const char *name, int useMtab) status = mount(blockDevice, name, NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); if (status == 0) { - fprintf(stderr, "umount: %s busy - remounted read-only\n", - blockDevice); + errorMsg("%s busy - remounted read-only\n", blockDevice); } else { - fprintf(stderr, "umount: Cannot remount %s read-only\n", - blockDevice); + errorMsg("Cannot remount %s read-only\n", blockDevice); } } if (status == 0) { diff --git a/utility.c b/utility.c index 61f67618d..2b2156624 100644 --- a/utility.c +++ b/utility.c @@ -299,7 +299,7 @@ copyFile(const char *srcName, const char *destName, if ((srcStatBuf.st_dev == dstStatBuf.st_dev) && (srcStatBuf.st_ino == dstStatBuf.st_ino)) { - fprintf(stderr, "Copying file \"%s\" to itself\n", srcName); + errorMsg("Copying file \"%s\" to itself\n", srcName); return FALSE; } @@ -630,7 +630,7 @@ int recursiveAction(const char *fileName, continue; } if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) { - fprintf(stderr, name_too_long, "ftw"); + errorMsg(name_too_long); return FALSE; } memset(nextFile, 0, sizeof(nextFile)); @@ -995,8 +995,7 @@ int get_console_fd(char *tty_name) if (is_a_console(fd)) return fd; - fprintf(stderr, - "Couldnt get a file descriptor referring to the console\n"); + errorMsg("Couldnt get a file descriptor referring to the console\n"); return -1; /* total failure */ } diff --git a/whoami.c b/whoami.c index 983c6725d..01dff81f9 100644 --- a/whoami.c +++ b/whoami.c @@ -43,7 +43,6 @@ extern int whoami_main(int argc, char **argv) puts(user); exit(TRUE); } - fprintf(stderr, "%s: cannot find username for UID %u\n", applet_name, - (unsigned) uid); + errorMsg("cannot find username for UID %u\n", (unsigned) uid); return(FALSE); }