Use errorMsg rather than fprintf.

This commit is contained in:
Matt Kraai 2000-07-14 01:51:25 +00:00
parent 4ac6cb534d
commit d537a95fdb
81 changed files with 391 additions and 473 deletions

View File

@ -392,7 +392,7 @@ static char *busybox_fullpath()
if (len != -1) { if (len != -1) {
path[len] = 0; path[len] = 0;
} else { } else {
fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno)); errorMsg("%s: %s\n", proc, strerror(errno));
return NULL; return NULL;
} }
return strdup(path); return strdup(path);
@ -422,7 +422,7 @@ static int install_links(const char *busybox, int use_symbolic_links)
puts(command); puts(command);
#endif #endif
if (rc) { if (rc) {
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno)); errorMsg("%s: %s\n", command, strerror(errno));
} }
} }
return rc; return rc;
@ -438,6 +438,7 @@ int main(int argc, char **argv)
{ {
char *s; char *s;
const struct BB_applet *a = applets; const struct BB_applet *a = applets;
applet_name = "busybox";
#ifdef BB_FEATURE_INSTALLER #ifdef BB_FEATURE_INSTALLER
/* /*

View File

@ -659,7 +659,7 @@ int gunzip_main(int argc, char **argv)
if (*argv == '\0') if (*argv == '\0')
usage(gunzip_usage); usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) { if (strlen(*argv) > MAX_PATH_LEN) {
fprintf(stderr, name_too_long, "gunzip"); errorMsg(name_too_long);
exit(WARNING); exit(WARNING);
} }
strcpy(ifname, *argv); strcpy(ifname, *argv);
@ -698,7 +698,7 @@ int gunzip_main(int argc, char **argv)
/* And get to work */ /* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) { if (strlen(ifname) > MAX_PATH_LEN - 4) {
fprintf(stderr, name_too_long, "gunzip"); errorMsg(name_too_long);
exit(WARNING); exit(WARNING);
} }
strcpy(ofname, ifname); strcpy(ofname, ifname);
@ -780,8 +780,7 @@ int in; /* input file descriptor */
method = (int) get_byte(); method = (int) get_byte();
if (method != DEFLATED) { if (method != DEFLATED) {
fprintf(stderr, errorMsg("unknown method %d -- get newer version of gzip\n",
"unknown method %d -- get newer version of gzip\n",
method); method);
exit_code = ERROR; exit_code = ERROR;
return -1; return -1;

View File

@ -392,7 +392,7 @@ static char *busybox_fullpath()
if (len != -1) { if (len != -1) {
path[len] = 0; path[len] = 0;
} else { } else {
fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno)); errorMsg("%s: %s\n", proc, strerror(errno));
return NULL; return NULL;
} }
return strdup(path); return strdup(path);
@ -422,7 +422,7 @@ static int install_links(const char *busybox, int use_symbolic_links)
puts(command); puts(command);
#endif #endif
if (rc) { if (rc) {
fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno)); errorMsg("%s: %s\n", command, strerror(errno));
} }
} }
return rc; return rc;
@ -438,6 +438,7 @@ int main(int argc, char **argv)
{ {
char *s; char *s;
const struct BB_applet *a = applets; const struct BB_applet *a = applets;
applet_name = "busybox";
#ifdef BB_FEATURE_INSTALLER #ifdef BB_FEATURE_INSTALLER
/* /*

View File

@ -123,7 +123,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
recursiveFlag = TRUE; recursiveFlag = TRUE;
break; break;
default: default:
fprintf(stderr, invalid_option, applet_name, **argv); errorMsg(invalid_option, **argv);
usage(appUsage); usage(appUsage);
} }
} }
@ -131,7 +131,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
} }
if (argc == 0 || *argv == NULL) { if (argc == 0 || *argv == NULL) {
fprintf(stderr, too_few_args, applet_name); errorMsg(too_few_args);
usage(appUsage); usage(appUsage);
} }
@ -176,7 +176,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
/* Ok, ready to do the deed now */ /* Ok, ready to do the deed now */
if (argc <= 1) { if (argc <= 1) {
fatalError( "too few arguments\n"); fatalError(too_few_args);
} }
while (argc-- > 1) { while (argc-- > 1) {
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE, if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,

View File

@ -39,14 +39,12 @@ int deallocvt_main(int argc, char *argv[])
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
num = atoi(argv[i]); num = atoi(argv[i]);
if (num == 0) if (num == 0)
fprintf(stderr, "%s: 0: illegal VT number\n", applet_name); errorMsg("0: illegal VT number\n");
else if (num == 1) else if (num == 1)
fprintf(stderr, "%s: VT 1 cannot be deallocated\n", errorMsg("VT 1 cannot be deallocated\n");
applet_name);
else if (ioctl(fd, VT_DISALLOCATE, num)) { else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE"); perror("VT_DISALLOCATE");
fprintf(stderr, "%s: could not deallocate console %d\n", errorMsg("could not deallocate console %d\n", num);
applet_name, num);
exit( FALSE); exit( FALSE);
} }
} }

View File

@ -58,7 +58,7 @@ int dumpkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return 1; return 1;
} }
@ -86,7 +86,7 @@ int dumpkmap_main(int argc, char **argv)
ke.kb_table = i; ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) { 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 { else {
write(1,&ke.kb_value,2); write(1,&ke.kb_value,2);

View File

@ -46,12 +46,12 @@ int loadacm_main(int argc, char **argv)
fd = open("/dev/tty", O_RDWR); fd = open("/dev/tty", O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno)); errorMsg("Error opening /dev/tty1: %s\n", strerror(errno));
return( FALSE); return( FALSE);
} }
if (screen_map_load(fd, stdin)) { 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); return( FALSE);
} }
@ -79,8 +79,7 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) { if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
fprintf(stderr, errorMsg("16bit screen-map MUST be a regular file.\n"),
"16bit screen-map MUST be a regular file.\n"),
exit(1); exit(1);
else else
perror("fseek failed reading binary 16bit screen-map"), 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); perror("Cannot read [new] map from file"), exit(1);
#if 0 #if 0
else else
fprintf(stderr, "Input screen-map is binary.\n"); errorMsg("Input screen-map is binary.\n");
#endif #endif
} }
@ -108,8 +107,7 @@ int screen_map_load(int fd, FILE * fp)
/* rewind... */ /* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
fprintf(stderr, errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"),
"Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1); exit(1);
else else
perror("fseek failed assuming 8bit screen-map"), exit(1); 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 (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
/* should not - it succedeed above */ /* should not - it succedeed above */
fprintf(stderr, "fseek() returned ESPIPE !\n"), errorMsg("fseek() returned ESPIPE !\n"),
exit(1); exit(1);
else else
perror("fseek for binary 8bit screen-map"), exit(1); 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); perror("Cannot read [old] map from file"), exit(1);
#if 0 #if 0
else else
fprintf(stderr, "Input screen-map is binary.\n"); errorMsg("Input screen-map is binary.\n");
#endif #endif
} }
@ -141,7 +139,7 @@ int screen_map_load(int fd, FILE * fp)
else else
return 0; return 0;
} }
fprintf(stderr, "Error parsing symbolic map\n"); errorMsg("Error parsing symbolic map\n");
return(1); return(1);
} }

View File

@ -56,7 +56,7 @@ extern int loadfont_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return( FALSE); return( FALSE);
} }
loadnewfont(fd); loadnewfont(fd);
@ -72,7 +72,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32) { if (unit < 1 || unit > 32) {
fprintf(stderr, "Bad character size %d\n", unit); errorMsg("Bad character size %d\n", unit);
exit(1); 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)); up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
if (!up) { if (!up) {
fprintf(stderr, "Out of memory?\n"); errorMsg("Out of memory?\n");
exit(1); exit(1);
} }
for (glyph = 0; glyph < fontsize; glyph++) { 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)) { if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD #ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) { if (errno == ENOIOCTLCMD) {
fprintf(stderr, "It seems this kernel is older than 1.1.92\n"); errorMsg("It seems this kernel is older than 1.1.92\n");
fprintf(stderr, "No Unicode mapping table loaded.\n"); errorMsg("No Unicode mapping table loaded.\n");
} else } else
#endif #endif
perror("PIO_UNIMAPCLR"); perror("PIO_UNIMAPCLR");
@ -198,13 +198,13 @@ static void loadnewfont(int fd)
goto no_psf; goto no_psf;
if (psfhdr.mode > PSF_MAXMODE) { if (psfhdr.mode > PSF_MAXMODE) {
fprintf(stderr, "Unsupported psf file mode\n"); errorMsg("Unsupported psf file mode\n");
exit(1); exit(1);
} }
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ ) #if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256) { if (fontsize != 256) {
fprintf(stderr, "Only fontsize 256 supported\n"); errorMsg("Only fontsize 256 supported\n");
exit(1); exit(1);
} }
#endif #endif
@ -214,7 +214,7 @@ static void loadnewfont(int fd)
head = head0 + fontsize * unit; head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth)) { if (head > inputlth || (!hastable && head != inputlth)) {
fprintf(stderr, "Input file: bad length\n"); errorMsg("Input file: bad length\n");
exit(1); exit(1);
} }
do_loadfont(fd, inbuf + head0, unit, fontsize); do_loadfont(fd, inbuf + head0, unit, fontsize);
@ -231,7 +231,7 @@ static void loadnewfont(int fd)
} else { } else {
/* bare font */ /* bare font */
if (inputlth & 0377) { if (inputlth & 0377) {
fprintf(stderr, "Bad input file size\n"); errorMsg("Bad input file size\n");
exit(1); exit(1);
} }
offset = 0; offset = 0;

View File

@ -59,25 +59,25 @@ int loadkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
exit(FALSE); exit(FALSE);
} }
read(0, buff, 7); read(0, buff, 7);
if (0 != strncmp(buff, magic, 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); exit(FALSE);
} }
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) { 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)); strerror(errno));
exit(FALSE); exit(FALSE);
} }
ibuff = (u_short *) malloc(ibuffsz); ibuff = (u_short *) malloc(ibuffsz);
if (!ibuff) { if (!ibuff) {
fprintf(stderr, "Out of memory.\n"); errorMsg("Out of memory.\n");
exit(FALSE); exit(FALSE);
} }
@ -87,7 +87,7 @@ int loadkmap_main(int argc, char **argv)
while (pos < ibuffsz) { while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
< 0) { < 0) {
fprintf(stderr, "Error reading keymap: %s\n", errorMsg("Error reading keymap: %s\n",
strerror(errno)); strerror(errno));
exit(FALSE); exit(FALSE);
} }

View File

@ -84,13 +84,13 @@ void cut(void);
void warn(int warn_number, char *option) void warn(int warn_number, char *option)
{ {
static char *warn_msg[] = { static char *warn_msg[] = {
"%s: Option -%s allowed only with -f\n", "Option -%s allowed only with -f\n",
"%s: -%s overrides earlier option\n", "-%s overrides earlier option\n",
"%s: -%s not allowed in current mode\n", "-%s not allowed in current mode\n",
"%s: Cannot open %s\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; exit_status = warn_number + 1;
} }
@ -98,15 +98,15 @@ void warn(int warn_number, char *option)
void cuterror(int err) void cuterror(int err)
{ {
static char *err_mes[] = { static char *err_mes[] = {
"%s: syntax error\n", "syntax error\n",
"%s: position must be >0\n", "position must be >0\n",
"%s: line longer than BUFSIZ\n", "line longer than BUFSIZ\n",
"%s: range must not decrease from left to right\n", "range must not decrease from left to right\n",
"%s: MAX_FIELD exceeded\n", "MAX_FIELD exceeded\n",
"%s: MAX_ARGS exceeded\n" "MAX_ARGS exceeded\n"
}; };
fprintf(stderr, err_mes[err - 101], applet_name); errorMsg(err_mes[err - 101]);
exit(err); exit(err);
} }

View File

@ -86,26 +86,26 @@ extern int dd_main(int argc, char **argv)
else if (strncmp("count", *argv, 5) == 0) { else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1); count = getNum((strchr(*argv, '=')) + 1);
if (count <= 0) { if (count <= 0) {
fprintf(stderr, "Bad count value %s\n", *argv); errorMsg("Bad count value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "bs", 2) == 0) { } else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1); blockSize = getNum((strchr(*argv, '=')) + 1);
if (blockSize <= 0) { if (blockSize <= 0) {
fprintf(stderr, "Bad block size value %s\n", *argv); errorMsg("Bad block size value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "skip", 4) == 0) { } else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1); skipBlocks = getNum((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) { if (skipBlocks <= 0) {
fprintf(stderr, "Bad skip value %s\n", *argv); errorMsg("Bad skip value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "seek", 4) == 0) { } else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1); seekBlocks = getNum((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) { if (seekBlocks <= 0) {
fprintf(stderr, "Bad seek value %s\n", *argv); errorMsg("Bad seek value %s\n", *argv);
goto usage; goto usage;
} }

View File

@ -82,7 +82,7 @@ extern int df_main(int argc, char **argv)
} }
while (argc > 1) { while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { 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); exit(FALSE);
} }
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);

View File

@ -108,7 +108,7 @@ static long du(char *filename)
} }
if (len + strlen(name) + 1 > BUFSIZ) { if (len + strlen(name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "du"); errorMsg(name_too_long);
du_depth--; du_depth--;
return 0; return 0;
} }
@ -158,7 +158,7 @@ int du_main(int argc, char **argv)
usage(du_usage); usage(du_usage);
break; break;
default: default:
fprintf(stderr, "du: invalid option -- %c\n", opt); errorMsg("invalid option -- %c\n", opt);
usage(du_usage); usage(du_usage);
} }
} else { } else {
@ -184,7 +184,7 @@ int du_main(int argc, char **argv)
return(0); 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: Local Variables:
c-file-style: "linux" c-file-style: "linux"

View File

@ -75,7 +75,7 @@ int head_main(int argc, char **argv)
case 'h': case 'h':
usage(head_usage); usage(head_usage);
default: default:
fprintf(stderr, "head: invalid option -- %c\n", opt); errorMsg("invalid option -- %c\n", opt);
usage(head_usage); usage(head_usage);
} }
} else { } else {
@ -95,8 +95,7 @@ int head_main(int argc, char **argv)
src = fopen(argv[i], "r"); src = fopen(argv[i], "r");
if (!src) { if (!src) {
fprintf(stderr, "head: %s: %s\n", argv[i], errorMsg("%s: %s\n", argv[i], strerror(errno));
strerror(errno));
} else { } else {
/* emulating GNU behaviour */ /* emulating GNU behaviour */
if (need_headers) { if (need_headers) {
@ -112,4 +111,4 @@ int head_main(int argc, char **argv)
return(0); 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 $ */

View File

@ -23,7 +23,6 @@
#include "internal.h" #include "internal.h"
#define BB_DECLARE_EXTERN #define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#define bb_need_not_a_directory #define bb_need_not_a_directory
#include "messages.c" #include "messages.c"
@ -92,7 +91,7 @@ extern int ln_main(int argc, char **argv)
linkIntoDirFlag = isDirectory(linkName, followLinks, NULL); linkIntoDirFlag = isDirectory(linkName, followLinks, NULL);
if ((argc >= 3) && linkIntoDirFlag == FALSE) { if ((argc >= 3) && linkIntoDirFlag == FALSE) {
fprintf(stderr, not_a_directory, "ln", linkName); errorMsg(not_a_directory, linkName);
exit FALSE; exit FALSE;
} }

View File

@ -41,6 +41,6 @@ extern int logname_main(int argc, char **argv)
puts(user); puts(user);
exit(TRUE); exit(TRUE);
} }
fprintf(stderr, "no login name\n"); errorMsg("no login name\n");
return(FALSE); return(FALSE);
} }

View File

@ -62,7 +62,7 @@ extern int mkdir_main(int argc, char **argv)
/* Find the specified modes */ /* Find the specified modes */
mode = 0; mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) { if (parse_mode(*(++argv), &mode) == FALSE) {
fprintf(stderr, "Unknown mode: %s\n", *argv); errorMsg("Unknown mode: %s\n", *argv);
exit FALSE; exit FALSE;
} }
/* Set the umask for this process so it doesn't /* 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]; char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) { if (strlen(*argv) > BUFSIZ - 1) {
fprintf(stderr, name_too_long, "mkdir"); errorMsg(name_too_long);
exit FALSE; exit FALSE;
} }
strcpy(buf, *argv); strcpy(buf, *argv);
status = stat(buf, &statBuf); status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) { if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
fprintf(stderr, "%s: File exists\n", buf); errorMsg("%s: File exists\n", buf);
exit FALSE; exit FALSE;
} }
if (parentFlag == TRUE) { if (parentFlag == TRUE) {

View File

@ -40,7 +40,7 @@ extern int rmdir_main(int argc, char **argv)
while (--argc > 0) { while (--argc > 0) {
if (rmdir(*(++argv)) == -1) { if (rmdir(*(++argv)) == -1) {
fprintf(stderr, "%s: %s\n", applet_name, strerror(errno)); errorMsg("%s\n", strerror(errno));
exit(FALSE); exit(FALSE);
} }
} }

View File

@ -263,7 +263,7 @@ int sort_main(int argc, char **argv)
break; break;
#endif #endif
default: default:
fprintf(stderr, "sort: invalid option -- %c\n", opt); errorMsg("invalid option -- %c\n", opt);
usage(sort_usage); usage(sort_usage);
} }
} else { } else {
@ -304,4 +304,4 @@ int sort_main(int argc, char **argv)
return(0); 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 $ */

View File

@ -375,7 +375,7 @@ extern int tail_main(int argc, char **argv)
usage(tail_usage); usage(tail_usage);
default: default:
if ((n_units = atoi(&argv[i][1])) < 1) { 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); usage(tail_usage);
} }
} }
@ -386,8 +386,7 @@ extern int tail_main(int argc, char **argv)
if (i + 1 < argc) { if (i + 1 < argc) {
if (forever) { if (forever) {
fprintf(stderr, errorMsg("option -f is invalid with multiple files\n");
"tail: option -f is invalid with multiple files\n");
usage(tail_usage); usage(tail_usage);
} }
print_headers = 1; print_headers = 1;

View File

@ -104,7 +104,7 @@ int tee_main(int argc, char **argv)
/* init FILE pointers */ /* init FILE pointers */
FileList = calloc(FL_MAX, sizeof(FILE*)); FileList = calloc(FL_MAX, sizeof(FILE*));
if (!FileList) { if (!FileList) {
fprintf(stderr, "tee: %s\n", strerror(errno)); errorMsg("%s\n", strerror(errno));
exit(1); exit(1);
} }
FL_end = 0; FL_end = 0;
@ -133,4 +133,4 @@ int tee_main(int argc, char **argv)
return(0); 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 $ */

View File

@ -127,11 +127,11 @@ set_file_pointers(int schema, FILE ** in, FILE ** out, char **argv)
break; break;
} }
if (*in == NULL) { if (*in == NULL) {
fprintf(stderr, "uniq: %s: %s\n", argv[0], strerror(errno)); errorMsg("%s: %s\n", argv[0], strerror(errno));
return errno; return errno;
} }
if (*out == NULL) { if (*out == NULL) {
fprintf(stderr, "uniq: %s: %s\n", argv[1], strerror(errno)); errorMsg("%s: %s\n", argv[1], strerror(errno));
return errno; return errno;
} }
return 0; return 0;
@ -187,4 +187,4 @@ int uniq_main(int argc, char **argv)
return(0); 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 $ */

View File

@ -43,7 +43,6 @@ extern int whoami_main(int argc, char **argv)
puts(user); puts(user);
exit(TRUE); exit(TRUE);
} }
fprintf(stderr, "%s: cannot find username for UID %u\n", applet_name, errorMsg("cannot find username for UID %u\n", (unsigned) uid);
(unsigned) uid);
return(FALSE); return(FALSE);
} }

39
cp_mv.c
View File

@ -89,8 +89,7 @@ static void name_too_long__exit (void) __attribute__((noreturn));
static static
void name_too_long__exit (void) void name_too_long__exit (void)
{ {
fprintf(stderr, name_too_long, applet_name); fatalError(name_too_long);
exit(FALSE);
} }
static void static void
@ -124,14 +123,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (srcDirFlag == TRUE) { if (srcDirFlag == TRUE) {
if (recursiveFlag == FALSE) { if (recursiveFlag == FALSE) {
fprintf(stderr, omitting_directory, applet_name, baseSrcName); errorMsg(omitting_directory, baseSrcName);
return TRUE; return TRUE;
} }
srcBasename = (strstr(fileName, baseSrcName) srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName)); + strlen(baseSrcName));
if (destLen + strlen(srcBasename) > BUFSIZ) { if (destLen + strlen(srcBasename) > BUFSIZ) {
fprintf(stderr, name_too_long, applet_name); errorMsg(name_too_long);
return FALSE; return FALSE;
} }
strcat(destName, srcBasename); 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)) { if (mv_Action_first_time && (dz_i == is_mv)) {
mv_Action_first_time = errno = 0; mv_Action_first_time = errno = 0;
if (rename(fileName, destName) < 0 && errno != EXDEV) { if (rename(fileName, destName) < 0 && errno != EXDEV) {
fprintf(stderr, "%s: rename(%s, %s): %s\n", errorMsg("rename(%s, %s): %s\n", fileName, destName,
applet_name, fileName, destName, strerror(errno)); strerror(errno));
goto do_copyFile; /* Try anyway... */ goto do_copyFile; /* Try anyway... */
} }
else if (errno == EXDEV) 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 (preserveFlag == TRUE && statbuf->st_nlink > 1) {
if (is_in_ino_dev_hashtable(statbuf, &name)) { if (is_in_ino_dev_hashtable(statbuf, &name)) {
if (link(name, destName) < 0) { if (link(name, destName) < 0) {
fprintf(stderr, "%s: link(%s, %s): %s\n", errorMsg("link(%s, %s): %s\n", name, destName, strerror(errno));
applet_name, name, destName, strerror(errno));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -178,11 +176,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
if (S_ISDIR(statbuf->st_mode)) { if (S_ISDIR(statbuf->st_mode)) {
if (rmdir(fileName) < 0) { 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; status = FALSE;
} }
} else if (unlink(fileName) < 0) { } 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; status = FALSE;
} }
return status; return status;
@ -236,7 +234,7 @@ extern int cp_mv_main(int argc, char **argv)
if (strlen(argv[argc - 1]) > BUFSIZ) { if (strlen(argv[argc - 1]) > BUFSIZ) {
fprintf(stderr, name_too_long, "cp"); errorMsg(name_too_long);
goto exit_false; goto exit_false;
} }
strcpy(baseDestName, argv[argc - 1]); strcpy(baseDestName, argv[argc - 1]);
@ -246,7 +244,7 @@ extern int cp_mv_main(int argc, char **argv)
destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf); destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf);
if ((argc > 3) && destDirFlag == FALSE) { if ((argc > 3) && destDirFlag == FALSE) {
fprintf(stderr, not_a_directory, "cp", baseDestName); errorMsg(not_a_directory, baseDestName);
goto exit_false; goto exit_false;
} }
@ -272,29 +270,28 @@ extern int cp_mv_main(int argc, char **argv)
char *pushd, *d, *p; char *pushd, *d, *p;
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno)); errorMsg("getcwd(): %s\n", strerror(errno));
continue; continue;
} }
if (chdir(baseDestName) < 0) { 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; continue;
} }
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno)); errorMsg("getcwd(): %s\n", strerror(errno));
continue; continue;
} }
while (!state && *d != '\0') { while (!state && *d != '\0') {
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ 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; state = -1;
continue; continue;
} }
if ((sb.st_ino == srcStatBuf.st_ino) && if ((sb.st_ino == srcStatBuf.st_ino) &&
(sb.st_dev == srcStatBuf.st_dev)) { (sb.st_dev == srcStatBuf.st_dev)) {
fprintf(stderr, errorMsg("Cannot %s `%s' into a subdirectory of itself, "
"%s: Cannot %s `%s' " "`%s/%s'\n", applet_name, baseSrcName,
"into a subdirectory of itself, `%s/%s'\n", baseDestName, baseSrcName);
applet_name, applet_name, baseSrcName, baseDestName, baseSrcName);
state = -1; state = -1;
continue; continue;
} }
@ -303,7 +300,7 @@ extern int cp_mv_main(int argc, char **argv)
} }
} }
if (chdir(pushd) < 0) { 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(pushd);
free(d); free(d);
continue; continue;

24
cut.c
View File

@ -84,13 +84,13 @@ void cut(void);
void warn(int warn_number, char *option) void warn(int warn_number, char *option)
{ {
static char *warn_msg[] = { static char *warn_msg[] = {
"%s: Option -%s allowed only with -f\n", "Option -%s allowed only with -f\n",
"%s: -%s overrides earlier option\n", "-%s overrides earlier option\n",
"%s: -%s not allowed in current mode\n", "-%s not allowed in current mode\n",
"%s: Cannot open %s\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; exit_status = warn_number + 1;
} }
@ -98,15 +98,15 @@ void warn(int warn_number, char *option)
void cuterror(int err) void cuterror(int err)
{ {
static char *err_mes[] = { static char *err_mes[] = {
"%s: syntax error\n", "syntax error\n",
"%s: position must be >0\n", "position must be >0\n",
"%s: line longer than BUFSIZ\n", "line longer than BUFSIZ\n",
"%s: range must not decrease from left to right\n", "range must not decrease from left to right\n",
"%s: MAX_FIELD exceeded\n", "MAX_FIELD exceeded\n",
"%s: MAX_ARGS exceeded\n" "MAX_ARGS exceeded\n"
}; };
fprintf(stderr, err_mes[err - 101], applet_name); errorMsg(err_mes[err - 101]);
exit(err); exit(err);
} }

6
dc.c
View File

@ -22,7 +22,7 @@ static unsigned int pointer;
static void push(double a) static void push(double a)
{ {
if (pointer >= (sizeof(stack) / sizeof(*stack))) { if (pointer >= (sizeof(stack) / sizeof(*stack))) {
fprintf(stderr, "dc: stack overflow\n"); errorMsg("stack overflow\n");
exit(-1); exit(-1);
} else } else
stack[pointer++] = a; stack[pointer++] = a;
@ -31,7 +31,7 @@ static void push(double a)
static double pop() static double pop()
{ {
if (pointer == 0) { if (pointer == 0) {
fprintf(stderr, "dc: stack underflow\n"); errorMsg("stack underflow\n");
exit(-1); exit(-1);
} }
return stack[--pointer]; return stack[--pointer];
@ -132,7 +132,7 @@ static void stack_machine(const char *argument)
} }
o++; o++;
} }
fprintf(stderr, "dc: %s: syntax error.\n", argument); errorMsg("%s: syntax error.\n", argument);
exit(-1); exit(-1);
} }

8
dd.c
View File

@ -86,26 +86,26 @@ extern int dd_main(int argc, char **argv)
else if (strncmp("count", *argv, 5) == 0) { else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1); count = getNum((strchr(*argv, '=')) + 1);
if (count <= 0) { if (count <= 0) {
fprintf(stderr, "Bad count value %s\n", *argv); errorMsg("Bad count value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "bs", 2) == 0) { } else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1); blockSize = getNum((strchr(*argv, '=')) + 1);
if (blockSize <= 0) { if (blockSize <= 0) {
fprintf(stderr, "Bad block size value %s\n", *argv); errorMsg("Bad block size value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "skip", 4) == 0) { } else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1); skipBlocks = getNum((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) { if (skipBlocks <= 0) {
fprintf(stderr, "Bad skip value %s\n", *argv); errorMsg("Bad skip value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "seek", 4) == 0) { } else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1); seekBlocks = getNum((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) { if (seekBlocks <= 0) {
fprintf(stderr, "Bad seek value %s\n", *argv); errorMsg("Bad seek value %s\n", *argv);
goto usage; goto usage;
} }

View File

@ -39,14 +39,12 @@ int deallocvt_main(int argc, char *argv[])
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
num = atoi(argv[i]); num = atoi(argv[i]);
if (num == 0) if (num == 0)
fprintf(stderr, "%s: 0: illegal VT number\n", applet_name); errorMsg("0: illegal VT number\n");
else if (num == 1) else if (num == 1)
fprintf(stderr, "%s: VT 1 cannot be deallocated\n", errorMsg("VT 1 cannot be deallocated\n");
applet_name);
else if (ioctl(fd, VT_DISALLOCATE, num)) { else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE"); perror("VT_DISALLOCATE");
fprintf(stderr, "%s: could not deallocate console %d\n", errorMsg("could not deallocate console %d\n", num);
applet_name, num);
exit( FALSE); exit( FALSE);
} }
} }

2
df.c
View File

@ -82,7 +82,7 @@ extern int df_main(int argc, char **argv)
} }
while (argc > 1) { while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { 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); exit(FALSE);
} }
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir); status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);

6
du.c
View File

@ -108,7 +108,7 @@ static long du(char *filename)
} }
if (len + strlen(name) + 1 > BUFSIZ) { if (len + strlen(name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "du"); errorMsg(name_too_long);
du_depth--; du_depth--;
return 0; return 0;
} }
@ -158,7 +158,7 @@ int du_main(int argc, char **argv)
usage(du_usage); usage(du_usage);
break; break;
default: default:
fprintf(stderr, "du: invalid option -- %c\n", opt); errorMsg("invalid option -- %c\n", opt);
usage(du_usage); usage(du_usage);
} }
} else { } else {
@ -184,7 +184,7 @@ int du_main(int argc, char **argv)
return(0); 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: Local Variables:
c-file-style: "linux" c-file-style: "linux"

View File

@ -58,7 +58,7 @@ int dumpkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return 1; return 1;
} }
@ -86,7 +86,7 @@ int dumpkmap_main(int argc, char **argv)
ke.kb_table = i; ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) { 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 { else {
write(1,&ke.kb_value,2); write(1,&ke.kb_value,2);

View File

@ -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 '/' */ idx++; /* so it points to the next character after the last '/' */
} }
else { else {
fprintf(stderr, "sed.c:get_address: no address found in string\n"); errorMsg("get_address: no address found in string\n"
fprintf(stderr, "\t(you probably didn't check the string you passed me)\n"); "\t(you probably didn't check the string you passed me)\n");
idx = -1; idx = -1;
} }
@ -612,7 +612,7 @@ extern int sed_main(int argc, char **argv)
for (i = optind; i < argc; i++) { for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r"); file = fopen(argv[i], "r");
if (file == NULL) { if (file == NULL) {
fprintf(stderr, "sed: %s: %s\n", argv[i], strerror(errno)); errorMsg("%s: %s\n", argv[i], strerror(errno));
} else { } else {
process_file(file); process_file(file);
fclose(file); fclose(file);

View File

@ -387,7 +387,7 @@ extern int fbset_main(int argc, char **argv)
PERROR("fbset(ioctl)"); PERROR("fbset(ioctl)");
if (g_options & OPT_READMODE) { if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) { if (!readmode(&var, modefile, mode)) {
fprintf(stderr, "Unknown video mode `%s'\n", mode); errorMsg("Unknown video mode `%s'\n", mode);
exit(1); exit(1);
} }
} }

View File

@ -165,7 +165,7 @@ extern int grep_main(int argc, char **argv)
file = fopen(cur_file, "r"); file = fopen(cur_file, "r");
if (file == NULL) { if (file == NULL) {
if (!suppress_err_msgs) if (!suppress_err_msgs)
fprintf(stderr, "grep: %s: %s\n", cur_file, strerror(errno)); errorMsg("%s: %s\n", cur_file, strerror(errno));
} else { } else {
grep_file(file); grep_file(file);
fclose(file); fclose(file);

View File

@ -311,7 +311,7 @@ static void show_usage(void)
static void die(const char *str) static void die(const char *str)
{ {
fprintf(stderr, "%s: %s\n", applet_name, str); errorMsg("%s\n", str);
leave(8); leave(8);
} }

2
grep.c
View File

@ -165,7 +165,7 @@ extern int grep_main(int argc, char **argv)
file = fopen(cur_file, "r"); file = fopen(cur_file, "r");
if (file == NULL) { if (file == NULL) {
if (!suppress_err_msgs) if (!suppress_err_msgs)
fprintf(stderr, "grep: %s: %s\n", cur_file, strerror(errno)); errorMsg("%s: %s\n", cur_file, strerror(errno));
} else { } else {
grep_file(file); grep_file(file);
fclose(file); fclose(file);

View File

@ -659,7 +659,7 @@ int gunzip_main(int argc, char **argv)
if (*argv == '\0') if (*argv == '\0')
usage(gunzip_usage); usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) { if (strlen(*argv) > MAX_PATH_LEN) {
fprintf(stderr, name_too_long, "gunzip"); errorMsg(name_too_long);
exit(WARNING); exit(WARNING);
} }
strcpy(ifname, *argv); strcpy(ifname, *argv);
@ -698,7 +698,7 @@ int gunzip_main(int argc, char **argv)
/* And get to work */ /* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) { if (strlen(ifname) > MAX_PATH_LEN - 4) {
fprintf(stderr, name_too_long, "gunzip"); errorMsg(name_too_long);
exit(WARNING); exit(WARNING);
} }
strcpy(ofname, ifname); strcpy(ofname, ifname);
@ -780,8 +780,7 @@ int in; /* input file descriptor */
method = (int) get_byte(); method = (int) get_byte();
if (method != DEFLATED) { if (method != DEFLATED) {
fprintf(stderr, errorMsg("unknown method %d -- get newer version of gzip\n",
"unknown method %d -- get newer version of gzip\n",
method); method);
exit_code = ERROR; exit_code = ERROR;
return -1; return -1;

7
head.c
View File

@ -75,7 +75,7 @@ int head_main(int argc, char **argv)
case 'h': case 'h':
usage(head_usage); usage(head_usage);
default: default:
fprintf(stderr, "head: invalid option -- %c\n", opt); errorMsg("invalid option -- %c\n", opt);
usage(head_usage); usage(head_usage);
} }
} else { } else {
@ -95,8 +95,7 @@ int head_main(int argc, char **argv)
src = fopen(argv[i], "r"); src = fopen(argv[i], "r");
if (!src) { if (!src) {
fprintf(stderr, "head: %s: %s\n", argv[i], errorMsg("%s: %s\n", argv[i], strerror(errno));
strerror(errno));
} else { } else {
/* emulating GNU behaviour */ /* emulating GNU behaviour */
if (need_headers) { if (need_headers) {
@ -112,4 +111,4 @@ int head_main(int argc, char **argv)
return(0); 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 $ */

View File

@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */ /* 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 * Mini hostname implementation for busybox
* *
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org> * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@ -55,8 +55,7 @@ void do_sethostname(char *s, int isfile)
if (!isfile) { if (!isfile) {
if (sethostname(s, strlen(s)) < 0) { if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM) if (errno == EPERM)
fprintf(stderr, errorMsg("you must be root to change the hostname\n");
"hostname: you must be root to change the hostname\n");
else else
perror("sethostname"); perror("sethostname");
exit(1); exit(1);

View File

@ -70,7 +70,7 @@
#ifndef MODUTILS_MODULE_H #ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1 #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. /* 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 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 #ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1 #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. */ /* 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 /* Don't report an error if the symbol is coming from
the kernel or some external module. */ the kernel or some external module. */
if (secidx <= SHN_HIRESERVE) if (secidx <= SHN_HIRESERVE)
fprintf(stderr, "%s multiply defined\n", name); errorMsg("%s multiply defined\n", name);
return sym; 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. */ /* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) { 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; return 0;
} }
@ -1214,7 +1214,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q)); str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) { for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') { if (*q == '\0') {
fprintf(stderr, "improperly terminated string argument for %s\n", p); errorMsg("improperly terminated string argument for %s\n", p);
return 0; return 0;
} else if (*q == '\\') } else if (*q == '\\')
switch (*++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); p = get_modinfo_value(f, key);
key += 5; key += 5;
if (p == NULL) { if (p == NULL) {
fprintf(stderr, "invalid parameter %s\n", key); errorMsg("invalid parameter %s\n", key);
return 0; 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. */ /* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) { 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; return 0;
} }
@ -1603,8 +1603,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q)); str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) { for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') { if (*q == '\0') {
fprintf(stderr, errorMsg("improperly terminated string argument for %s\n",
"improperly terminated string argument for %s\n",
key); key);
return 0; return 0;
} else if (*q == '\\') } 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 */ /* Get the size of each member */
/* Probably we should do that outside the loop ? */ /* Probably we should do that outside the loop ? */
if (!isdigit(*(p + 1))) { if (!isdigit(*(p + 1))) {
fprintf(stderr, errorMsg("parameter type 'c' for %s must be followed by"
"parameter type 'c' for %s must be followed by"
" the maximum size\n", key); " the maximum size\n", key);
return 0; return 0;
} }
@ -1707,8 +1705,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Check length */ /* Check length */
if (strlen(str) >= charssize) { if (strlen(str) >= charssize) {
fprintf(stderr, errorMsg("string too long for %s (max %ld)\n", key,
"string too long for %s (max %ld)\n", key,
charssize - 1); charssize - 1);
return 0; return 0;
} }
@ -1737,8 +1734,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
break; break;
default: default:
fprintf(stderr, "unknown parameter type '%c' for %s\n", errorMsg("unknown parameter type '%c' for %s\n", *p, key);
*p, key);
return 0; return 0;
} }
} }
@ -1757,22 +1753,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
case ',': case ',':
if (++n > max) { if (++n > max) {
fprintf(stderr, "too many values for %s (max %d)\n", errorMsg("too many values for %s (max %d)\n", key, max);
key, max);
return 0; return 0;
} }
++q; ++q;
break; break;
default: default:
fprintf(stderr, "invalid argument syntax for %s\n", key); errorMsg("invalid argument syntax for %s\n", key);
return 0; return 0;
} }
} }
end_of_arg: end_of_arg:
if (n < min) { 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; return 0;
} }
@ -2157,7 +2152,7 @@ int obj_check_undefineds(struct obj_file *f)
sym->secidx = SHN_ABS; sym->secidx = SHN_ABS;
sym->value = 0; sym->value = 0;
} else { } else {
fprintf(stderr, "unresolved symbol %s\n", sym->name); errorMsg("unresolved symbol %s\n", sym->name);
ret = 0; ret = 0;
} }
} }
@ -2380,11 +2375,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base)
errmsg = "Unhandled relocation"; errmsg = "Unhandled relocation";
bad_reloc: bad_reloc:
if (extsym) { 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), (long) ELFW(R_TYPE) (rel->r_info),
strtab + extsym->st_name); strtab + extsym->st_name);
} else { } else {
fprintf(stderr, "%s of type %ld\n", errmsg, errorMsg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info)); (long) ELFW(R_TYPE) (rel->r_info));
} }
ret = 0; 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_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2 || f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) { || f->header.e_ident[EI_MAG3] != ELFMAG3) {
fprintf(stderr, "not an ELF file\n"); errorMsg("not an ELF file\n");
return NULL; return NULL;
} }
if (f->header.e_ident[EI_CLASS] != ELFCLASSM if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM || f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT || f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) { || !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; return NULL;
} }
if (f->header.e_type != ET_REL) { 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; return NULL;
} }
/* Read the section headers. */ /* Read the section headers. */
if (f->header.e_shentsize != sizeof(ElfW(Shdr))) { 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) f->header.e_shentsize,
(unsigned long) sizeof(ElfW(Shdr))); (unsigned long) sizeof(ElfW(Shdr)));
return NULL; return NULL;
@ -2540,13 +2535,11 @@ struct obj_file *obj_load(FILE * fp)
#if SHT_RELM == SHT_REL #if SHT_RELM == SHT_REL
case SHT_RELA: case SHT_RELA:
fprintf(stderr, errorMsg("RELA relocations not supported on this architecture\n");
"RELA relocations not supported on this architecture\n");
return NULL; return NULL;
#else #else
case SHT_REL: case SHT_REL:
fprintf(stderr, errorMsg("REL relocations not supported on this architecture\n");
"REL relocations not supported on this architecture\n");
return NULL; return NULL;
#endif #endif
@ -2559,7 +2552,7 @@ struct obj_file *obj_load(FILE * fp)
break; 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); (long) sec->header.sh_type);
return NULL; return NULL;
} }
@ -2588,7 +2581,7 @@ struct obj_file *obj_load(FILE * fp)
ElfW(Sym) * sym; ElfW(Sym) * sym;
if (sec->header.sh_entsize != sizeof(ElfW(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) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(Sym))); (unsigned long) sizeof(ElfW(Sym)));
return NULL; return NULL;
@ -2620,8 +2613,7 @@ struct obj_file *obj_load(FILE * fp)
case SHT_RELM: case SHT_RELM:
if (sec->header.sh_entsize != sizeof(ElfW(RelM))) { if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
fprintf(stderr, errorMsg("relocation entry size mismatch: %lu != %lu\n",
"relocation entry size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize, (unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(RelM))); (unsigned long) sizeof(ElfW(RelM)));
return NULL; return NULL;
@ -2754,20 +2746,20 @@ extern int insmod_main( int argc, char **argv)
} else { } else {
m_version = old_get_module_version(f, m_strversion); m_version = old_get_module_version(f, m_strversion);
if (m_version == -1) { if (m_version == -1) {
fprintf(stderr, errorMsg("couldn't find the kernel version the module was "
"couldn't find the kernel version the module was compiled for\n"); "compiled for\n");
goto out; goto out;
} }
} }
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) { 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" "\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s\n", "\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion); m_filename, m_strversion, k_strversion);
} else { } else {
fprintf(stderr, "kernel-module version mismatch\n" errorMsg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n" "\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n", "\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion); m_filename, m_strversion, k_strversion);
@ -2785,7 +2777,7 @@ extern int insmod_main( int argc, char **argv)
goto out; goto out;
k_crcs = new_is_kernel_checksummed(); k_crcs = new_is_kernel_checksummed();
#else #else
fprintf(stderr, "Not configured to support new kernels\n"); errorMsg("Not configured to support new kernels\n");
goto out; goto out;
#endif #endif
} else { } else {
@ -2794,7 +2786,7 @@ extern int insmod_main( int argc, char **argv)
goto out; goto out;
k_crcs = old_is_kernel_checksummed(); k_crcs = old_is_kernel_checksummed();
#else #else
fprintf(stderr, "Not configured to support old kernels\n"); errorMsg("Not configured to support old kernels\n");
goto out; goto out;
#endif #endif
} }
@ -2851,11 +2843,10 @@ extern int insmod_main( int argc, char **argv)
case 0: case 0:
break; break;
case EEXIST: 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; goto out;
case ENOMEM: case ENOMEM:
fprintf(stderr, errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n",
"Can't allocate kernel memory for module; needed %lu bytes\n",
m_size); m_size);
goto out; goto out;
default: default:

20
lash.c
View File

@ -207,12 +207,12 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList)
if (!jobList->head) { if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) { 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]); cmd->progs[0].argv[0]);
return FALSE; return FALSE;
} }
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) { 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]); cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return FALSE; return FALSE;
for (job = jobList->head; job; job = job->next) { 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) { if (!job) {
fprintf(stderr, "%s: unknown job %d\n", errorMsg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum); cmd->progs[0].argv[0], jobNum);
return FALSE; return FALSE;
} }
@ -519,7 +519,7 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult); rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) { if (rc == GLOB_NOSPACE) {
fprintf(stderr, "out of space during glob operation\n"); errorMsg("out of space during glob operation\n");
return; return;
} else if (rc == GLOB_NOMATCH || } else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 && (!rc && (prog->globResult.gl_pathc - i) == 1 &&
@ -607,7 +607,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*src == '\\') { if (*src == '\\') {
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "character expected after \\\n"); errorMsg("character expected after \\\n");
freeJob(job); freeJob(job);
return 1; return 1;
} }
@ -686,7 +686,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
chptr++; chptr++;
if (!*chptr) { if (!*chptr) {
fprintf(stderr, "file name expected after %c\n", *src); errorMsg("file name expected after %c\n", *src);
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -705,7 +705,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*prog->argv[argc]) if (*prog->argv[argc])
argc++; argc++;
if (!argc) { if (!argc) {
fprintf(stderr, "empty command in pipe1.\n"); errorMsg("empty command in pipe1\n");
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -731,7 +731,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "empty command in pipe2\n"); errorMsg("empty command in pipe2\n");
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -750,7 +750,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
case '\\': case '\\':
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "character expected after \\\n"); errorMsg("character expected after \\\n");
freeJob(job); freeJob(job);
return 1; return 1;
} }
@ -965,7 +965,7 @@ static int setupRedirections(struct childProgram *prog)
if (openfd < 0) { if (openfd < 0) {
/* this could get lost if stderr has been redirected, but /* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */ 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)); strerror(errno));
return 1; return 1;
} }

3
ln.c
View File

@ -23,7 +23,6 @@
#include "internal.h" #include "internal.h"
#define BB_DECLARE_EXTERN #define BB_DECLARE_EXTERN
#define bb_need_name_too_long
#define bb_need_not_a_directory #define bb_need_not_a_directory
#include "messages.c" #include "messages.c"
@ -92,7 +91,7 @@ extern int ln_main(int argc, char **argv)
linkIntoDirFlag = isDirectory(linkName, followLinks, NULL); linkIntoDirFlag = isDirectory(linkName, followLinks, NULL);
if ((argc >= 3) && linkIntoDirFlag == FALSE) { if ((argc >= 3) && linkIntoDirFlag == FALSE) {
fprintf(stderr, not_a_directory, "ln", linkName); errorMsg(not_a_directory, linkName);
exit FALSE; exit FALSE;
} }

View File

@ -46,12 +46,12 @@ int loadacm_main(int argc, char **argv)
fd = open("/dev/tty", O_RDWR); fd = open("/dev/tty", O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno)); errorMsg("Error opening /dev/tty1: %s\n", strerror(errno));
return( FALSE); return( FALSE);
} }
if (screen_map_load(fd, stdin)) { 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); return( FALSE);
} }
@ -79,8 +79,7 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) { if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
fprintf(stderr, errorMsg("16bit screen-map MUST be a regular file.\n"),
"16bit screen-map MUST be a regular file.\n"),
exit(1); exit(1);
else else
perror("fseek failed reading binary 16bit screen-map"), 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); perror("Cannot read [new] map from file"), exit(1);
#if 0 #if 0
else else
fprintf(stderr, "Input screen-map is binary.\n"); errorMsg("Input screen-map is binary.\n");
#endif #endif
} }
@ -108,8 +107,7 @@ int screen_map_load(int fd, FILE * fp)
/* rewind... */ /* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
fprintf(stderr, errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"),
"Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1); exit(1);
else else
perror("fseek failed assuming 8bit screen-map"), exit(1); 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 (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
/* should not - it succedeed above */ /* should not - it succedeed above */
fprintf(stderr, "fseek() returned ESPIPE !\n"), errorMsg("fseek() returned ESPIPE !\n"),
exit(1); exit(1);
else else
perror("fseek for binary 8bit screen-map"), exit(1); 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); perror("Cannot read [old] map from file"), exit(1);
#if 0 #if 0
else else
fprintf(stderr, "Input screen-map is binary.\n"); errorMsg("Input screen-map is binary.\n");
#endif #endif
} }
@ -141,7 +139,7 @@ int screen_map_load(int fd, FILE * fp)
else else
return 0; return 0;
} }
fprintf(stderr, "Error parsing symbolic map\n"); errorMsg("Error parsing symbolic map\n");
return(1); return(1);
} }

View File

@ -56,7 +56,7 @@ extern int loadfont_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return( FALSE); return( FALSE);
} }
loadnewfont(fd); loadnewfont(fd);
@ -72,7 +72,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32) { if (unit < 1 || unit > 32) {
fprintf(stderr, "Bad character size %d\n", unit); errorMsg("Bad character size %d\n", unit);
exit(1); 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)); up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
if (!up) { if (!up) {
fprintf(stderr, "Out of memory?\n"); errorMsg("Out of memory?\n");
exit(1); exit(1);
} }
for (glyph = 0; glyph < fontsize; glyph++) { 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)) { if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD #ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) { if (errno == ENOIOCTLCMD) {
fprintf(stderr, "It seems this kernel is older than 1.1.92\n"); errorMsg("It seems this kernel is older than 1.1.92\n");
fprintf(stderr, "No Unicode mapping table loaded.\n"); errorMsg("No Unicode mapping table loaded.\n");
} else } else
#endif #endif
perror("PIO_UNIMAPCLR"); perror("PIO_UNIMAPCLR");
@ -198,13 +198,13 @@ static void loadnewfont(int fd)
goto no_psf; goto no_psf;
if (psfhdr.mode > PSF_MAXMODE) { if (psfhdr.mode > PSF_MAXMODE) {
fprintf(stderr, "Unsupported psf file mode\n"); errorMsg("Unsupported psf file mode\n");
exit(1); exit(1);
} }
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ ) #if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256) { if (fontsize != 256) {
fprintf(stderr, "Only fontsize 256 supported\n"); errorMsg("Only fontsize 256 supported\n");
exit(1); exit(1);
} }
#endif #endif
@ -214,7 +214,7 @@ static void loadnewfont(int fd)
head = head0 + fontsize * unit; head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth)) { if (head > inputlth || (!hastable && head != inputlth)) {
fprintf(stderr, "Input file: bad length\n"); errorMsg("Input file: bad length\n");
exit(1); exit(1);
} }
do_loadfont(fd, inbuf + head0, unit, fontsize); do_loadfont(fd, inbuf + head0, unit, fontsize);
@ -231,7 +231,7 @@ static void loadnewfont(int fd)
} else { } else {
/* bare font */ /* bare font */
if (inputlth & 0377) { if (inputlth & 0377) {
fprintf(stderr, "Bad input file size\n"); errorMsg("Bad input file size\n");
exit(1); exit(1);
} }
offset = 0; offset = 0;

View File

@ -59,25 +59,25 @@ int loadkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno)); errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
exit(FALSE); exit(FALSE);
} }
read(0, buff, 7); read(0, buff, 7);
if (0 != strncmp(buff, magic, 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); exit(FALSE);
} }
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) { 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)); strerror(errno));
exit(FALSE); exit(FALSE);
} }
ibuff = (u_short *) malloc(ibuffsz); ibuff = (u_short *) malloc(ibuffsz);
if (!ibuff) { if (!ibuff) {
fprintf(stderr, "Out of memory.\n"); errorMsg("Out of memory.\n");
exit(FALSE); exit(FALSE);
} }
@ -87,7 +87,7 @@ int loadkmap_main(int argc, char **argv)
while (pos < ibuffsz) { while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
< 0) { < 0) {
fprintf(stderr, "Error reading keymap: %s\n", errorMsg("Error reading keymap: %s\n",
strerror(errno)); strerror(errno));
exit(FALSE); exit(FALSE);
} }

View File

@ -96,7 +96,7 @@ static int pencode(char *s)
*s = '\0'; *s = '\0';
fac = decode(save, facilitynames); fac = decode(save, facilitynames);
if (fac < 0) { if (fac < 0) {
fprintf(stderr, "unknown facility name: %s\n", save); errorMsg("unknown facility name: %s\n", save);
exit(FALSE); exit(FALSE);
} }
*s++ = '.'; *s++ = '.';
@ -105,7 +105,7 @@ static int pencode(char *s)
} }
lev = decode(s, prioritynames); lev = decode(s, prioritynames);
if (lev < 0) { if (lev < 0) {
fprintf(stderr, "unknown priority name: %s\n", save); errorMsg("unknown priority name: %s\n", save);
exit(FALSE); exit(FALSE);
} }
return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)); return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
@ -166,7 +166,7 @@ extern int logger_main(int argc, char **argv)
if (argc >= 1) { if (argc >= 1) {
message = *argv; message = *argv;
} else { } else {
fprintf(stderr, "No message\n"); errorMsg("No message\n");
exit(FALSE); exit(FALSE);
} }
} }

View File

@ -41,6 +41,6 @@ extern int logname_main(int argc, char **argv)
puts(user); puts(user);
exit(TRUE); exit(TRUE);
} }
fprintf(stderr, "no login name\n"); errorMsg("no login name\n");
return(FALSE); return(FALSE);
} }

View File

@ -48,13 +48,13 @@
#if defined bb_need_name_too_long || ! defined BB_DECLARE_EXTERN #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 #endif
#if defined bb_need_omitting_directory || ! defined BB_DECLARE_EXTERN #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 #endif
#if defined bb_need_not_a_directory || ! defined BB_DECLARE_EXTERN #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 #endif
#if defined bb_need_memory_exhausted || ! defined BB_DECLARE_EXTERN #if defined bb_need_memory_exhausted || ! defined BB_DECLARE_EXTERN
BB_DEF_MESSAGE(memory_exhausted, "memory exhausted\n") BB_DEF_MESSAGE(memory_exhausted, "memory exhausted\n")
@ -63,7 +63,7 @@
BB_DEF_MESSAGE(invalid_date, "invalid date `%s'\n") BB_DEF_MESSAGE(invalid_date, "invalid date `%s'\n")
#endif #endif
#if defined bb_need_invalid_option || ! defined BB_DECLARE_EXTERN #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 #endif
#if defined bb_need_io_error || ! defined BB_DECLARE_EXTERN #if defined bb_need_io_error || ! defined BB_DECLARE_EXTERN
BB_DEF_MESSAGE(io_error, "%s: input/output error -- %s\n") BB_DEF_MESSAGE(io_error, "%s: input/output error -- %s\n")
@ -75,7 +75,7 @@
BB_DEF_MESSAGE(write_error, "Write Error\n") BB_DEF_MESSAGE(write_error, "Write Error\n")
#endif #endif
#if defined bb_need_too_few_args || ! defined BB_DECLARE_EXTERN #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 #endif

View File

@ -22,7 +22,7 @@ static unsigned int pointer;
static void push(double a) static void push(double a)
{ {
if (pointer >= (sizeof(stack) / sizeof(*stack))) { if (pointer >= (sizeof(stack) / sizeof(*stack))) {
fprintf(stderr, "dc: stack overflow\n"); errorMsg("stack overflow\n");
exit(-1); exit(-1);
} else } else
stack[pointer++] = a; stack[pointer++] = a;
@ -31,7 +31,7 @@ static void push(double a)
static double pop() static double pop()
{ {
if (pointer == 0) { if (pointer == 0) {
fprintf(stderr, "dc: stack underflow\n"); errorMsg("stack underflow\n");
exit(-1); exit(-1);
} }
return stack[--pointer]; return stack[--pointer];
@ -132,7 +132,7 @@ static void stack_machine(const char *argument)
} }
o++; o++;
} }
fprintf(stderr, "dc: %s: syntax error.\n", argument); errorMsg("%s: syntax error.\n", argument);
exit(-1); exit(-1);
} }

View File

@ -81,7 +81,7 @@ extern int mt_main(int argc, char **argv)
} }
if (code->name == 0) { if (code->name == 0) {
fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); errorMsg("unrecognized opcode %s.\n", argv[1]);
exit (FALSE); exit (FALSE);
} }

View File

@ -62,7 +62,7 @@ extern int mkdir_main(int argc, char **argv)
/* Find the specified modes */ /* Find the specified modes */
mode = 0; mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) { if (parse_mode(*(++argv), &mode) == FALSE) {
fprintf(stderr, "Unknown mode: %s\n", *argv); errorMsg("Unknown mode: %s\n", *argv);
exit FALSE; exit FALSE;
} }
/* Set the umask for this process so it doesn't /* 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]; char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) { if (strlen(*argv) > BUFSIZ - 1) {
fprintf(stderr, name_too_long, "mkdir"); errorMsg(name_too_long);
exit FALSE; exit FALSE;
} }
strcpy(buf, *argv); strcpy(buf, *argv);
status = stat(buf, &statBuf); status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) { if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
fprintf(stderr, "%s: File exists\n", buf); errorMsg("%s: File exists\n", buf);
exit FALSE; exit FALSE;
} }
if (parentFlag == TRUE) { if (parentFlag == TRUE) {

View File

@ -263,7 +263,7 @@ static unsigned long req_nr_inodes = 0;
*/ */
static volatile void die(char *str) static volatile void die(char *str)
{ {
fprintf(stderr, "%s: %s\n", applet_name, str); errorMsg("%s\n", str);
exit(8); exit(8);
} }
@ -814,8 +814,8 @@ extern int mkfs_minix_main(int argc, char **argv)
#ifdef HAVE_MINIX2 #ifdef HAVE_MINIX2
version2 = 1; version2 = 1;
#else #else
fprintf(stderr, "%s: not compiled with minix v2 support\n", errorMsg("%s: not compiled with minix v2 support\n",
applet_name, device_name); device_name);
exit(-1); exit(-1);
#endif #endif
break; break;

View File

@ -116,7 +116,7 @@ static void init_signature_page()
#ifdef PAGE_SIZE #ifdef PAGE_SIZE
if (pagesize != PAGE_SIZE) if (pagesize != PAGE_SIZE)
fprintf(stderr, "Assuming pages of size %d\n", pagesize); errorMsg("Assuming pages of size %d\n", pagesize);
#endif #endif
signature_page = (int *) xmalloc(pagesize); signature_page = (int *) xmalloc(pagesize);
memset(signature_page, 0, 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) void die(const char *str)
{ {
fprintf(stderr, "%s: %s\n", applet_name, str); errorMsg("%s\n", str);
exit(FALSE); exit(FALSE);
} }
@ -345,18 +345,14 @@ int mkswap_main(int argc, char **argv)
} }
} }
if (!device_name) { if (!device_name) {
fprintf(stderr, errorMsg("error: Nowhere to set up swap on?\n");
"%s: error: Nowhere to set up swap on?\n", applet_name);
usage(mkswap_usage); usage(mkswap_usage);
} }
sz = get_size(device_name); sz = get_size(device_name);
if (!PAGES) { if (!PAGES) {
PAGES = sz; PAGES = sz;
} else if (PAGES > sz && !force) { } else if (PAGES > sz && !force) {
fprintf(stderr, errorMsg("error: size %ld is larger than device size %d\n",
"%s: error: "
"size %ld is larger than device size %d\n",
applet_name,
PAGES * (pagesize / 1024), sz * (pagesize / 1024)); PAGES * (pagesize / 1024), sz * (pagesize / 1024));
exit(FALSE); exit(FALSE);
} }
@ -372,14 +368,12 @@ int mkswap_main(int argc, char **argv)
version = 1; version = 1;
} }
if (version != 0 && version != 1) { if (version != 0 && version != 1) {
fprintf(stderr, "%s: error: unknown version %d\n", errorMsg("error: unknown version %d\n", version);
applet_name, version);
usage(mkswap_usage); usage(mkswap_usage);
} }
if (PAGES < 10) { if (PAGES < 10) {
fprintf(stderr, errorMsg("error: swap area needs to be at least %ldkB\n",
"%s: error: swap area needs to be at least %ldkB\n", (long) (10 * pagesize / 1024));
applet_name, (long) (10 * pagesize / 1024));
usage(mkswap_usage); usage(mkswap_usage);
} }
#if 0 #if 0
@ -397,8 +391,8 @@ int mkswap_main(int argc, char **argv)
#endif #endif
if (PAGES > maxpages) { if (PAGES > maxpages) {
PAGES = maxpages; PAGES = maxpages;
fprintf(stderr, "%s: warning: truncating swap area to %ldkB\n", errorMsg("warning: truncating swap area to %ldkB\n",
applet_name, PAGES * pagesize / 1024); PAGES * pagesize / 1024);
} }
DEV = open(device_name, O_RDWR); DEV = open(device_name, O_RDWR);
@ -424,11 +418,10 @@ int mkswap_main(int argc, char **argv)
for (sum = 0; q >= (unsigned short *) buffer;) for (sum = 0; q >= (unsigned short *) buffer;)
sum ^= *q--; sum ^= *q--;
if (!sum) { if (!sum) {
fprintf(stderr, "\ errorMsg("Device '%s' contains a valid Sun disklabel.\n"
%s: Device '%s' contains a valid Sun disklabel.\n\ "This probably means creating v0 swap would destroy your partition table\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"
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);
the -f option to force it.\n", applet_name, device_name);
exit(FALSE); exit(FALSE);
} }
} }

View File

@ -70,7 +70,7 @@
#ifndef MODUTILS_MODULE_H #ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1 #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. /* 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 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 #ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1 #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. */ /* 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 /* Don't report an error if the symbol is coming from
the kernel or some external module. */ the kernel or some external module. */
if (secidx <= SHN_HIRESERVE) if (secidx <= SHN_HIRESERVE)
fprintf(stderr, "%s multiply defined\n", name); errorMsg("%s multiply defined\n", name);
return sym; 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. */ /* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) { 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; return 0;
} }
@ -1214,7 +1214,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q)); str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) { for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') { if (*q == '\0') {
fprintf(stderr, "improperly terminated string argument for %s\n", p); errorMsg("improperly terminated string argument for %s\n", p);
return 0; return 0;
} else if (*q == '\\') } else if (*q == '\\')
switch (*++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); p = get_modinfo_value(f, key);
key += 5; key += 5;
if (p == NULL) { if (p == NULL) {
fprintf(stderr, "invalid parameter %s\n", key); errorMsg("invalid parameter %s\n", key);
return 0; 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. */ /* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) { 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; return 0;
} }
@ -1603,8 +1603,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q)); str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) { for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') { if (*q == '\0') {
fprintf(stderr, errorMsg("improperly terminated string argument for %s\n",
"improperly terminated string argument for %s\n",
key); key);
return 0; return 0;
} else if (*q == '\\') } 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 */ /* Get the size of each member */
/* Probably we should do that outside the loop ? */ /* Probably we should do that outside the loop ? */
if (!isdigit(*(p + 1))) { if (!isdigit(*(p + 1))) {
fprintf(stderr, errorMsg("parameter type 'c' for %s must be followed by"
"parameter type 'c' for %s must be followed by"
" the maximum size\n", key); " the maximum size\n", key);
return 0; return 0;
} }
@ -1707,8 +1705,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Check length */ /* Check length */
if (strlen(str) >= charssize) { if (strlen(str) >= charssize) {
fprintf(stderr, errorMsg("string too long for %s (max %ld)\n", key,
"string too long for %s (max %ld)\n", key,
charssize - 1); charssize - 1);
return 0; return 0;
} }
@ -1737,8 +1734,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
break; break;
default: default:
fprintf(stderr, "unknown parameter type '%c' for %s\n", errorMsg("unknown parameter type '%c' for %s\n", *p, key);
*p, key);
return 0; return 0;
} }
} }
@ -1757,22 +1753,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
case ',': case ',':
if (++n > max) { if (++n > max) {
fprintf(stderr, "too many values for %s (max %d)\n", errorMsg("too many values for %s (max %d)\n", key, max);
key, max);
return 0; return 0;
} }
++q; ++q;
break; break;
default: default:
fprintf(stderr, "invalid argument syntax for %s\n", key); errorMsg("invalid argument syntax for %s\n", key);
return 0; return 0;
} }
} }
end_of_arg: end_of_arg:
if (n < min) { 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; return 0;
} }
@ -2157,7 +2152,7 @@ int obj_check_undefineds(struct obj_file *f)
sym->secidx = SHN_ABS; sym->secidx = SHN_ABS;
sym->value = 0; sym->value = 0;
} else { } else {
fprintf(stderr, "unresolved symbol %s\n", sym->name); errorMsg("unresolved symbol %s\n", sym->name);
ret = 0; ret = 0;
} }
} }
@ -2380,11 +2375,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base)
errmsg = "Unhandled relocation"; errmsg = "Unhandled relocation";
bad_reloc: bad_reloc:
if (extsym) { 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), (long) ELFW(R_TYPE) (rel->r_info),
strtab + extsym->st_name); strtab + extsym->st_name);
} else { } else {
fprintf(stderr, "%s of type %ld\n", errmsg, errorMsg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info)); (long) ELFW(R_TYPE) (rel->r_info));
} }
ret = 0; 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_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2 || f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) { || f->header.e_ident[EI_MAG3] != ELFMAG3) {
fprintf(stderr, "not an ELF file\n"); errorMsg("not an ELF file\n");
return NULL; return NULL;
} }
if (f->header.e_ident[EI_CLASS] != ELFCLASSM if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM || f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT || f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) { || !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; return NULL;
} }
if (f->header.e_type != ET_REL) { 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; return NULL;
} }
/* Read the section headers. */ /* Read the section headers. */
if (f->header.e_shentsize != sizeof(ElfW(Shdr))) { 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) f->header.e_shentsize,
(unsigned long) sizeof(ElfW(Shdr))); (unsigned long) sizeof(ElfW(Shdr)));
return NULL; return NULL;
@ -2540,13 +2535,11 @@ struct obj_file *obj_load(FILE * fp)
#if SHT_RELM == SHT_REL #if SHT_RELM == SHT_REL
case SHT_RELA: case SHT_RELA:
fprintf(stderr, errorMsg("RELA relocations not supported on this architecture\n");
"RELA relocations not supported on this architecture\n");
return NULL; return NULL;
#else #else
case SHT_REL: case SHT_REL:
fprintf(stderr, errorMsg("REL relocations not supported on this architecture\n");
"REL relocations not supported on this architecture\n");
return NULL; return NULL;
#endif #endif
@ -2559,7 +2552,7 @@ struct obj_file *obj_load(FILE * fp)
break; 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); (long) sec->header.sh_type);
return NULL; return NULL;
} }
@ -2588,7 +2581,7 @@ struct obj_file *obj_load(FILE * fp)
ElfW(Sym) * sym; ElfW(Sym) * sym;
if (sec->header.sh_entsize != sizeof(ElfW(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) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(Sym))); (unsigned long) sizeof(ElfW(Sym)));
return NULL; return NULL;
@ -2620,8 +2613,7 @@ struct obj_file *obj_load(FILE * fp)
case SHT_RELM: case SHT_RELM:
if (sec->header.sh_entsize != sizeof(ElfW(RelM))) { if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
fprintf(stderr, errorMsg("relocation entry size mismatch: %lu != %lu\n",
"relocation entry size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize, (unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(RelM))); (unsigned long) sizeof(ElfW(RelM)));
return NULL; return NULL;
@ -2754,20 +2746,20 @@ extern int insmod_main( int argc, char **argv)
} else { } else {
m_version = old_get_module_version(f, m_strversion); m_version = old_get_module_version(f, m_strversion);
if (m_version == -1) { if (m_version == -1) {
fprintf(stderr, errorMsg("couldn't find the kernel version the module was "
"couldn't find the kernel version the module was compiled for\n"); "compiled for\n");
goto out; goto out;
} }
} }
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) { 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" "\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s\n", "\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion); m_filename, m_strversion, k_strversion);
} else { } else {
fprintf(stderr, "kernel-module version mismatch\n" errorMsg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n" "\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n", "\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion); m_filename, m_strversion, k_strversion);
@ -2785,7 +2777,7 @@ extern int insmod_main( int argc, char **argv)
goto out; goto out;
k_crcs = new_is_kernel_checksummed(); k_crcs = new_is_kernel_checksummed();
#else #else
fprintf(stderr, "Not configured to support new kernels\n"); errorMsg("Not configured to support new kernels\n");
goto out; goto out;
#endif #endif
} else { } else {
@ -2794,7 +2786,7 @@ extern int insmod_main( int argc, char **argv)
goto out; goto out;
k_crcs = old_is_kernel_checksummed(); k_crcs = old_is_kernel_checksummed();
#else #else
fprintf(stderr, "Not configured to support old kernels\n"); errorMsg("Not configured to support old kernels\n");
goto out; goto out;
#endif #endif
} }
@ -2851,11 +2843,10 @@ extern int insmod_main( int argc, char **argv)
case 0: case 0:
break; break;
case EEXIST: 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; goto out;
case ENOMEM: case ENOMEM:
fprintf(stderr, errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n",
"Can't allocate kernel memory for module; needed %lu bytes\n",
m_size); m_size);
goto out; goto out;
default: default:

View File

@ -157,15 +157,15 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
specialfile = find_unused_loop_device(); specialfile = find_unused_loop_device();
if (specialfile == NULL) { if (specialfile == NULL) {
fprintf(stderr, "Could not find a spare loop device\n"); errorMsg("Could not find a spare loop device\n");
return (FALSE); return (FALSE);
} }
if (set_loop(specialfile, lofile, 0, &loro)) { if (set_loop(specialfile, lofile, 0, &loro)) {
fprintf(stderr, "Could not setup loop device\n"); errorMsg("Could not setup loop device\n");
return (FALSE); return (FALSE);
} }
if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */ 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; flags &= ~MS_RDONLY;
} }
} }
@ -329,7 +329,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
if (status == FALSE) { if (status == FALSE) {
if (whineOnErrors == TRUE) { if (whineOnErrors == TRUE) {
fprintf(stderr, "Mounting %s on %s failed: %s\n", errorMsg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno)); blockDevice, directory, strerror(errno));
} }
return (FALSE); return (FALSE);

2
mt.c
View File

@ -81,7 +81,7 @@ extern int mt_main(int argc, char **argv)
} }
if (code->name == 0) { if (code->name == 0) {
fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); errorMsg("unrecognized opcode %s.\n", argv[1]);
exit (FALSE); exit (FALSE);
} }

View File

@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */ /* 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 * Mini hostname implementation for busybox
* *
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org> * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@ -55,8 +55,7 @@ void do_sethostname(char *s, int isfile)
if (!isfile) { if (!isfile) {
if (sethostname(s, strlen(s)) < 0) { if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM) if (errno == EPERM)
fprintf(stderr, errorMsg("you must be root to change the hostname\n");
"hostname: you must be root to change the hostname\n");
else else
perror("sethostname"); perror("sethostname");
exit(1); exit(1);

View File

@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */ /* 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 * Mini ping implementation for busybox
* *
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org> * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@ -208,7 +208,7 @@ static void ping(const char *host)
pingaddr.sin_family = AF_INET; pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) { if (!(h = gethostbyname(host))) {
fprintf(stderr, "ping: unknown host %s\n", host); errorMsg("unknown host %s\n", host);
exit(1); exit(1);
} }
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); 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 || c != sizeof(packet)) {
if (c < 0) if (c < 0)
perror("ping: sendto"); perror("ping: sendto");
fprintf(stderr, "ping: write incomplete\n"); errorMsg("write incomplete\n");
exit(1); exit(1);
} }
@ -433,8 +433,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
printf("\n"); printf("\n");
} else } else
if (icmppkt->icmp_type != ICMP_ECHO) if (icmppkt->icmp_type != ICMP_ECHO)
fprintf(stderr, errorMsg("Warning: Got ICMP %d (%s)\n",
"Warning: Got ICMP %d (%s)\n",
icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); 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, if ((pingsock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */ (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
if (errno == EPERM) { if (errno == EPERM) {
fprintf(stderr, "ping: permission denied. (are you root?)\n"); errorMsg("permission denied. (are you root?)\n");
} else { } else {
perror("ping: creating a raw socket"); perror("ping: creating a raw socket");
} }
@ -466,13 +465,12 @@ static void ping(const char *host)
pingaddr.sin_family = AF_INET; pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) { if (!(h = gethostbyname(host))) {
fprintf(stderr, "ping: unknown host %s\n", host); errorMsg("unknown host %s\n", host);
exit(1); exit(1);
} }
if (h->h_addrtype != AF_INET) { if (h->h_addrtype != AF_INET) {
fprintf(stderr, errorMsg("unknown address type; only AF_INET is currently supported.\n");
"ping: unknown address type; only AF_INET is currently supported.\n");
exit(1); exit(1);
} }

View File

@ -312,8 +312,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
msock = fsock = -1; msock = fsock = -1;
mclient = NULL; mclient = NULL;
if (strlen(spec) >= sizeof(hostdir)) { if (strlen(spec) >= sizeof(hostdir)) {
fprintf(stderr, _("mount: " errorMsg("excessively long host:dir argument\n");
"excessively long host:dir argument\n"));
goto fail; goto fail;
} }
strcpy(hostdir, spec); 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) */ until they can be fully supported. (mack@sgi.com) */
if ((s = strchr(hostdir, ','))) { if ((s = strchr(hostdir, ','))) {
*s = '\0'; *s = '\0';
fprintf(stderr, _("mount: warning: " errorMsg("warning: multiple hostnames not supported\n");
"multiple hostnames not supported\n"));
} }
} else { } else {
fprintf(stderr, _("mount: " errorMsg("directory to mount not in host:dir format\n");
"directory to mount not in host:dir format\n"));
goto fail; goto fail;
} }
@ -340,13 +337,11 @@ int nfsmount(const char *spec, const char *node, int *flags,
#endif #endif
{ {
if ((hp = gethostbyname(hostname)) == NULL) { if ((hp = gethostbyname(hostname)) == NULL) {
fprintf(stderr, _("mount: can't get address for %s\n"), errorMsg("can't get address for %s\n", hostname);
hostname);
goto fail; goto fail;
} else { } else {
if (hp->h_length > sizeof(struct in_addr)) { if (hp->h_length > sizeof(struct in_addr)) {
fprintf(stderr, errorMsg("got bad hp->h_length\n");
_("mount: got bad hp->h_length\n"));
hp->h_length = sizeof(struct in_addr); hp->h_length = sizeof(struct in_addr);
} }
memcpy(&server_addr.sin_addr, memcpy(&server_addr.sin_addr,
@ -363,8 +358,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
if (!old_opts) if (!old_opts)
old_opts = ""; old_opts = "";
if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) { if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
fprintf(stderr, _("mount: " errorMsg("excessively long option argument\n");
"excessively long option argument\n"));
goto fail; goto fail;
} }
sprintf(new_opts, "%s%saddr=%s", 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); data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
#endif #endif
if (nfsvers > MAX_NFSPROT) { if (nfsvers > MAX_NFSPROT) {
fprintf(stderr, "NFSv%d not supported!\n", nfsvers); errorMsg("NFSv%d not supported!\n", nfsvers);
return 0; return 0;
} }
if (mountvers > MAX_NFSPROT) { if (mountvers > MAX_NFSPROT) {
fprintf(stderr, "NFSv%d not supported!\n", nfsvers); errorMsg("NFSv%d not supported!\n", nfsvers);
return 0; return 0;
} }
if (nfsvers && !mountvers) 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); mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
} else { } else {
if ((hp = gethostbyname(mounthost)) == NULL) { if ((hp = gethostbyname(mounthost)) == NULL) {
fprintf(stderr, _("mount: can't get address for %s\n"), errorMsg("can't get address for %s\n", hostname);
hostname);
goto fail; goto fail;
} else { } else {
if (hp->h_length > sizeof(struct in_addr)) { if (hp->h_length > sizeof(struct in_addr)) {
fprintf(stderr, errorMsg("got bad hp->h_length?\n");
_("mount: got bad hp->h_length?\n"));
hp->h_length = sizeof(struct in_addr); hp->h_length = sizeof(struct in_addr);
} }
mount_server_addr.sin_family = AF_INET; 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 (nfsvers == 2) {
if (status.nfsv2.fhs_status != 0) { if (status.nfsv2.fhs_status != 0) {
fprintf(stderr, errorMsg("%s:%s failed, reason given by server: %s\n",
"mount: %s:%s failed, reason given by server: %s\n",
hostname, dirname, hostname, dirname,
nfs_strerror(status.nfsv2.fhs_status)); nfs_strerror(status.nfsv2.fhs_status));
goto fail; goto fail;
@ -748,8 +739,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
#if NFS_MOUNT_VERSION >= 4 #if NFS_MOUNT_VERSION >= 4
fhandle3 *fhandle; fhandle3 *fhandle;
if (status.nfsv3.fhs_status != 0) { if (status.nfsv3.fhs_status != 0) {
fprintf(stderr, errorMsg("%s:%s failed, reason given by server: %s\n",
"mount: %s:%s failed, reason given by server: %s\n",
hostname, dirname, hostname, dirname,
nfs_strerror(status.nfsv3.fhs_status)); nfs_strerror(status.nfsv3.fhs_status));
goto fail; goto fail;

16
ping.c
View File

@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */ /* 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 * Mini ping implementation for busybox
* *
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org> * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@ -208,7 +208,7 @@ static void ping(const char *host)
pingaddr.sin_family = AF_INET; pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) { if (!(h = gethostbyname(host))) {
fprintf(stderr, "ping: unknown host %s\n", host); errorMsg("unknown host %s\n", host);
exit(1); exit(1);
} }
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr)); 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 || c != sizeof(packet)) {
if (c < 0) if (c < 0)
perror("ping: sendto"); perror("ping: sendto");
fprintf(stderr, "ping: write incomplete\n"); errorMsg("write incomplete\n");
exit(1); exit(1);
} }
@ -433,8 +433,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
printf("\n"); printf("\n");
} else } else
if (icmppkt->icmp_type != ICMP_ECHO) if (icmppkt->icmp_type != ICMP_ECHO)
fprintf(stderr, errorMsg("Warning: Got ICMP %d (%s)\n",
"Warning: Got ICMP %d (%s)\n",
icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); 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, if ((pingsock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */ (proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
if (errno == EPERM) { if (errno == EPERM) {
fprintf(stderr, "ping: permission denied. (are you root?)\n"); errorMsg("permission denied. (are you root?)\n");
} else { } else {
perror("ping: creating a raw socket"); perror("ping: creating a raw socket");
} }
@ -466,13 +465,12 @@ static void ping(const char *host)
pingaddr.sin_family = AF_INET; pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) { if (!(h = gethostbyname(host))) {
fprintf(stderr, "ping: unknown host %s\n", host); errorMsg("unknown host %s\n", host);
exit(1); exit(1);
} }
if (h->h_addrtype != AF_INET) { if (h->h_addrtype != AF_INET) {
fprintf(stderr, errorMsg("unknown address type; only AF_INET is currently supported.\n");
"ping: unknown address type; only AF_INET is currently supported.\n");
exit(1); exit(1);
} }

View File

@ -97,20 +97,20 @@ static void parse_proc_status(char *S, proc_t * P)
if (tmp) if (tmp)
sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid); sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid);
else else
fprintf(stderr, "Internal error!\n"); errorMsg("Internal error!\n");
/* For busybox, ignoring effective, saved, etc */ /* For busybox, ignoring effective, saved, etc */
tmp = strstr(S, "Uid:"); tmp = strstr(S, "Uid:");
if (tmp) if (tmp)
sscanf(tmp, "Uid:\t%d", &P->ruid); sscanf(tmp, "Uid:\t%d", &P->ruid);
else else
fprintf(stderr, "Internal error!\n"); errorMsg("Internal error!\n");
tmp = strstr(S, "Gid:"); tmp = strstr(S, "Gid:");
if (tmp) if (tmp)
sscanf(tmp, "Gid:\t%d", &P->rgid); sscanf(tmp, "Gid:\t%d", &P->rgid);
else else
fprintf(stderr, "Internal error!\n"); errorMsg("Internal error!\n");
} }

6
ps.c
View File

@ -97,20 +97,20 @@ static void parse_proc_status(char *S, proc_t * P)
if (tmp) if (tmp)
sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid); sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid);
else else
fprintf(stderr, "Internal error!\n"); errorMsg("Internal error!\n");
/* For busybox, ignoring effective, saved, etc */ /* For busybox, ignoring effective, saved, etc */
tmp = strstr(S, "Uid:"); tmp = strstr(S, "Uid:");
if (tmp) if (tmp)
sscanf(tmp, "Uid:\t%d", &P->ruid); sscanf(tmp, "Uid:\t%d", &P->ruid);
else else
fprintf(stderr, "Internal error!\n"); errorMsg("Internal error!\n");
tmp = strstr(S, "Gid:"); tmp = strstr(S, "Gid:");
if (tmp) if (tmp)
sscanf(tmp, "Gid:\t%d", &P->rgid); sscanf(tmp, "Gid:\t%d", &P->rgid);
else else
fprintf(stderr, "Internal error!\n"); errorMsg("Internal error!\n");
} }

View File

@ -40,7 +40,7 @@ extern int rmdir_main(int argc, char **argv)
while (--argc > 0) { while (--argc > 0) {
if (rmdir(*(++argv)) == -1) { if (rmdir(*(++argv)) == -1) {
fprintf(stderr, "%s: %s\n", applet_name, strerror(errno)); errorMsg("%s\n", strerror(errno));
exit(FALSE); exit(FALSE);
} }
} }

6
sed.c
View File

@ -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 '/' */ idx++; /* so it points to the next character after the last '/' */
} }
else { else {
fprintf(stderr, "sed.c:get_address: no address found in string\n"); errorMsg("get_address: no address found in string\n"
fprintf(stderr, "\t(you probably didn't check the string you passed me)\n"); "\t(you probably didn't check the string you passed me)\n");
idx = -1; idx = -1;
} }
@ -612,7 +612,7 @@ extern int sed_main(int argc, char **argv)
for (i = optind; i < argc; i++) { for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r"); file = fopen(argv[i], "r");
if (file == NULL) { if (file == NULL) {
fprintf(stderr, "sed: %s: %s\n", argv[i], strerror(errno)); errorMsg("%s: %s\n", argv[i], strerror(errno));
} else { } else {
process_file(file); process_file(file);
fclose(file); fclose(file);

20
sh.c
View File

@ -207,12 +207,12 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList)
if (!jobList->head) { if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) { 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]); cmd->progs[0].argv[0]);
return FALSE; return FALSE;
} }
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) { 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]); cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return FALSE; return FALSE;
for (job = jobList->head; job; job = job->next) { 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) { if (!job) {
fprintf(stderr, "%s: unknown job %d\n", errorMsg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum); cmd->progs[0].argv[0], jobNum);
return FALSE; return FALSE;
} }
@ -519,7 +519,7 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult); rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) { if (rc == GLOB_NOSPACE) {
fprintf(stderr, "out of space during glob operation\n"); errorMsg("out of space during glob operation\n");
return; return;
} else if (rc == GLOB_NOMATCH || } else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 && (!rc && (prog->globResult.gl_pathc - i) == 1 &&
@ -607,7 +607,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*src == '\\') { if (*src == '\\') {
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "character expected after \\\n"); errorMsg("character expected after \\\n");
freeJob(job); freeJob(job);
return 1; return 1;
} }
@ -686,7 +686,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
chptr++; chptr++;
if (!*chptr) { if (!*chptr) {
fprintf(stderr, "file name expected after %c\n", *src); errorMsg("file name expected after %c\n", *src);
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -705,7 +705,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*prog->argv[argc]) if (*prog->argv[argc])
argc++; argc++;
if (!argc) { if (!argc) {
fprintf(stderr, "empty command in pipe1.\n"); errorMsg("empty command in pipe1\n");
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -731,7 +731,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "empty command in pipe2\n"); errorMsg("empty command in pipe2\n");
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -750,7 +750,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
case '\\': case '\\':
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "character expected after \\\n"); errorMsg("character expected after \\\n");
freeJob(job); freeJob(job);
return 1; return 1;
} }
@ -965,7 +965,7 @@ static int setupRedirections(struct childProgram *prog)
if (openfd < 0) { if (openfd < 0) {
/* this could get lost if stderr has been redirected, but /* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */ 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)); strerror(errno));
return 1; return 1;
} }

View File

@ -207,12 +207,12 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList)
if (!jobList->head) { if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) { 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]); cmd->progs[0].argv[0]);
return FALSE; return FALSE;
} }
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) { 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]); cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return FALSE; return FALSE;
for (job = jobList->head; job; job = job->next) { 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) { if (!job) {
fprintf(stderr, "%s: unknown job %d\n", errorMsg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum); cmd->progs[0].argv[0], jobNum);
return FALSE; return FALSE;
} }
@ -519,7 +519,7 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult); rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) { if (rc == GLOB_NOSPACE) {
fprintf(stderr, "out of space during glob operation\n"); errorMsg("out of space during glob operation\n");
return; return;
} else if (rc == GLOB_NOMATCH || } else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 && (!rc && (prog->globResult.gl_pathc - i) == 1 &&
@ -607,7 +607,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*src == '\\') { if (*src == '\\') {
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "character expected after \\\n"); errorMsg("character expected after \\\n");
freeJob(job); freeJob(job);
return 1; return 1;
} }
@ -686,7 +686,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
chptr++; chptr++;
if (!*chptr) { if (!*chptr) {
fprintf(stderr, "file name expected after %c\n", *src); errorMsg("file name expected after %c\n", *src);
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -705,7 +705,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*prog->argv[argc]) if (*prog->argv[argc])
argc++; argc++;
if (!argc) { if (!argc) {
fprintf(stderr, "empty command in pipe1.\n"); errorMsg("empty command in pipe1\n");
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -731,7 +731,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "empty command in pipe2\n"); errorMsg("empty command in pipe2\n");
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -750,7 +750,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
case '\\': case '\\':
src++; src++;
if (!*src) { if (!*src) {
fprintf(stderr, "character expected after \\\n"); errorMsg("character expected after \\\n");
freeJob(job); freeJob(job);
return 1; return 1;
} }
@ -965,7 +965,7 @@ static int setupRedirections(struct childProgram *prog)
if (openfd < 0) { if (openfd < 0) {
/* this could get lost if stderr has been redirected, but /* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */ 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)); strerror(errno));
return 1; return 1;
} }

4
sort.c
View File

@ -263,7 +263,7 @@ int sort_main(int argc, char **argv)
break; break;
#endif #endif
default: default:
fprintf(stderr, "sort: invalid option -- %c\n", opt); errorMsg("invalid option -- %c\n", opt);
usage(sort_usage); usage(sort_usage);
} }
} else { } else {
@ -304,4 +304,4 @@ int sort_main(int argc, char **argv)
return(0); 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 $ */

View File

@ -96,7 +96,7 @@ static int pencode(char *s)
*s = '\0'; *s = '\0';
fac = decode(save, facilitynames); fac = decode(save, facilitynames);
if (fac < 0) { if (fac < 0) {
fprintf(stderr, "unknown facility name: %s\n", save); errorMsg("unknown facility name: %s\n", save);
exit(FALSE); exit(FALSE);
} }
*s++ = '.'; *s++ = '.';
@ -105,7 +105,7 @@ static int pencode(char *s)
} }
lev = decode(s, prioritynames); lev = decode(s, prioritynames);
if (lev < 0) { if (lev < 0) {
fprintf(stderr, "unknown priority name: %s\n", save); errorMsg("unknown priority name: %s\n", save);
exit(FALSE); exit(FALSE);
} }
return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)); return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
@ -166,7 +166,7 @@ extern int logger_main(int argc, char **argv)
if (argc >= 1) { if (argc >= 1) {
message = *argv; message = *argv;
} else { } else {
fprintf(stderr, "No message\n"); errorMsg("No message\n");
exit(FALSE); exit(FALSE);
} }
} }

5
tail.c
View File

@ -375,7 +375,7 @@ extern int tail_main(int argc, char **argv)
usage(tail_usage); usage(tail_usage);
default: default:
if ((n_units = atoi(&argv[i][1])) < 1) { 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); usage(tail_usage);
} }
} }
@ -386,8 +386,7 @@ extern int tail_main(int argc, char **argv)
if (i + 1 < argc) { if (i + 1 < argc) {
if (forever) { if (forever) {
fprintf(stderr, errorMsg("option -f is invalid with multiple files\n");
"tail: option -f is invalid with multiple files\n");
usage(tail_usage); usage(tail_usage);
} }
print_headers = 1; print_headers = 1;

4
tee.c
View File

@ -104,7 +104,7 @@ int tee_main(int argc, char **argv)
/* init FILE pointers */ /* init FILE pointers */
FileList = calloc(FL_MAX, sizeof(FILE*)); FileList = calloc(FL_MAX, sizeof(FILE*));
if (!FileList) { if (!FileList) {
fprintf(stderr, "tee: %s\n", strerror(errno)); errorMsg("%s\n", strerror(errno));
exit(1); exit(1);
} }
FL_end = 0; FL_end = 0;
@ -133,4 +133,4 @@ int tee_main(int argc, char **argv)
return(0); 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 $ */

View File

@ -101,7 +101,7 @@ void mtab_read(void)
return; return;
if ((fp = setmntent(mtab_file, "r")) == NULL) { if ((fp = setmntent(mtab_file, "r")) == NULL) {
fprintf(stderr, "Cannot open %s\n", mtab_file); errorMsg("Cannot open %s\n", mtab_file);
return; return;
} }
while ((e = getmntent(fp))) { while ((e = getmntent(fp))) {
@ -209,11 +209,9 @@ static int do_umount(const char *name, int useMtab)
status = mount(blockDevice, name, NULL, status = mount(blockDevice, name, NULL,
MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
if (status == 0) { if (status == 0) {
fprintf(stderr, "umount: %s busy - remounted read-only\n", errorMsg("%s busy - remounted read-only\n", blockDevice);
blockDevice);
} else { } else {
fprintf(stderr, "umount: Cannot remount %s read-only\n", errorMsg("Cannot remount %s read-only\n", blockDevice);
blockDevice);
} }
} }
if (status == 0) { if (status == 0) {

6
uniq.c
View File

@ -127,11 +127,11 @@ set_file_pointers(int schema, FILE ** in, FILE ** out, char **argv)
break; break;
} }
if (*in == NULL) { if (*in == NULL) {
fprintf(stderr, "uniq: %s: %s\n", argv[0], strerror(errno)); errorMsg("%s: %s\n", argv[0], strerror(errno));
return errno; return errno;
} }
if (*out == NULL) { if (*out == NULL) {
fprintf(stderr, "uniq: %s: %s\n", argv[1], strerror(errno)); errorMsg("%s: %s\n", argv[1], strerror(errno));
return errno; return errno;
} }
return 0; return 0;
@ -187,4 +187,4 @@ int uniq_main(int argc, char **argv)
return(0); 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 $ */

View File

@ -387,7 +387,7 @@ extern int fbset_main(int argc, char **argv)
PERROR("fbset(ioctl)"); PERROR("fbset(ioctl)");
if (g_options & OPT_READMODE) { if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) { if (!readmode(&var, modefile, mode)) {
fprintf(stderr, "Unknown video mode `%s'\n", mode); errorMsg("Unknown video mode `%s'\n", mode);
exit(1); exit(1);
} }
} }

View File

@ -311,7 +311,7 @@ static void show_usage(void)
static void die(const char *str) static void die(const char *str)
{ {
fprintf(stderr, "%s: %s\n", applet_name, str); errorMsg("%s\n", str);
leave(8); leave(8);
} }

View File

@ -263,7 +263,7 @@ static unsigned long req_nr_inodes = 0;
*/ */
static volatile void die(char *str) static volatile void die(char *str)
{ {
fprintf(stderr, "%s: %s\n", applet_name, str); errorMsg("%s\n", str);
exit(8); exit(8);
} }
@ -814,8 +814,8 @@ extern int mkfs_minix_main(int argc, char **argv)
#ifdef HAVE_MINIX2 #ifdef HAVE_MINIX2
version2 = 1; version2 = 1;
#else #else
fprintf(stderr, "%s: not compiled with minix v2 support\n", errorMsg("%s: not compiled with minix v2 support\n",
applet_name, device_name); device_name);
exit(-1); exit(-1);
#endif #endif
break; break;

View File

@ -116,7 +116,7 @@ static void init_signature_page()
#ifdef PAGE_SIZE #ifdef PAGE_SIZE
if (pagesize != PAGE_SIZE) if (pagesize != PAGE_SIZE)
fprintf(stderr, "Assuming pages of size %d\n", pagesize); errorMsg("Assuming pages of size %d\n", pagesize);
#endif #endif
signature_page = (int *) xmalloc(pagesize); signature_page = (int *) xmalloc(pagesize);
memset(signature_page, 0, 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) void die(const char *str)
{ {
fprintf(stderr, "%s: %s\n", applet_name, str); errorMsg("%s\n", str);
exit(FALSE); exit(FALSE);
} }
@ -345,18 +345,14 @@ int mkswap_main(int argc, char **argv)
} }
} }
if (!device_name) { if (!device_name) {
fprintf(stderr, errorMsg("error: Nowhere to set up swap on?\n");
"%s: error: Nowhere to set up swap on?\n", applet_name);
usage(mkswap_usage); usage(mkswap_usage);
} }
sz = get_size(device_name); sz = get_size(device_name);
if (!PAGES) { if (!PAGES) {
PAGES = sz; PAGES = sz;
} else if (PAGES > sz && !force) { } else if (PAGES > sz && !force) {
fprintf(stderr, errorMsg("error: size %ld is larger than device size %d\n",
"%s: error: "
"size %ld is larger than device size %d\n",
applet_name,
PAGES * (pagesize / 1024), sz * (pagesize / 1024)); PAGES * (pagesize / 1024), sz * (pagesize / 1024));
exit(FALSE); exit(FALSE);
} }
@ -372,14 +368,12 @@ int mkswap_main(int argc, char **argv)
version = 1; version = 1;
} }
if (version != 0 && version != 1) { if (version != 0 && version != 1) {
fprintf(stderr, "%s: error: unknown version %d\n", errorMsg("error: unknown version %d\n", version);
applet_name, version);
usage(mkswap_usage); usage(mkswap_usage);
} }
if (PAGES < 10) { if (PAGES < 10) {
fprintf(stderr, errorMsg("error: swap area needs to be at least %ldkB\n",
"%s: error: swap area needs to be at least %ldkB\n", (long) (10 * pagesize / 1024));
applet_name, (long) (10 * pagesize / 1024));
usage(mkswap_usage); usage(mkswap_usage);
} }
#if 0 #if 0
@ -397,8 +391,8 @@ int mkswap_main(int argc, char **argv)
#endif #endif
if (PAGES > maxpages) { if (PAGES > maxpages) {
PAGES = maxpages; PAGES = maxpages;
fprintf(stderr, "%s: warning: truncating swap area to %ldkB\n", errorMsg("warning: truncating swap area to %ldkB\n",
applet_name, PAGES * pagesize / 1024); PAGES * pagesize / 1024);
} }
DEV = open(device_name, O_RDWR); DEV = open(device_name, O_RDWR);
@ -424,11 +418,10 @@ int mkswap_main(int argc, char **argv)
for (sum = 0; q >= (unsigned short *) buffer;) for (sum = 0; q >= (unsigned short *) buffer;)
sum ^= *q--; sum ^= *q--;
if (!sum) { if (!sum) {
fprintf(stderr, "\ errorMsg("Device '%s' contains a valid Sun disklabel.\n"
%s: Device '%s' contains a valid Sun disklabel.\n\ "This probably means creating v0 swap would destroy your partition table\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"
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);
the -f option to force it.\n", applet_name, device_name);
exit(FALSE); exit(FALSE);
} }
} }

View File

@ -157,15 +157,15 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
specialfile = find_unused_loop_device(); specialfile = find_unused_loop_device();
if (specialfile == NULL) { if (specialfile == NULL) {
fprintf(stderr, "Could not find a spare loop device\n"); errorMsg("Could not find a spare loop device\n");
return (FALSE); return (FALSE);
} }
if (set_loop(specialfile, lofile, 0, &loro)) { if (set_loop(specialfile, lofile, 0, &loro)) {
fprintf(stderr, "Could not setup loop device\n"); errorMsg("Could not setup loop device\n");
return (FALSE); return (FALSE);
} }
if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */ 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; flags &= ~MS_RDONLY;
} }
} }
@ -329,7 +329,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
if (status == FALSE) { if (status == FALSE) {
if (whineOnErrors == TRUE) { if (whineOnErrors == TRUE) {
fprintf(stderr, "Mounting %s on %s failed: %s\n", errorMsg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno)); blockDevice, directory, strerror(errno));
} }
return (FALSE); return (FALSE);

View File

@ -312,8 +312,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
msock = fsock = -1; msock = fsock = -1;
mclient = NULL; mclient = NULL;
if (strlen(spec) >= sizeof(hostdir)) { if (strlen(spec) >= sizeof(hostdir)) {
fprintf(stderr, _("mount: " errorMsg("excessively long host:dir argument\n");
"excessively long host:dir argument\n"));
goto fail; goto fail;
} }
strcpy(hostdir, spec); 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) */ until they can be fully supported. (mack@sgi.com) */
if ((s = strchr(hostdir, ','))) { if ((s = strchr(hostdir, ','))) {
*s = '\0'; *s = '\0';
fprintf(stderr, _("mount: warning: " errorMsg("warning: multiple hostnames not supported\n");
"multiple hostnames not supported\n"));
} }
} else { } else {
fprintf(stderr, _("mount: " errorMsg("directory to mount not in host:dir format\n");
"directory to mount not in host:dir format\n"));
goto fail; goto fail;
} }
@ -340,13 +337,11 @@ int nfsmount(const char *spec, const char *node, int *flags,
#endif #endif
{ {
if ((hp = gethostbyname(hostname)) == NULL) { if ((hp = gethostbyname(hostname)) == NULL) {
fprintf(stderr, _("mount: can't get address for %s\n"), errorMsg("can't get address for %s\n", hostname);
hostname);
goto fail; goto fail;
} else { } else {
if (hp->h_length > sizeof(struct in_addr)) { if (hp->h_length > sizeof(struct in_addr)) {
fprintf(stderr, errorMsg("got bad hp->h_length\n");
_("mount: got bad hp->h_length\n"));
hp->h_length = sizeof(struct in_addr); hp->h_length = sizeof(struct in_addr);
} }
memcpy(&server_addr.sin_addr, memcpy(&server_addr.sin_addr,
@ -363,8 +358,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
if (!old_opts) if (!old_opts)
old_opts = ""; old_opts = "";
if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) { if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
fprintf(stderr, _("mount: " errorMsg("excessively long option argument\n");
"excessively long option argument\n"));
goto fail; goto fail;
} }
sprintf(new_opts, "%s%saddr=%s", 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); data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
#endif #endif
if (nfsvers > MAX_NFSPROT) { if (nfsvers > MAX_NFSPROT) {
fprintf(stderr, "NFSv%d not supported!\n", nfsvers); errorMsg("NFSv%d not supported!\n", nfsvers);
return 0; return 0;
} }
if (mountvers > MAX_NFSPROT) { if (mountvers > MAX_NFSPROT) {
fprintf(stderr, "NFSv%d not supported!\n", nfsvers); errorMsg("NFSv%d not supported!\n", nfsvers);
return 0; return 0;
} }
if (nfsvers && !mountvers) 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); mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
} else { } else {
if ((hp = gethostbyname(mounthost)) == NULL) { if ((hp = gethostbyname(mounthost)) == NULL) {
fprintf(stderr, _("mount: can't get address for %s\n"), errorMsg("can't get address for %s\n", hostname);
hostname);
goto fail; goto fail;
} else { } else {
if (hp->h_length > sizeof(struct in_addr)) { if (hp->h_length > sizeof(struct in_addr)) {
fprintf(stderr, errorMsg("got bad hp->h_length?\n");
_("mount: got bad hp->h_length?\n"));
hp->h_length = sizeof(struct in_addr); hp->h_length = sizeof(struct in_addr);
} }
mount_server_addr.sin_family = AF_INET; 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 (nfsvers == 2) {
if (status.nfsv2.fhs_status != 0) { if (status.nfsv2.fhs_status != 0) {
fprintf(stderr, errorMsg("%s:%s failed, reason given by server: %s\n",
"mount: %s:%s failed, reason given by server: %s\n",
hostname, dirname, hostname, dirname,
nfs_strerror(status.nfsv2.fhs_status)); nfs_strerror(status.nfsv2.fhs_status));
goto fail; goto fail;
@ -748,8 +739,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
#if NFS_MOUNT_VERSION >= 4 #if NFS_MOUNT_VERSION >= 4
fhandle3 *fhandle; fhandle3 *fhandle;
if (status.nfsv3.fhs_status != 0) { if (status.nfsv3.fhs_status != 0) {
fprintf(stderr, errorMsg("%s:%s failed, reason given by server: %s\n",
"mount: %s:%s failed, reason given by server: %s\n",
hostname, dirname, hostname, dirname,
nfs_strerror(status.nfsv3.fhs_status)); nfs_strerror(status.nfsv3.fhs_status));
goto fail; goto fail;

View File

@ -101,7 +101,7 @@ void mtab_read(void)
return; return;
if ((fp = setmntent(mtab_file, "r")) == NULL) { if ((fp = setmntent(mtab_file, "r")) == NULL) {
fprintf(stderr, "Cannot open %s\n", mtab_file); errorMsg("Cannot open %s\n", mtab_file);
return; return;
} }
while ((e = getmntent(fp))) { while ((e = getmntent(fp))) {
@ -209,11 +209,9 @@ static int do_umount(const char *name, int useMtab)
status = mount(blockDevice, name, NULL, status = mount(blockDevice, name, NULL,
MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
if (status == 0) { if (status == 0) {
fprintf(stderr, "umount: %s busy - remounted read-only\n", errorMsg("%s busy - remounted read-only\n", blockDevice);
blockDevice);
} else { } else {
fprintf(stderr, "umount: Cannot remount %s read-only\n", errorMsg("Cannot remount %s read-only\n", blockDevice);
blockDevice);
} }
} }
if (status == 0) { if (status == 0) {

View File

@ -299,7 +299,7 @@ copyFile(const char *srcName, const char *destName,
if ((srcStatBuf.st_dev == dstStatBuf.st_dev) && if ((srcStatBuf.st_dev == dstStatBuf.st_dev) &&
(srcStatBuf.st_ino == dstStatBuf.st_ino)) { (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; return FALSE;
} }
@ -630,7 +630,7 @@ int recursiveAction(const char *fileName,
continue; continue;
} }
if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) { if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) {
fprintf(stderr, name_too_long, "ftw"); errorMsg(name_too_long);
return FALSE; return FALSE;
} }
memset(nextFile, 0, sizeof(nextFile)); memset(nextFile, 0, sizeof(nextFile));
@ -995,8 +995,7 @@ int get_console_fd(char *tty_name)
if (is_a_console(fd)) if (is_a_console(fd))
return fd; return fd;
fprintf(stderr, errorMsg("Couldnt get a file descriptor referring to the console\n");
"Couldnt get a file descriptor referring to the console\n");
return -1; /* total failure */ return -1; /* total failure */
} }

View File

@ -43,7 +43,6 @@ extern int whoami_main(int argc, char **argv)
puts(user); puts(user);
exit(TRUE); exit(TRUE);
} }
fprintf(stderr, "%s: cannot find username for UID %u\n", applet_name, errorMsg("cannot find username for UID %u\n", (unsigned) uid);
(unsigned) uid);
return(FALSE); return(FALSE);
} }