if (len != -1) {
path[len] = 0;
} else {
- fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno));
+ errorMsg("%s: %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
puts(command);
#endif
if (rc) {
- fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
+ errorMsg("%s: %s\n", command, strerror(errno));
}
}
return rc;
{
char *s;
const struct BB_applet *a = applets;
+ applet_name = "busybox";
#ifdef BB_FEATURE_INSTALLER
/*
if (*argv == '\0')
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
- fprintf(stderr, name_too_long, "gunzip");
+ errorMsg(name_too_long);
exit(WARNING);
}
strcpy(ifname, *argv);
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
- fprintf(stderr, name_too_long, "gunzip");
+ errorMsg(name_too_long);
exit(WARNING);
}
strcpy(ofname, ifname);
method = (int) get_byte();
if (method != DEFLATED) {
- fprintf(stderr,
- "unknown method %d -- get newer version of gzip\n",
+ errorMsg("unknown method %d -- get newer version of gzip\n",
method);
exit_code = ERROR;
return -1;
if (len != -1) {
path[len] = 0;
} else {
- fprintf(stderr, "busybox : %s : %s\n", proc, strerror(errno));
+ errorMsg("%s: %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
puts(command);
#endif
if (rc) {
- fprintf(stderr,"busybox : %s : %s\n", command, strerror(errno));
+ errorMsg("%s: %s\n", command, strerror(errno));
}
}
return rc;
{
char *s;
const struct BB_applet *a = applets;
+ applet_name = "busybox";
#ifdef BB_FEATURE_INSTALLER
/*
recursiveFlag = TRUE;
break;
default:
- fprintf(stderr, invalid_option, applet_name, **argv);
+ errorMsg(invalid_option, **argv);
usage(appUsage);
}
}
}
if (argc == 0 || *argv == NULL) {
- fprintf(stderr, too_few_args, applet_name);
+ errorMsg(too_few_args);
usage(appUsage);
}
/* Ok, ready to do the deed now */
if (argc <= 1) {
- fatalError( "too few arguments\n");
+ fatalError(too_few_args);
}
while (argc-- > 1) {
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
- fprintf(stderr, "%s: 0: illegal VT number\n", applet_name);
+ errorMsg("0: illegal VT number\n");
else if (num == 1)
- fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
- applet_name);
+ errorMsg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
- fprintf(stderr, "%s: could not deallocate console %d\n",
- applet_name, num);
+ errorMsg("could not deallocate console %d\n", num);
exit( FALSE);
}
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
+ errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return 1;
}
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
- fprintf(stderr, "ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
+ errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,&ke.kb_value,2);
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno));
+ errorMsg("Error opening /dev/tty1: %s\n", strerror(errno));
return( FALSE);
}
if (screen_map_load(fd, stdin)) {
- fprintf(stderr, "Error loading acm: %s\n", strerror(errno));
+ errorMsg("Error loading acm: %s\n", strerror(errno));
return( FALSE);
}
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- fprintf(stderr,
- "16bit screen-map MUST be a regular file.\n"),
+ errorMsg("16bit screen-map MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed reading binary 16bit screen-map"),
perror("Cannot read [new] map from file"), exit(1);
#if 0
else
- fprintf(stderr, "Input screen-map is binary.\n");
+ errorMsg("Input screen-map is binary.\n");
#endif
}
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- fprintf(stderr,
- "Assuming 8bit screen-map - MUST be a regular file.\n"),
+ errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed assuming 8bit screen-map"), exit(1);
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
- fprintf(stderr, "fseek() returned ESPIPE !\n"),
+ errorMsg("fseek() returned ESPIPE !\n"),
exit(1);
else
perror("fseek for binary 8bit screen-map"), exit(1);
perror("Cannot read [old] map from file"), exit(1);
#if 0
else
- fprintf(stderr, "Input screen-map is binary.\n");
+ errorMsg("Input screen-map is binary.\n");
#endif
}
else
return 0;
}
- fprintf(stderr, "Error parsing symbolic map\n");
+ errorMsg("Error parsing symbolic map\n");
return(1);
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
+ errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return( FALSE);
}
loadnewfont(fd);
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32) {
- fprintf(stderr, "Bad character size %d\n", unit);
+ errorMsg("Bad character size %d\n", unit);
exit(1);
}
up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
if (!up) {
- fprintf(stderr, "Out of memory?\n");
+ errorMsg("Out of memory?\n");
exit(1);
}
for (glyph = 0; glyph < fontsize; glyph++) {
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
- fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
- fprintf(stderr, "No Unicode mapping table loaded.\n");
+ errorMsg("It seems this kernel is older than 1.1.92\n");
+ errorMsg("No Unicode mapping table loaded.\n");
} else
#endif
perror("PIO_UNIMAPCLR");
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE) {
- fprintf(stderr, "Unsupported psf file mode\n");
+ errorMsg("Unsupported psf file mode\n");
exit(1);
}
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256) {
- fprintf(stderr, "Only fontsize 256 supported\n");
+ errorMsg("Only fontsize 256 supported\n");
exit(1);
}
#endif
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth)) {
- fprintf(stderr, "Input file: bad length\n");
+ errorMsg("Input file: bad length\n");
exit(1);
}
do_loadfont(fd, inbuf + head0, unit, fontsize);
} else {
/* bare font */
if (inputlth & 0377) {
- fprintf(stderr, "Bad input file size\n");
+ errorMsg("Bad input file size\n");
exit(1);
}
offset = 0;
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
+ errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
exit(FALSE);
}
read(0, buff, 7);
if (0 != strncmp(buff, magic, 7)) {
- fprintf(stderr, "This is not a valid binary keymap.\n");
+ errorMsg("This is not a valid binary keymap.\n");
exit(FALSE);
}
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) {
- fprintf(stderr, "Error reading keymap flags: %s\n",
+ errorMsg("Error reading keymap flags: %s\n",
strerror(errno));
exit(FALSE);
}
ibuff = (u_short *) malloc(ibuffsz);
if (!ibuff) {
- fprintf(stderr, "Out of memory.\n");
+ errorMsg("Out of memory.\n");
exit(FALSE);
}
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
< 0) {
- fprintf(stderr, "Error reading keymap: %s\n",
+ errorMsg("Error reading keymap: %s\n",
strerror(errno));
exit(FALSE);
}
void warn(int warn_number, char *option)
{
static char *warn_msg[] = {
- "%s: Option -%s allowed only with -f\n",
- "%s: -%s overrides earlier option\n",
- "%s: -%s not allowed in current mode\n",
- "%s: Cannot open %s\n"
+ "Option -%s allowed only with -f\n",
+ "-%s overrides earlier option\n",
+ "-%s not allowed in current mode\n",
+ "Cannot open %s\n"
};
- fprintf(stderr, warn_msg[warn_number], applet_name, option);
+ errorMsg(warn_msg[warn_number], option);
exit_status = warn_number + 1;
}
void cuterror(int err)
{
static char *err_mes[] = {
- "%s: syntax error\n",
- "%s: position must be >0\n",
- "%s: line longer than BUFSIZ\n",
- "%s: range must not decrease from left to right\n",
- "%s: MAX_FIELD exceeded\n",
- "%s: MAX_ARGS exceeded\n"
+ "syntax error\n",
+ "position must be >0\n",
+ "line longer than BUFSIZ\n",
+ "range must not decrease from left to right\n",
+ "MAX_FIELD exceeded\n",
+ "MAX_ARGS exceeded\n"
};
- fprintf(stderr, err_mes[err - 101], applet_name);
+ errorMsg(err_mes[err - 101]);
exit(err);
}
else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1);
if (count <= 0) {
- fprintf(stderr, "Bad count value %s\n", *argv);
+ errorMsg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
- fprintf(stderr, "Bad block size value %s\n", *argv);
+ errorMsg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
- fprintf(stderr, "Bad skip value %s\n", *argv);
+ errorMsg("Bad skip value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
- fprintf(stderr, "Bad seek value %s\n", *argv);
+ errorMsg("Bad seek value %s\n", *argv);
goto usage;
}
}
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
- fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
+ errorMsg("%s: can't find mount point.\n", argv[1]);
exit(FALSE);
}
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
}
if (len + strlen(name) + 1 > BUFSIZ) {
- fprintf(stderr, name_too_long, "du");
+ errorMsg(name_too_long);
du_depth--;
return 0;
}
usage(du_usage);
break;
default:
- fprintf(stderr, "du: invalid option -- %c\n", opt);
+ errorMsg("invalid option -- %c\n", opt);
usage(du_usage);
}
} else {
return(0);
}
-/* $Id: du.c,v 1.20 2000/06/19 17:25:39 andersen Exp $ */
+/* $Id: du.c,v 1.21 2000/07/14 01:51:25 kraai Exp $ */
/*
Local Variables:
c-file-style: "linux"
case 'h':
usage(head_usage);
default:
- fprintf(stderr, "head: invalid option -- %c\n", opt);
+ errorMsg("invalid option -- %c\n", opt);
usage(head_usage);
}
} else {
src = fopen(argv[i], "r");
if (!src) {
- fprintf(stderr, "head: %s: %s\n", argv[i],
- strerror(errno));
+ errorMsg("%s: %s\n", argv[i], strerror(errno));
} else {
/* emulating GNU behaviour */
if (need_headers) {
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 $ */
#include "internal.h"
#define BB_DECLARE_EXTERN
-#define bb_need_name_too_long
#define bb_need_not_a_directory
#include "messages.c"
linkIntoDirFlag = isDirectory(linkName, followLinks, NULL);
if ((argc >= 3) && linkIntoDirFlag == FALSE) {
- fprintf(stderr, not_a_directory, "ln", linkName);
+ errorMsg(not_a_directory, linkName);
exit FALSE;
}
puts(user);
exit(TRUE);
}
- fprintf(stderr, "no login name\n");
+ errorMsg("no login name\n");
return(FALSE);
}
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
- fprintf(stderr, "Unknown mode: %s\n", *argv);
+ errorMsg("Unknown mode: %s\n", *argv);
exit FALSE;
}
/* Set the umask for this process so it doesn't
char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) {
- fprintf(stderr, name_too_long, "mkdir");
+ errorMsg(name_too_long);
exit FALSE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
- fprintf(stderr, "%s: File exists\n", buf);
+ errorMsg("%s: File exists\n", buf);
exit FALSE;
}
if (parentFlag == TRUE) {
while (--argc > 0) {
if (rmdir(*(++argv)) == -1) {
- fprintf(stderr, "%s: %s\n", applet_name, strerror(errno));
+ errorMsg("%s\n", strerror(errno));
exit(FALSE);
}
}
break;
#endif
default:
- fprintf(stderr, "sort: invalid option -- %c\n", opt);
+ errorMsg("invalid option -- %c\n", opt);
usage(sort_usage);
}
} else {
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 $ */
usage(tail_usage);
default:
if ((n_units = atoi(&argv[i][1])) < 1) {
- fprintf(stderr, "tail: invalid option -- %c\n", opt);
+ errorMsg("invalid option -- %c\n", opt);
usage(tail_usage);
}
}
if (i + 1 < argc) {
if (forever) {
- fprintf(stderr,
- "tail: option -f is invalid with multiple files\n");
+ errorMsg("option -f is invalid with multiple files\n");
usage(tail_usage);
}
print_headers = 1;
/* init FILE pointers */
FileList = calloc(FL_MAX, sizeof(FILE*));
if (!FileList) {
- fprintf(stderr, "tee: %s\n", strerror(errno));
+ errorMsg("%s\n", strerror(errno));
exit(1);
}
FL_end = 0;
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 $ */
break;
}
if (*in == NULL) {
- fprintf(stderr, "uniq: %s: %s\n", argv[0], strerror(errno));
+ errorMsg("%s: %s\n", argv[0], strerror(errno));
return errno;
}
if (*out == NULL) {
- fprintf(stderr, "uniq: %s: %s\n", argv[1], strerror(errno));
+ errorMsg("%s: %s\n", argv[1], strerror(errno));
return errno;
}
return 0;
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 $ */
puts(user);
exit(TRUE);
}
- fprintf(stderr, "%s: cannot find username for UID %u\n", applet_name,
- (unsigned) uid);
+ errorMsg("cannot find username for UID %u\n", (unsigned) uid);
return(FALSE);
}
static
void name_too_long__exit (void)
{
- fprintf(stderr, name_too_long, applet_name);
- exit(FALSE);
+ fatalError(name_too_long);
}
static void
if (srcDirFlag == TRUE) {
if (recursiveFlag == FALSE) {
- fprintf(stderr, omitting_directory, applet_name, baseSrcName);
+ errorMsg(omitting_directory, baseSrcName);
return TRUE;
}
srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName));
if (destLen + strlen(srcBasename) > BUFSIZ) {
- fprintf(stderr, name_too_long, applet_name);
+ errorMsg(name_too_long);
return FALSE;
}
strcat(destName, srcBasename);
if (mv_Action_first_time && (dz_i == is_mv)) {
mv_Action_first_time = errno = 0;
if (rename(fileName, destName) < 0 && errno != EXDEV) {
- fprintf(stderr, "%s: rename(%s, %s): %s\n",
- applet_name, fileName, destName, strerror(errno));
+ errorMsg("rename(%s, %s): %s\n", fileName, destName,
+ strerror(errno));
goto do_copyFile; /* Try anyway... */
}
else if (errno == EXDEV)
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
if (is_in_ino_dev_hashtable(statbuf, &name)) {
if (link(name, destName) < 0) {
- fprintf(stderr, "%s: link(%s, %s): %s\n",
- applet_name, name, destName, strerror(errno));
+ errorMsg("link(%s, %s): %s\n", name, destName, strerror(errno));
return FALSE;
}
return TRUE;
if (S_ISDIR(statbuf->st_mode)) {
if (rmdir(fileName) < 0) {
- fprintf(stderr, "%s: rmdir(%s): %s\n", applet_name, fileName, strerror(errno));
+ errorMsg("rmdir(%s): %s\n", fileName, strerror(errno));
status = FALSE;
}
} else if (unlink(fileName) < 0) {
- fprintf(stderr, "%s: unlink(%s): %s\n", applet_name, fileName, strerror(errno));
+ errorMsg("unlink(%s): %s\n", fileName, strerror(errno));
status = FALSE;
}
return status;
if (strlen(argv[argc - 1]) > BUFSIZ) {
- fprintf(stderr, name_too_long, "cp");
+ errorMsg(name_too_long);
goto exit_false;
}
strcpy(baseDestName, argv[argc - 1]);
destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf);
if ((argc > 3) && destDirFlag == FALSE) {
- fprintf(stderr, not_a_directory, "cp", baseDestName);
+ errorMsg(not_a_directory, baseDestName);
goto exit_false;
}
char *pushd, *d, *p;
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
- fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno));
+ errorMsg("getcwd(): %s\n", strerror(errno));
continue;
}
if (chdir(baseDestName) < 0) {
- fprintf(stderr, "%s: chdir(%s): %s\n", applet_name, baseSrcName, strerror(errno));
+ errorMsg("chdir(%s): %s\n", baseSrcName, strerror(errno));
continue;
}
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
- fprintf(stderr, "%s: getcwd(): %s\n", applet_name, strerror(errno));
+ errorMsg("getcwd(): %s\n", strerror(errno));
continue;
}
while (!state && *d != '\0') {
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
- fprintf(stderr, "%s: stat(%s) :%s\n", applet_name, d, strerror(errno));
+ errorMsg("stat(%s): %s\n", d, strerror(errno));
state = -1;
continue;
}
if ((sb.st_ino == srcStatBuf.st_ino) &&
(sb.st_dev == srcStatBuf.st_dev)) {
- fprintf(stderr,
- "%s: Cannot %s `%s' "
- "into a subdirectory of itself, `%s/%s'\n",
- applet_name, applet_name, baseSrcName, baseDestName, baseSrcName);
+ errorMsg("Cannot %s `%s' into a subdirectory of itself, "
+ "`%s/%s'\n", applet_name, baseSrcName,
+ baseDestName, baseSrcName);
state = -1;
continue;
}
}
}
if (chdir(pushd) < 0) {
- fprintf(stderr, "%s: chdir(%s): %s\n", applet_name, pushd, strerror(errno));
+ errorMsg("chdir(%s): %s\n", pushd, strerror(errno));
free(pushd);
free(d);
continue;
void warn(int warn_number, char *option)
{
static char *warn_msg[] = {
- "%s: Option -%s allowed only with -f\n",
- "%s: -%s overrides earlier option\n",
- "%s: -%s not allowed in current mode\n",
- "%s: Cannot open %s\n"
+ "Option -%s allowed only with -f\n",
+ "-%s overrides earlier option\n",
+ "-%s not allowed in current mode\n",
+ "Cannot open %s\n"
};
- fprintf(stderr, warn_msg[warn_number], applet_name, option);
+ errorMsg(warn_msg[warn_number], option);
exit_status = warn_number + 1;
}
void cuterror(int err)
{
static char *err_mes[] = {
- "%s: syntax error\n",
- "%s: position must be >0\n",
- "%s: line longer than BUFSIZ\n",
- "%s: range must not decrease from left to right\n",
- "%s: MAX_FIELD exceeded\n",
- "%s: MAX_ARGS exceeded\n"
+ "syntax error\n",
+ "position must be >0\n",
+ "line longer than BUFSIZ\n",
+ "range must not decrease from left to right\n",
+ "MAX_FIELD exceeded\n",
+ "MAX_ARGS exceeded\n"
};
- fprintf(stderr, err_mes[err - 101], applet_name);
+ errorMsg(err_mes[err - 101]);
exit(err);
}
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack))) {
- fprintf(stderr, "dc: stack overflow\n");
+ errorMsg("stack overflow\n");
exit(-1);
} else
stack[pointer++] = a;
static double pop()
{
if (pointer == 0) {
- fprintf(stderr, "dc: stack underflow\n");
+ errorMsg("stack underflow\n");
exit(-1);
}
return stack[--pointer];
}
o++;
}
- fprintf(stderr, "dc: %s: syntax error.\n", argument);
+ errorMsg("%s: syntax error.\n", argument);
exit(-1);
}
else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1);
if (count <= 0) {
- fprintf(stderr, "Bad count value %s\n", *argv);
+ errorMsg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
- fprintf(stderr, "Bad block size value %s\n", *argv);
+ errorMsg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
- fprintf(stderr, "Bad skip value %s\n", *argv);
+ errorMsg("Bad skip value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
- fprintf(stderr, "Bad seek value %s\n", *argv);
+ errorMsg("Bad seek value %s\n", *argv);
goto usage;
}
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
- fprintf(stderr, "%s: 0: illegal VT number\n", applet_name);
+ errorMsg("0: illegal VT number\n");
else if (num == 1)
- fprintf(stderr, "%s: VT 1 cannot be deallocated\n",
- applet_name);
+ errorMsg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
- fprintf(stderr, "%s: could not deallocate console %d\n",
- applet_name, num);
+ errorMsg("could not deallocate console %d\n", num);
exit( FALSE);
}
}
}
while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
- fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
+ errorMsg("%s: can't find mount point.\n", argv[1]);
exit(FALSE);
}
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
}
if (len + strlen(name) + 1 > BUFSIZ) {
- fprintf(stderr, name_too_long, "du");
+ errorMsg(name_too_long);
du_depth--;
return 0;
}
usage(du_usage);
break;
default:
- fprintf(stderr, "du: invalid option -- %c\n", opt);
+ errorMsg("invalid option -- %c\n", opt);
usage(du_usage);
}
} else {
return(0);
}
-/* $Id: du.c,v 1.20 2000/06/19 17:25:39 andersen Exp $ */
+/* $Id: du.c,v 1.21 2000/07/14 01:51:25 kraai Exp $ */
/*
Local Variables:
c-file-style: "linux"
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
+ errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return 1;
}
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
- fprintf(stderr, "ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
+ errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,&ke.kb_value,2);
idx++; /* so it points to the next character after the last '/' */
}
else {
- fprintf(stderr, "sed.c:get_address: no address found in string\n");
- fprintf(stderr, "\t(you probably didn't check the string you passed me)\n");
+ errorMsg("get_address: no address found in string\n"
+ "\t(you probably didn't check the string you passed me)\n");
idx = -1;
}
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
- fprintf(stderr, "sed: %s: %s\n", argv[i], strerror(errno));
+ errorMsg("%s: %s\n", argv[i], strerror(errno));
} else {
process_file(file);
fclose(file);
PERROR("fbset(ioctl)");
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
- fprintf(stderr, "Unknown video mode `%s'\n", mode);
+ errorMsg("Unknown video mode `%s'\n", mode);
exit(1);
}
}
file = fopen(cur_file, "r");
if (file == NULL) {
if (!suppress_err_msgs)
- fprintf(stderr, "grep: %s: %s\n", cur_file, strerror(errno));
+ errorMsg("%s: %s\n", cur_file, strerror(errno));
} else {
grep_file(file);
fclose(file);
static void die(const char *str)
{
- fprintf(stderr, "%s: %s\n", applet_name, str);
+ errorMsg("%s\n", str);
leave(8);
}
file = fopen(cur_file, "r");
if (file == NULL) {
if (!suppress_err_msgs)
- fprintf(stderr, "grep: %s: %s\n", cur_file, strerror(errno));
+ errorMsg("%s: %s\n", cur_file, strerror(errno));
} else {
grep_file(file);
fclose(file);
if (*argv == '\0')
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
- fprintf(stderr, name_too_long, "gunzip");
+ errorMsg(name_too_long);
exit(WARNING);
}
strcpy(ifname, *argv);
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
- fprintf(stderr, name_too_long, "gunzip");
+ errorMsg(name_too_long);
exit(WARNING);
}
strcpy(ofname, ifname);
method = (int) get_byte();
if (method != DEFLATED) {
- fprintf(stderr,
- "unknown method %d -- get newer version of gzip\n",
+ errorMsg("unknown method %d -- get newer version of gzip\n",
method);
exit_code = ERROR;
return -1;
case 'h':
usage(head_usage);
default:
- fprintf(stderr, "head: invalid option -- %c\n", opt);
+ errorMsg("invalid option -- %c\n", opt);
usage(head_usage);
}
} else {
src = fopen(argv[i], "r");
if (!src) {
- fprintf(stderr, "head: %s: %s\n", argv[i],
- strerror(errno));
+ errorMsg("%s: %s\n", argv[i], strerror(errno));
} else {
/* emulating GNU behaviour */
if (need_headers) {
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 $ */
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.10 2000/06/19 17:25:39 andersen Exp $
+ * $Id: hostname.c,v 1.11 2000/07/14 01:51:25 kraai Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM)
- fprintf(stderr,
- "hostname: you must be root to change the hostname\n");
+ errorMsg("you must be root to change the hostname\n");
else
perror("sethostname");
exit(1);
#ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1
-#ident "$Id: insmod.c,v 1.15 2000/07/11 17:52:22 andersen Exp $"
+#ident "$Id: insmod.c,v 1.16 2000/07/14 01:51:25 kraai Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1
-#ident "$Id: insmod.c,v 1.15 2000/07/11 17:52:22 andersen Exp $"
+#ident "$Id: insmod.c,v 1.16 2000/07/14 01:51:25 kraai Exp $"
/* The relocatable object is manipulated using elfin types. */
/* Don't report an error if the symbol is coming from
the kernel or some external module. */
if (secidx <= SHN_HIRESERVE)
- fprintf(stderr, "%s multiply defined\n", name);
+ errorMsg("%s multiply defined\n", name);
return sym;
}
}
/* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- fprintf(stderr, "symbol for parameter %s not found\n", p);
+ errorMsg("symbol for parameter %s not found\n", p);
return 0;
}
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
- fprintf(stderr, "improperly terminated string argument for %s\n", p);
+ errorMsg("improperly terminated string argument for %s\n", p);
return 0;
} else if (*q == '\\')
switch (*++q) {
p = get_modinfo_value(f, key);
key += 5;
if (p == NULL) {
- fprintf(stderr, "invalid parameter %s\n", key);
+ errorMsg("invalid parameter %s\n", key);
return 0;
}
/* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- fprintf(stderr, "symbol for parameter %s not found\n", key);
+ errorMsg("symbol for parameter %s not found\n", key);
return 0;
}
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
- fprintf(stderr,
- "improperly terminated string argument for %s\n",
+ errorMsg("improperly terminated string argument for %s\n",
key);
return 0;
} else if (*q == '\\')
/* Get the size of each member */
/* Probably we should do that outside the loop ? */
if (!isdigit(*(p + 1))) {
- fprintf(stderr,
- "parameter type 'c' for %s must be followed by"
+ errorMsg("parameter type 'c' for %s must be followed by"
" the maximum size\n", key);
return 0;
}
/* Check length */
if (strlen(str) >= charssize) {
- fprintf(stderr,
- "string too long for %s (max %ld)\n", key,
+ errorMsg("string too long for %s (max %ld)\n", key,
charssize - 1);
return 0;
}
break;
default:
- fprintf(stderr, "unknown parameter type '%c' for %s\n",
- *p, key);
+ errorMsg("unknown parameter type '%c' for %s\n", *p, key);
return 0;
}
}
case ',':
if (++n > max) {
- fprintf(stderr, "too many values for %s (max %d)\n",
- key, max);
+ errorMsg("too many values for %s (max %d)\n", key, max);
return 0;
}
++q;
break;
default:
- fprintf(stderr, "invalid argument syntax for %s\n", key);
+ errorMsg("invalid argument syntax for %s\n", key);
return 0;
}
}
end_of_arg:
if (n < min) {
- fprintf(stderr, "too few values for %s (min %d)\n", key, min);
+ errorMsg("too few values for %s (min %d)\n", key, min);
return 0;
}
sym->secidx = SHN_ABS;
sym->value = 0;
} else {
- fprintf(stderr, "unresolved symbol %s\n", sym->name);
+ errorMsg("unresolved symbol %s\n", sym->name);
ret = 0;
}
}
errmsg = "Unhandled relocation";
bad_reloc:
if (extsym) {
- fprintf(stderr, "%s of type %ld for %s\n", errmsg,
+ errorMsg("%s of type %ld for %s\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info),
strtab + extsym->st_name);
} else {
- fprintf(stderr, "%s of type %ld\n", errmsg,
+ errorMsg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info));
}
ret = 0;
|| f->header.e_ident[EI_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) {
- fprintf(stderr, "not an ELF file\n");
+ errorMsg("not an ELF file\n");
return NULL;
}
if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) {
- fprintf(stderr, "ELF file not for this architecture\n");
+ errorMsg("ELF file not for this architecture\n");
return NULL;
}
if (f->header.e_type != ET_REL) {
- fprintf(stderr, "ELF file not a relocatable object\n");
+ errorMsg("ELF file not a relocatable object\n");
return NULL;
}
/* Read the section headers. */
if (f->header.e_shentsize != sizeof(ElfW(Shdr))) {
- fprintf(stderr, "section header size mismatch: %lu != %lu\n",
+ errorMsg("section header size mismatch: %lu != %lu\n",
(unsigned long) f->header.e_shentsize,
(unsigned long) sizeof(ElfW(Shdr)));
return NULL;
#if SHT_RELM == SHT_REL
case SHT_RELA:
- fprintf(stderr,
- "RELA relocations not supported on this architecture\n");
+ errorMsg("RELA relocations not supported on this architecture\n");
return NULL;
#else
case SHT_REL:
- fprintf(stderr,
- "REL relocations not supported on this architecture\n");
+ errorMsg("REL relocations not supported on this architecture\n");
return NULL;
#endif
break;
}
- fprintf(stderr, "can't handle sections of type %ld\n",
+ errorMsg("can't handle sections of type %ld\n",
(long) sec->header.sh_type);
return NULL;
}
ElfW(Sym) * sym;
if (sec->header.sh_entsize != sizeof(ElfW(Sym))) {
- fprintf(stderr, "symbol size mismatch: %lu != %lu\n",
+ errorMsg("symbol size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(Sym)));
return NULL;
case SHT_RELM:
if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
- fprintf(stderr,
- "relocation entry size mismatch: %lu != %lu\n",
+ errorMsg("relocation entry size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(RelM)));
return NULL;
} else {
m_version = old_get_module_version(f, m_strversion);
if (m_version == -1) {
- fprintf(stderr,
- "couldn't find the kernel version the module was compiled for\n");
+ errorMsg("couldn't find the kernel version the module was "
+ "compiled for\n");
goto out;
}
}
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) {
- fprintf(stderr, "Warning: kernel-module version mismatch\n"
+ errorMsg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion);
} else {
- fprintf(stderr, "kernel-module version mismatch\n"
+ errorMsg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion);
goto out;
k_crcs = new_is_kernel_checksummed();
#else
- fprintf(stderr, "Not configured to support new kernels\n");
+ errorMsg("Not configured to support new kernels\n");
goto out;
#endif
} else {
goto out;
k_crcs = old_is_kernel_checksummed();
#else
- fprintf(stderr, "Not configured to support old kernels\n");
+ errorMsg("Not configured to support old kernels\n");
goto out;
#endif
}
case 0:
break;
case EEXIST:
- fprintf(stderr, "A module named %s already exists\n", m_name);
+ errorMsg("A module named %s already exists\n", m_name);
goto out;
case ENOMEM:
- fprintf(stderr,
- "Can't allocate kernel memory for module; needed %lu bytes\n",
+ errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n",
m_size);
goto out;
default:
if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
- fprintf(stderr, "%s: exactly one argument is expected\n",
+ errorMsg("%s: exactly one argument is expected\n",
cmd->progs[0].argv[0]);
return FALSE;
}
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) {
- fprintf(stderr, "%s: bad argument '%s'\n",
+ errorMsg("%s: bad argument '%s'\n",
cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return FALSE;
for (job = jobList->head; job; job = job->next) {
}
if (!job) {
- fprintf(stderr, "%s: unknown job %d\n",
+ errorMsg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum);
return FALSE;
}
rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) {
- fprintf(stderr, "out of space during glob operation\n");
+ errorMsg("out of space during glob operation\n");
return;
} else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 &&
if (*src == '\\') {
src++;
if (!*src) {
- fprintf(stderr, "character expected after \\\n");
+ errorMsg("character expected after \\\n");
freeJob(job);
return 1;
}
chptr++;
if (!*chptr) {
- fprintf(stderr, "file name expected after %c\n", *src);
+ errorMsg("file name expected after %c\n", *src);
freeJob(job);
job->numProgs=0;
return 1;
if (*prog->argv[argc])
argc++;
if (!argc) {
- fprintf(stderr, "empty command in pipe1.\n");
+ errorMsg("empty command in pipe1\n");
freeJob(job);
job->numProgs=0;
return 1;
src++;
if (!*src) {
- fprintf(stderr, "empty command in pipe2\n");
+ errorMsg("empty command in pipe2\n");
freeJob(job);
job->numProgs=0;
return 1;
case '\\':
src++;
if (!*src) {
- fprintf(stderr, "character expected after \\\n");
+ errorMsg("character expected after \\\n");
freeJob(job);
return 1;
}
if (openfd < 0) {
/* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */
- fprintf(stderr, "error opening %s: %s\n", redir->filename,
+ errorMsg("error opening %s: %s\n", redir->filename,
strerror(errno));
return 1;
}
#include "internal.h"
#define BB_DECLARE_EXTERN
-#define bb_need_name_too_long
#define bb_need_not_a_directory
#include "messages.c"
linkIntoDirFlag = isDirectory(linkName, followLinks, NULL);
if ((argc >= 3) && linkIntoDirFlag == FALSE) {
- fprintf(stderr, not_a_directory, "ln", linkName);
+ errorMsg(not_a_directory, linkName);
exit FALSE;
}
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty1: %s\n", strerror(errno));
+ errorMsg("Error opening /dev/tty1: %s\n", strerror(errno));
return( FALSE);
}
if (screen_map_load(fd, stdin)) {
- fprintf(stderr, "Error loading acm: %s\n", strerror(errno));
+ errorMsg("Error loading acm: %s\n", strerror(errno));
return( FALSE);
}
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- fprintf(stderr,
- "16bit screen-map MUST be a regular file.\n"),
+ errorMsg("16bit screen-map MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed reading binary 16bit screen-map"),
perror("Cannot read [new] map from file"), exit(1);
#if 0
else
- fprintf(stderr, "Input screen-map is binary.\n");
+ errorMsg("Input screen-map is binary.\n");
#endif
}
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- fprintf(stderr,
- "Assuming 8bit screen-map - MUST be a regular file.\n"),
+ errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed assuming 8bit screen-map"), exit(1);
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
- fprintf(stderr, "fseek() returned ESPIPE !\n"),
+ errorMsg("fseek() returned ESPIPE !\n"),
exit(1);
else
perror("fseek for binary 8bit screen-map"), exit(1);
perror("Cannot read [old] map from file"), exit(1);
#if 0
else
- fprintf(stderr, "Input screen-map is binary.\n");
+ errorMsg("Input screen-map is binary.\n");
#endif
}
else
return 0;
}
- fprintf(stderr, "Error parsing symbolic map\n");
+ errorMsg("Error parsing symbolic map\n");
return(1);
}
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
+ errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
return( FALSE);
}
loadnewfont(fd);
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32) {
- fprintf(stderr, "Bad character size %d\n", unit);
+ errorMsg("Bad character size %d\n", unit);
exit(1);
}
up = (struct unipair *) malloc(maxct * sizeof(struct unipair));
if (!up) {
- fprintf(stderr, "Out of memory?\n");
+ errorMsg("Out of memory?\n");
exit(1);
}
for (glyph = 0; glyph < fontsize; glyph++) {
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
- fprintf(stderr, "It seems this kernel is older than 1.1.92\n");
- fprintf(stderr, "No Unicode mapping table loaded.\n");
+ errorMsg("It seems this kernel is older than 1.1.92\n");
+ errorMsg("No Unicode mapping table loaded.\n");
} else
#endif
perror("PIO_UNIMAPCLR");
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE) {
- fprintf(stderr, "Unsupported psf file mode\n");
+ errorMsg("Unsupported psf file mode\n");
exit(1);
}
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256) {
- fprintf(stderr, "Only fontsize 256 supported\n");
+ errorMsg("Only fontsize 256 supported\n");
exit(1);
}
#endif
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth)) {
- fprintf(stderr, "Input file: bad length\n");
+ errorMsg("Input file: bad length\n");
exit(1);
}
do_loadfont(fd, inbuf + head0, unit, fontsize);
} else {
/* bare font */
if (inputlth & 0377) {
- fprintf(stderr, "Bad input file size\n");
+ errorMsg("Bad input file size\n");
exit(1);
}
offset = 0;
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
+ errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
exit(FALSE);
}
read(0, buff, 7);
if (0 != strncmp(buff, magic, 7)) {
- fprintf(stderr, "This is not a valid binary keymap.\n");
+ errorMsg("This is not a valid binary keymap.\n");
exit(FALSE);
}
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) {
- fprintf(stderr, "Error reading keymap flags: %s\n",
+ errorMsg("Error reading keymap flags: %s\n",
strerror(errno));
exit(FALSE);
}
ibuff = (u_short *) malloc(ibuffsz);
if (!ibuff) {
- fprintf(stderr, "Out of memory.\n");
+ errorMsg("Out of memory.\n");
exit(FALSE);
}
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
< 0) {
- fprintf(stderr, "Error reading keymap: %s\n",
+ errorMsg("Error reading keymap: %s\n",
strerror(errno));
exit(FALSE);
}
*s = '\0';
fac = decode(save, facilitynames);
if (fac < 0) {
- fprintf(stderr, "unknown facility name: %s\n", save);
+ errorMsg("unknown facility name: %s\n", save);
exit(FALSE);
}
*s++ = '.';
}
lev = decode(s, prioritynames);
if (lev < 0) {
- fprintf(stderr, "unknown priority name: %s\n", save);
+ errorMsg("unknown priority name: %s\n", save);
exit(FALSE);
}
return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
if (argc >= 1) {
message = *argv;
} else {
- fprintf(stderr, "No message\n");
+ errorMsg("No message\n");
exit(FALSE);
}
}
puts(user);
exit(TRUE);
}
- fprintf(stderr, "no login name\n");
+ errorMsg("no login name\n");
return(FALSE);
}
#if defined bb_need_name_too_long || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(name_too_long, "%s: file name too long\n")
+ BB_DEF_MESSAGE(name_too_long, "file name too long\n")
#endif
#if defined bb_need_omitting_directory || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(omitting_directory, "%s: %s: omitting directory\n")
+ BB_DEF_MESSAGE(omitting_directory, "%s: omitting directory\n")
#endif
#if defined bb_need_not_a_directory || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(not_a_directory, "%s: %s: not a directory\n")
+ BB_DEF_MESSAGE(not_a_directory, "%s: not a directory\n")
#endif
#if defined bb_need_memory_exhausted || ! defined BB_DECLARE_EXTERN
BB_DEF_MESSAGE(memory_exhausted, "memory exhausted\n")
BB_DEF_MESSAGE(invalid_date, "invalid date `%s'\n")
#endif
#if defined bb_need_invalid_option || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(invalid_option, "%s: invalid option -- %c\n")
+ BB_DEF_MESSAGE(invalid_option, "invalid option -- %c\n")
#endif
#if defined bb_need_io_error || ! defined BB_DECLARE_EXTERN
BB_DEF_MESSAGE(io_error, "%s: input/output error -- %s\n")
BB_DEF_MESSAGE(write_error, "Write Error\n")
#endif
#if defined bb_need_too_few_args || ! defined BB_DECLARE_EXTERN
- BB_DEF_MESSAGE(too_few_args, "%s: too few arguments\n")
+ BB_DEF_MESSAGE(too_few_args, "too few arguments\n")
#endif
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack))) {
- fprintf(stderr, "dc: stack overflow\n");
+ errorMsg("stack overflow\n");
exit(-1);
} else
stack[pointer++] = a;
static double pop()
{
if (pointer == 0) {
- fprintf(stderr, "dc: stack underflow\n");
+ errorMsg("stack underflow\n");
exit(-1);
}
return stack[--pointer];
}
o++;
}
- fprintf(stderr, "dc: %s: syntax error.\n", argument);
+ errorMsg("%s: syntax error.\n", argument);
exit(-1);
}
}
if (code->name == 0) {
- fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
+ errorMsg("unrecognized opcode %s.\n", argv[1]);
exit (FALSE);
}
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
- fprintf(stderr, "Unknown mode: %s\n", *argv);
+ errorMsg("Unknown mode: %s\n", *argv);
exit FALSE;
}
/* Set the umask for this process so it doesn't
char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) {
- fprintf(stderr, name_too_long, "mkdir");
+ errorMsg(name_too_long);
exit FALSE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
- fprintf(stderr, "%s: File exists\n", buf);
+ errorMsg("%s: File exists\n", buf);
exit FALSE;
}
if (parentFlag == TRUE) {
*/
static volatile void die(char *str)
{
- fprintf(stderr, "%s: %s\n", applet_name, str);
+ errorMsg("%s\n", str);
exit(8);
}
#ifdef HAVE_MINIX2
version2 = 1;
#else
- fprintf(stderr, "%s: not compiled with minix v2 support\n",
- applet_name, device_name);
+ errorMsg("%s: not compiled with minix v2 support\n",
+ device_name);
exit(-1);
#endif
break;
#ifdef PAGE_SIZE
if (pagesize != PAGE_SIZE)
- fprintf(stderr, "Assuming pages of size %d\n", pagesize);
+ errorMsg("Assuming pages of size %d\n", pagesize);
#endif
signature_page = (int *) xmalloc(pagesize);
memset(signature_page, 0, pagesize);
void die(const char *str)
{
- fprintf(stderr, "%s: %s\n", applet_name, str);
+ errorMsg("%s\n", str);
exit(FALSE);
}
}
}
if (!device_name) {
- fprintf(stderr,
- "%s: error: Nowhere to set up swap on?\n", applet_name);
+ errorMsg("error: Nowhere to set up swap on?\n");
usage(mkswap_usage);
}
sz = get_size(device_name);
if (!PAGES) {
PAGES = sz;
} else if (PAGES > sz && !force) {
- fprintf(stderr,
- "%s: error: "
- "size %ld is larger than device size %d\n",
- applet_name,
+ errorMsg("error: size %ld is larger than device size %d\n",
PAGES * (pagesize / 1024), sz * (pagesize / 1024));
exit(FALSE);
}
version = 1;
}
if (version != 0 && version != 1) {
- fprintf(stderr, "%s: error: unknown version %d\n",
- applet_name, version);
+ errorMsg("error: unknown version %d\n", version);
usage(mkswap_usage);
}
if (PAGES < 10) {
- fprintf(stderr,
- "%s: error: swap area needs to be at least %ldkB\n",
- applet_name, (long) (10 * pagesize / 1024));
+ errorMsg("error: swap area needs to be at least %ldkB\n",
+ (long) (10 * pagesize / 1024));
usage(mkswap_usage);
}
#if 0
#endif
if (PAGES > maxpages) {
PAGES = maxpages;
- fprintf(stderr, "%s: warning: truncating swap area to %ldkB\n",
- applet_name, PAGES * pagesize / 1024);
+ errorMsg("warning: truncating swap area to %ldkB\n",
+ PAGES * pagesize / 1024);
}
DEV = open(device_name, O_RDWR);
for (sum = 0; q >= (unsigned short *) buffer;)
sum ^= *q--;
if (!sum) {
- fprintf(stderr, "\
-%s: Device '%s' contains a valid Sun disklabel.\n\
-This probably means creating v0 swap would destroy your partition table\n\
-No swap created. If you really want to create swap v0 on that device, use\n\
-the -f option to force it.\n", applet_name, device_name);
+ errorMsg("Device '%s' contains a valid Sun disklabel.\n"
+"This probably means creating v0 swap would destroy your partition table\n"
+"No swap created. If you really want to create swap v0 on that device, use\n"
+"the -f option to force it.\n", device_name);
exit(FALSE);
}
}
#ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1
-#ident "$Id: insmod.c,v 1.15 2000/07/11 17:52:22 andersen Exp $"
+#ident "$Id: insmod.c,v 1.16 2000/07/14 01:51:25 kraai Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1
-#ident "$Id: insmod.c,v 1.15 2000/07/11 17:52:22 andersen Exp $"
+#ident "$Id: insmod.c,v 1.16 2000/07/14 01:51:25 kraai Exp $"
/* The relocatable object is manipulated using elfin types. */
/* Don't report an error if the symbol is coming from
the kernel or some external module. */
if (secidx <= SHN_HIRESERVE)
- fprintf(stderr, "%s multiply defined\n", name);
+ errorMsg("%s multiply defined\n", name);
return sym;
}
}
/* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- fprintf(stderr, "symbol for parameter %s not found\n", p);
+ errorMsg("symbol for parameter %s not found\n", p);
return 0;
}
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
- fprintf(stderr, "improperly terminated string argument for %s\n", p);
+ errorMsg("improperly terminated string argument for %s\n", p);
return 0;
} else if (*q == '\\')
switch (*++q) {
p = get_modinfo_value(f, key);
key += 5;
if (p == NULL) {
- fprintf(stderr, "invalid parameter %s\n", key);
+ errorMsg("invalid parameter %s\n", key);
return 0;
}
/* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
- fprintf(stderr, "symbol for parameter %s not found\n", key);
+ errorMsg("symbol for parameter %s not found\n", key);
return 0;
}
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
- fprintf(stderr,
- "improperly terminated string argument for %s\n",
+ errorMsg("improperly terminated string argument for %s\n",
key);
return 0;
} else if (*q == '\\')
/* Get the size of each member */
/* Probably we should do that outside the loop ? */
if (!isdigit(*(p + 1))) {
- fprintf(stderr,
- "parameter type 'c' for %s must be followed by"
+ errorMsg("parameter type 'c' for %s must be followed by"
" the maximum size\n", key);
return 0;
}
/* Check length */
if (strlen(str) >= charssize) {
- fprintf(stderr,
- "string too long for %s (max %ld)\n", key,
+ errorMsg("string too long for %s (max %ld)\n", key,
charssize - 1);
return 0;
}
break;
default:
- fprintf(stderr, "unknown parameter type '%c' for %s\n",
- *p, key);
+ errorMsg("unknown parameter type '%c' for %s\n", *p, key);
return 0;
}
}
case ',':
if (++n > max) {
- fprintf(stderr, "too many values for %s (max %d)\n",
- key, max);
+ errorMsg("too many values for %s (max %d)\n", key, max);
return 0;
}
++q;
break;
default:
- fprintf(stderr, "invalid argument syntax for %s\n", key);
+ errorMsg("invalid argument syntax for %s\n", key);
return 0;
}
}
end_of_arg:
if (n < min) {
- fprintf(stderr, "too few values for %s (min %d)\n", key, min);
+ errorMsg("too few values for %s (min %d)\n", key, min);
return 0;
}
sym->secidx = SHN_ABS;
sym->value = 0;
} else {
- fprintf(stderr, "unresolved symbol %s\n", sym->name);
+ errorMsg("unresolved symbol %s\n", sym->name);
ret = 0;
}
}
errmsg = "Unhandled relocation";
bad_reloc:
if (extsym) {
- fprintf(stderr, "%s of type %ld for %s\n", errmsg,
+ errorMsg("%s of type %ld for %s\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info),
strtab + extsym->st_name);
} else {
- fprintf(stderr, "%s of type %ld\n", errmsg,
+ errorMsg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info));
}
ret = 0;
|| f->header.e_ident[EI_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) {
- fprintf(stderr, "not an ELF file\n");
+ errorMsg("not an ELF file\n");
return NULL;
}
if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) {
- fprintf(stderr, "ELF file not for this architecture\n");
+ errorMsg("ELF file not for this architecture\n");
return NULL;
}
if (f->header.e_type != ET_REL) {
- fprintf(stderr, "ELF file not a relocatable object\n");
+ errorMsg("ELF file not a relocatable object\n");
return NULL;
}
/* Read the section headers. */
if (f->header.e_shentsize != sizeof(ElfW(Shdr))) {
- fprintf(stderr, "section header size mismatch: %lu != %lu\n",
+ errorMsg("section header size mismatch: %lu != %lu\n",
(unsigned long) f->header.e_shentsize,
(unsigned long) sizeof(ElfW(Shdr)));
return NULL;
#if SHT_RELM == SHT_REL
case SHT_RELA:
- fprintf(stderr,
- "RELA relocations not supported on this architecture\n");
+ errorMsg("RELA relocations not supported on this architecture\n");
return NULL;
#else
case SHT_REL:
- fprintf(stderr,
- "REL relocations not supported on this architecture\n");
+ errorMsg("REL relocations not supported on this architecture\n");
return NULL;
#endif
break;
}
- fprintf(stderr, "can't handle sections of type %ld\n",
+ errorMsg("can't handle sections of type %ld\n",
(long) sec->header.sh_type);
return NULL;
}
ElfW(Sym) * sym;
if (sec->header.sh_entsize != sizeof(ElfW(Sym))) {
- fprintf(stderr, "symbol size mismatch: %lu != %lu\n",
+ errorMsg("symbol size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(Sym)));
return NULL;
case SHT_RELM:
if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
- fprintf(stderr,
- "relocation entry size mismatch: %lu != %lu\n",
+ errorMsg("relocation entry size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(RelM)));
return NULL;
} else {
m_version = old_get_module_version(f, m_strversion);
if (m_version == -1) {
- fprintf(stderr,
- "couldn't find the kernel version the module was compiled for\n");
+ errorMsg("couldn't find the kernel version the module was "
+ "compiled for\n");
goto out;
}
}
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) {
- fprintf(stderr, "Warning: kernel-module version mismatch\n"
+ errorMsg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion);
} else {
- fprintf(stderr, "kernel-module version mismatch\n"
+ errorMsg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion);
goto out;
k_crcs = new_is_kernel_checksummed();
#else
- fprintf(stderr, "Not configured to support new kernels\n");
+ errorMsg("Not configured to support new kernels\n");
goto out;
#endif
} else {
goto out;
k_crcs = old_is_kernel_checksummed();
#else
- fprintf(stderr, "Not configured to support old kernels\n");
+ errorMsg("Not configured to support old kernels\n");
goto out;
#endif
}
case 0:
break;
case EEXIST:
- fprintf(stderr, "A module named %s already exists\n", m_name);
+ errorMsg("A module named %s already exists\n", m_name);
goto out;
case ENOMEM:
- fprintf(stderr,
- "Can't allocate kernel memory for module; needed %lu bytes\n",
+ errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n",
m_size);
goto out;
default:
specialfile = find_unused_loop_device();
if (specialfile == NULL) {
- fprintf(stderr, "Could not find a spare loop device\n");
+ errorMsg("Could not find a spare loop device\n");
return (FALSE);
}
if (set_loop(specialfile, lofile, 0, &loro)) {
- fprintf(stderr, "Could not setup loop device\n");
+ errorMsg("Could not setup loop device\n");
return (FALSE);
}
if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */
- fprintf(stderr, "WARNING: loop device is read-only\n");
+ errorMsg("WARNING: loop device is read-only\n");
flags &= ~MS_RDONLY;
}
}
if (status == FALSE) {
if (whineOnErrors == TRUE) {
- fprintf(stderr, "Mounting %s on %s failed: %s\n",
+ errorMsg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno));
}
return (FALSE);
}
if (code->name == 0) {
- fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
+ errorMsg("unrecognized opcode %s.\n", argv[1]);
exit (FALSE);
}
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.10 2000/06/19 17:25:39 andersen Exp $
+ * $Id: hostname.c,v 1.11 2000/07/14 01:51:25 kraai Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM)
- fprintf(stderr,
- "hostname: you must be root to change the hostname\n");
+ errorMsg("you must be root to change the hostname\n");
else
perror("sethostname");
exit(1);
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.20 2000/07/12 17:02:35 kraai Exp $
+ * $Id: ping.c,v 1.21 2000/07/14 01:51:25 kraai Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) {
- fprintf(stderr, "ping: unknown host %s\n", host);
+ errorMsg("unknown host %s\n", host);
exit(1);
}
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
if (c < 0 || c != sizeof(packet)) {
if (c < 0)
perror("ping: sendto");
- fprintf(stderr, "ping: write incomplete\n");
+ errorMsg("write incomplete\n");
exit(1);
}
printf("\n");
} else
if (icmppkt->icmp_type != ICMP_ECHO)
- fprintf(stderr,
- "Warning: Got ICMP %d (%s)\n",
+ errorMsg("Warning: Got ICMP %d (%s)\n",
icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
}
if ((pingsock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
if (errno == EPERM) {
- fprintf(stderr, "ping: permission denied. (are you root?)\n");
+ errorMsg("permission denied. (are you root?)\n");
} else {
perror("ping: creating a raw socket");
}
pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) {
- fprintf(stderr, "ping: unknown host %s\n", host);
+ errorMsg("unknown host %s\n", host);
exit(1);
}
if (h->h_addrtype != AF_INET) {
- fprintf(stderr,
- "ping: unknown address type; only AF_INET is currently supported.\n");
+ errorMsg("unknown address type; only AF_INET is currently supported.\n");
exit(1);
}
msock = fsock = -1;
mclient = NULL;
if (strlen(spec) >= sizeof(hostdir)) {
- fprintf(stderr, _("mount: "
- "excessively long host:dir argument\n"));
+ errorMsg("excessively long host:dir argument\n");
goto fail;
}
strcpy(hostdir, spec);
until they can be fully supported. (mack@sgi.com) */
if ((s = strchr(hostdir, ','))) {
*s = '\0';
- fprintf(stderr, _("mount: warning: "
- "multiple hostnames not supported\n"));
+ errorMsg("warning: multiple hostnames not supported\n");
}
} else {
- fprintf(stderr, _("mount: "
- "directory to mount not in host:dir format\n"));
+ errorMsg("directory to mount not in host:dir format\n");
goto fail;
}
#endif
{
if ((hp = gethostbyname(hostname)) == NULL) {
- fprintf(stderr, _("mount: can't get address for %s\n"),
- hostname);
+ errorMsg("can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
- fprintf(stderr,
- _("mount: got bad hp->h_length\n"));
+ errorMsg("got bad hp->h_length\n");
hp->h_length = sizeof(struct in_addr);
}
memcpy(&server_addr.sin_addr,
if (!old_opts)
old_opts = "";
if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
- fprintf(stderr, _("mount: "
- "excessively long option argument\n"));
+ errorMsg("excessively long option argument\n");
goto fail;
}
sprintf(new_opts, "%s%saddr=%s",
data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
#endif
if (nfsvers > MAX_NFSPROT) {
- fprintf(stderr, "NFSv%d not supported!\n", nfsvers);
+ errorMsg("NFSv%d not supported!\n", nfsvers);
return 0;
}
if (mountvers > MAX_NFSPROT) {
- fprintf(stderr, "NFSv%d not supported!\n", nfsvers);
+ errorMsg("NFSv%d not supported!\n", nfsvers);
return 0;
}
if (nfsvers && !mountvers)
mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
} else {
if ((hp = gethostbyname(mounthost)) == NULL) {
- fprintf(stderr, _("mount: can't get address for %s\n"),
- hostname);
+ errorMsg("can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
- fprintf(stderr,
- _("mount: got bad hp->h_length?\n"));
+ errorMsg("got bad hp->h_length?\n");
hp->h_length = sizeof(struct in_addr);
}
mount_server_addr.sin_family = AF_INET;
if (nfsvers == 2) {
if (status.nfsv2.fhs_status != 0) {
- fprintf(stderr,
- "mount: %s:%s failed, reason given by server: %s\n",
+ errorMsg("%s:%s failed, reason given by server: %s\n",
hostname, dirname,
nfs_strerror(status.nfsv2.fhs_status));
goto fail;
#if NFS_MOUNT_VERSION >= 4
fhandle3 *fhandle;
if (status.nfsv3.fhs_status != 0) {
- fprintf(stderr,
- "mount: %s:%s failed, reason given by server: %s\n",
+ errorMsg("%s:%s failed, reason given by server: %s\n",
hostname, dirname,
nfs_strerror(status.nfsv3.fhs_status));
goto fail;
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.20 2000/07/12 17:02:35 kraai Exp $
+ * $Id: ping.c,v 1.21 2000/07/14 01:51:25 kraai Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) {
- fprintf(stderr, "ping: unknown host %s\n", host);
+ errorMsg("unknown host %s\n", host);
exit(1);
}
memcpy(&pingaddr.sin_addr, h->h_addr, sizeof(pingaddr.sin_addr));
if (c < 0 || c != sizeof(packet)) {
if (c < 0)
perror("ping: sendto");
- fprintf(stderr, "ping: write incomplete\n");
+ errorMsg("write incomplete\n");
exit(1);
}
printf("\n");
} else
if (icmppkt->icmp_type != ICMP_ECHO)
- fprintf(stderr,
- "Warning: Got ICMP %d (%s)\n",
+ errorMsg("Warning: Got ICMP %d (%s)\n",
icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
}
if ((pingsock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
if (errno == EPERM) {
- fprintf(stderr, "ping: permission denied. (are you root?)\n");
+ errorMsg("permission denied. (are you root?)\n");
} else {
perror("ping: creating a raw socket");
}
pingaddr.sin_family = AF_INET;
if (!(h = gethostbyname(host))) {
- fprintf(stderr, "ping: unknown host %s\n", host);
+ errorMsg("unknown host %s\n", host);
exit(1);
}
if (h->h_addrtype != AF_INET) {
- fprintf(stderr,
- "ping: unknown address type; only AF_INET is currently supported.\n");
+ errorMsg("unknown address type; only AF_INET is currently supported.\n");
exit(1);
}
if (tmp)
sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid);
else
- fprintf(stderr, "Internal error!\n");
+ errorMsg("Internal error!\n");
/* For busybox, ignoring effective, saved, etc */
tmp = strstr(S, "Uid:");
if (tmp)
sscanf(tmp, "Uid:\t%d", &P->ruid);
else
- fprintf(stderr, "Internal error!\n");
+ errorMsg("Internal error!\n");
tmp = strstr(S, "Gid:");
if (tmp)
sscanf(tmp, "Gid:\t%d", &P->rgid);
else
- fprintf(stderr, "Internal error!\n");
+ errorMsg("Internal error!\n");
}
if (tmp)
sscanf(tmp, "Pid:\t%d\n" "PPid:\t%d\n", &P->pid, &P->ppid);
else
- fprintf(stderr, "Internal error!\n");
+ errorMsg("Internal error!\n");
/* For busybox, ignoring effective, saved, etc */
tmp = strstr(S, "Uid:");
if (tmp)
sscanf(tmp, "Uid:\t%d", &P->ruid);
else
- fprintf(stderr, "Internal error!\n");
+ errorMsg("Internal error!\n");
tmp = strstr(S, "Gid:");
if (tmp)
sscanf(tmp, "Gid:\t%d", &P->rgid);
else
- fprintf(stderr, "Internal error!\n");
+ errorMsg("Internal error!\n");
}
while (--argc > 0) {
if (rmdir(*(++argv)) == -1) {
- fprintf(stderr, "%s: %s\n", applet_name, strerror(errno));
+ errorMsg("%s\n", strerror(errno));
exit(FALSE);
}
}
idx++; /* so it points to the next character after the last '/' */
}
else {
- fprintf(stderr, "sed.c:get_address: no address found in string\n");
- fprintf(stderr, "\t(you probably didn't check the string you passed me)\n");
+ errorMsg("get_address: no address found in string\n"
+ "\t(you probably didn't check the string you passed me)\n");
idx = -1;
}
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
- fprintf(stderr, "sed: %s: %s\n", argv[i], strerror(errno));
+ errorMsg("%s: %s\n", argv[i], strerror(errno));
} else {
process_file(file);
fclose(file);
if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
- fprintf(stderr, "%s: exactly one argument is expected\n",
+ errorMsg("%s: exactly one argument is expected\n",
cmd->progs[0].argv[0]);
return FALSE;
}
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) {
- fprintf(stderr, "%s: bad argument '%s'\n",
+ errorMsg("%s: bad argument '%s'\n",
cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return FALSE;
for (job = jobList->head; job; job = job->next) {
}
if (!job) {
- fprintf(stderr, "%s: unknown job %d\n",
+ errorMsg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum);
return FALSE;
}
rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) {
- fprintf(stderr, "out of space during glob operation\n");
+ errorMsg("out of space during glob operation\n");
return;
} else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 &&
if (*src == '\\') {
src++;
if (!*src) {
- fprintf(stderr, "character expected after \\\n");
+ errorMsg("character expected after \\\n");
freeJob(job);
return 1;
}
chptr++;
if (!*chptr) {
- fprintf(stderr, "file name expected after %c\n", *src);
+ errorMsg("file name expected after %c\n", *src);
freeJob(job);
job->numProgs=0;
return 1;
if (*prog->argv[argc])
argc++;
if (!argc) {
- fprintf(stderr, "empty command in pipe1.\n");
+ errorMsg("empty command in pipe1\n");
freeJob(job);
job->numProgs=0;
return 1;
src++;
if (!*src) {
- fprintf(stderr, "empty command in pipe2\n");
+ errorMsg("empty command in pipe2\n");
freeJob(job);
job->numProgs=0;
return 1;
case '\\':
src++;
if (!*src) {
- fprintf(stderr, "character expected after \\\n");
+ errorMsg("character expected after \\\n");
freeJob(job);
return 1;
}
if (openfd < 0) {
/* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */
- fprintf(stderr, "error opening %s: %s\n", redir->filename,
+ errorMsg("error opening %s: %s\n", redir->filename,
strerror(errno));
return 1;
}
if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
- fprintf(stderr, "%s: exactly one argument is expected\n",
+ errorMsg("%s: exactly one argument is expected\n",
cmd->progs[0].argv[0]);
return FALSE;
}
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) {
- fprintf(stderr, "%s: bad argument '%s'\n",
+ errorMsg("%s: bad argument '%s'\n",
cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return FALSE;
for (job = jobList->head; job; job = job->next) {
}
if (!job) {
- fprintf(stderr, "%s: unknown job %d\n",
+ errorMsg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum);
return FALSE;
}
rc = glob(prog->argv[argc - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) {
- fprintf(stderr, "out of space during glob operation\n");
+ errorMsg("out of space during glob operation\n");
return;
} else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 &&
if (*src == '\\') {
src++;
if (!*src) {
- fprintf(stderr, "character expected after \\\n");
+ errorMsg("character expected after \\\n");
freeJob(job);
return 1;
}
chptr++;
if (!*chptr) {
- fprintf(stderr, "file name expected after %c\n", *src);
+ errorMsg("file name expected after %c\n", *src);
freeJob(job);
job->numProgs=0;
return 1;
if (*prog->argv[argc])
argc++;
if (!argc) {
- fprintf(stderr, "empty command in pipe1.\n");
+ errorMsg("empty command in pipe1\n");
freeJob(job);
job->numProgs=0;
return 1;
src++;
if (!*src) {
- fprintf(stderr, "empty command in pipe2\n");
+ errorMsg("empty command in pipe2\n");
freeJob(job);
job->numProgs=0;
return 1;
case '\\':
src++;
if (!*src) {
- fprintf(stderr, "character expected after \\\n");
+ errorMsg("character expected after \\\n");
freeJob(job);
return 1;
}
if (openfd < 0) {
/* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */
- fprintf(stderr, "error opening %s: %s\n", redir->filename,
+ errorMsg("error opening %s: %s\n", redir->filename,
strerror(errno));
return 1;
}
break;
#endif
default:
- fprintf(stderr, "sort: invalid option -- %c\n", opt);
+ errorMsg("invalid option -- %c\n", opt);
usage(sort_usage);
}
} else {
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 $ */
*s = '\0';
fac = decode(save, facilitynames);
if (fac < 0) {
- fprintf(stderr, "unknown facility name: %s\n", save);
+ errorMsg("unknown facility name: %s\n", save);
exit(FALSE);
}
*s++ = '.';
}
lev = decode(s, prioritynames);
if (lev < 0) {
- fprintf(stderr, "unknown priority name: %s\n", save);
+ errorMsg("unknown priority name: %s\n", save);
exit(FALSE);
}
return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
if (argc >= 1) {
message = *argv;
} else {
- fprintf(stderr, "No message\n");
+ errorMsg("No message\n");
exit(FALSE);
}
}
usage(tail_usage);
default:
if ((n_units = atoi(&argv[i][1])) < 1) {
- fprintf(stderr, "tail: invalid option -- %c\n", opt);
+ errorMsg("invalid option -- %c\n", opt);
usage(tail_usage);
}
}
if (i + 1 < argc) {
if (forever) {
- fprintf(stderr,
- "tail: option -f is invalid with multiple files\n");
+ errorMsg("option -f is invalid with multiple files\n");
usage(tail_usage);
}
print_headers = 1;
/* init FILE pointers */
FileList = calloc(FL_MAX, sizeof(FILE*));
if (!FileList) {
- fprintf(stderr, "tee: %s\n", strerror(errno));
+ errorMsg("%s\n", strerror(errno));
exit(1);
}
FL_end = 0;
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 $ */
return;
if ((fp = setmntent(mtab_file, "r")) == NULL) {
- fprintf(stderr, "Cannot open %s\n", mtab_file);
+ errorMsg("Cannot open %s\n", mtab_file);
return;
}
while ((e = getmntent(fp))) {
status = mount(blockDevice, name, NULL,
MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
if (status == 0) {
- fprintf(stderr, "umount: %s busy - remounted read-only\n",
- blockDevice);
+ errorMsg("%s busy - remounted read-only\n", blockDevice);
} else {
- fprintf(stderr, "umount: Cannot remount %s read-only\n",
- blockDevice);
+ errorMsg("Cannot remount %s read-only\n", blockDevice);
}
}
if (status == 0) {
break;
}
if (*in == NULL) {
- fprintf(stderr, "uniq: %s: %s\n", argv[0], strerror(errno));
+ errorMsg("%s: %s\n", argv[0], strerror(errno));
return errno;
}
if (*out == NULL) {
- fprintf(stderr, "uniq: %s: %s\n", argv[1], strerror(errno));
+ errorMsg("%s: %s\n", argv[1], strerror(errno));
return errno;
}
return 0;
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 $ */
PERROR("fbset(ioctl)");
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
- fprintf(stderr, "Unknown video mode `%s'\n", mode);
+ errorMsg("Unknown video mode `%s'\n", mode);
exit(1);
}
}
static void die(const char *str)
{
- fprintf(stderr, "%s: %s\n", applet_name, str);
+ errorMsg("%s\n", str);
leave(8);
}
*/
static volatile void die(char *str)
{
- fprintf(stderr, "%s: %s\n", applet_name, str);
+ errorMsg("%s\n", str);
exit(8);
}
#ifdef HAVE_MINIX2
version2 = 1;
#else
- fprintf(stderr, "%s: not compiled with minix v2 support\n",
- applet_name, device_name);
+ errorMsg("%s: not compiled with minix v2 support\n",
+ device_name);
exit(-1);
#endif
break;
#ifdef PAGE_SIZE
if (pagesize != PAGE_SIZE)
- fprintf(stderr, "Assuming pages of size %d\n", pagesize);
+ errorMsg("Assuming pages of size %d\n", pagesize);
#endif
signature_page = (int *) xmalloc(pagesize);
memset(signature_page, 0, pagesize);
void die(const char *str)
{
- fprintf(stderr, "%s: %s\n", applet_name, str);
+ errorMsg("%s\n", str);
exit(FALSE);
}
}
}
if (!device_name) {
- fprintf(stderr,
- "%s: error: Nowhere to set up swap on?\n", applet_name);
+ errorMsg("error: Nowhere to set up swap on?\n");
usage(mkswap_usage);
}
sz = get_size(device_name);
if (!PAGES) {
PAGES = sz;
} else if (PAGES > sz && !force) {
- fprintf(stderr,
- "%s: error: "
- "size %ld is larger than device size %d\n",
- applet_name,
+ errorMsg("error: size %ld is larger than device size %d\n",
PAGES * (pagesize / 1024), sz * (pagesize / 1024));
exit(FALSE);
}
version = 1;
}
if (version != 0 && version != 1) {
- fprintf(stderr, "%s: error: unknown version %d\n",
- applet_name, version);
+ errorMsg("error: unknown version %d\n", version);
usage(mkswap_usage);
}
if (PAGES < 10) {
- fprintf(stderr,
- "%s: error: swap area needs to be at least %ldkB\n",
- applet_name, (long) (10 * pagesize / 1024));
+ errorMsg("error: swap area needs to be at least %ldkB\n",
+ (long) (10 * pagesize / 1024));
usage(mkswap_usage);
}
#if 0
#endif
if (PAGES > maxpages) {
PAGES = maxpages;
- fprintf(stderr, "%s: warning: truncating swap area to %ldkB\n",
- applet_name, PAGES * pagesize / 1024);
+ errorMsg("warning: truncating swap area to %ldkB\n",
+ PAGES * pagesize / 1024);
}
DEV = open(device_name, O_RDWR);
for (sum = 0; q >= (unsigned short *) buffer;)
sum ^= *q--;
if (!sum) {
- fprintf(stderr, "\
-%s: Device '%s' contains a valid Sun disklabel.\n\
-This probably means creating v0 swap would destroy your partition table\n\
-No swap created. If you really want to create swap v0 on that device, use\n\
-the -f option to force it.\n", applet_name, device_name);
+ errorMsg("Device '%s' contains a valid Sun disklabel.\n"
+"This probably means creating v0 swap would destroy your partition table\n"
+"No swap created. If you really want to create swap v0 on that device, use\n"
+"the -f option to force it.\n", device_name);
exit(FALSE);
}
}
specialfile = find_unused_loop_device();
if (specialfile == NULL) {
- fprintf(stderr, "Could not find a spare loop device\n");
+ errorMsg("Could not find a spare loop device\n");
return (FALSE);
}
if (set_loop(specialfile, lofile, 0, &loro)) {
- fprintf(stderr, "Could not setup loop device\n");
+ errorMsg("Could not setup loop device\n");
return (FALSE);
}
if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */
- fprintf(stderr, "WARNING: loop device is read-only\n");
+ errorMsg("WARNING: loop device is read-only\n");
flags &= ~MS_RDONLY;
}
}
if (status == FALSE) {
if (whineOnErrors == TRUE) {
- fprintf(stderr, "Mounting %s on %s failed: %s\n",
+ errorMsg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno));
}
return (FALSE);
msock = fsock = -1;
mclient = NULL;
if (strlen(spec) >= sizeof(hostdir)) {
- fprintf(stderr, _("mount: "
- "excessively long host:dir argument\n"));
+ errorMsg("excessively long host:dir argument\n");
goto fail;
}
strcpy(hostdir, spec);
until they can be fully supported. (mack@sgi.com) */
if ((s = strchr(hostdir, ','))) {
*s = '\0';
- fprintf(stderr, _("mount: warning: "
- "multiple hostnames not supported\n"));
+ errorMsg("warning: multiple hostnames not supported\n");
}
} else {
- fprintf(stderr, _("mount: "
- "directory to mount not in host:dir format\n"));
+ errorMsg("directory to mount not in host:dir format\n");
goto fail;
}
#endif
{
if ((hp = gethostbyname(hostname)) == NULL) {
- fprintf(stderr, _("mount: can't get address for %s\n"),
- hostname);
+ errorMsg("can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
- fprintf(stderr,
- _("mount: got bad hp->h_length\n"));
+ errorMsg("got bad hp->h_length\n");
hp->h_length = sizeof(struct in_addr);
}
memcpy(&server_addr.sin_addr,
if (!old_opts)
old_opts = "";
if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
- fprintf(stderr, _("mount: "
- "excessively long option argument\n"));
+ errorMsg("excessively long option argument\n");
goto fail;
}
sprintf(new_opts, "%s%saddr=%s",
data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
#endif
if (nfsvers > MAX_NFSPROT) {
- fprintf(stderr, "NFSv%d not supported!\n", nfsvers);
+ errorMsg("NFSv%d not supported!\n", nfsvers);
return 0;
}
if (mountvers > MAX_NFSPROT) {
- fprintf(stderr, "NFSv%d not supported!\n", nfsvers);
+ errorMsg("NFSv%d not supported!\n", nfsvers);
return 0;
}
if (nfsvers && !mountvers)
mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
} else {
if ((hp = gethostbyname(mounthost)) == NULL) {
- fprintf(stderr, _("mount: can't get address for %s\n"),
- hostname);
+ errorMsg("can't get address for %s\n", hostname);
goto fail;
} else {
if (hp->h_length > sizeof(struct in_addr)) {
- fprintf(stderr,
- _("mount: got bad hp->h_length?\n"));
+ errorMsg("got bad hp->h_length?\n");
hp->h_length = sizeof(struct in_addr);
}
mount_server_addr.sin_family = AF_INET;
if (nfsvers == 2) {
if (status.nfsv2.fhs_status != 0) {
- fprintf(stderr,
- "mount: %s:%s failed, reason given by server: %s\n",
+ errorMsg("%s:%s failed, reason given by server: %s\n",
hostname, dirname,
nfs_strerror(status.nfsv2.fhs_status));
goto fail;
#if NFS_MOUNT_VERSION >= 4
fhandle3 *fhandle;
if (status.nfsv3.fhs_status != 0) {
- fprintf(stderr,
- "mount: %s:%s failed, reason given by server: %s\n",
+ errorMsg("%s:%s failed, reason given by server: %s\n",
hostname, dirname,
nfs_strerror(status.nfsv3.fhs_status));
goto fail;
return;
if ((fp = setmntent(mtab_file, "r")) == NULL) {
- fprintf(stderr, "Cannot open %s\n", mtab_file);
+ errorMsg("Cannot open %s\n", mtab_file);
return;
}
while ((e = getmntent(fp))) {
status = mount(blockDevice, name, NULL,
MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL);
if (status == 0) {
- fprintf(stderr, "umount: %s busy - remounted read-only\n",
- blockDevice);
+ errorMsg("%s busy - remounted read-only\n", blockDevice);
} else {
- fprintf(stderr, "umount: Cannot remount %s read-only\n",
- blockDevice);
+ errorMsg("Cannot remount %s read-only\n", blockDevice);
}
}
if (status == 0) {
if ((srcStatBuf.st_dev == dstStatBuf.st_dev) &&
(srcStatBuf.st_ino == dstStatBuf.st_ino)) {
- fprintf(stderr, "Copying file \"%s\" to itself\n", srcName);
+ errorMsg("Copying file \"%s\" to itself\n", srcName);
return FALSE;
}
continue;
}
if (strlen(fileName) + strlen(next->d_name) + 1 > BUFSIZ) {
- fprintf(stderr, name_too_long, "ftw");
+ errorMsg(name_too_long);
return FALSE;
}
memset(nextFile, 0, sizeof(nextFile));
if (is_a_console(fd))
return fd;
- fprintf(stderr,
- "Couldnt get a file descriptor referring to the console\n");
+ errorMsg("Couldnt get a file descriptor referring to the console\n");
return -1; /* total failure */
}
puts(user);
exit(TRUE);
}
- fprintf(stderr, "%s: cannot find username for UID %u\n", applet_name,
- (unsigned) uid);
+ errorMsg("cannot find username for UID %u\n", (unsigned) uid);
return(FALSE);
}