Change calls to error_msg.* and strerror to use perror_msg.*.

This commit is contained in:
Matt Kraai 2000-12-18 03:57:16 +00:00
parent 0dab829977
commit 1fa1adea2a
52 changed files with 185 additions and 204 deletions

View File

@ -54,7 +54,7 @@ static char *busybox_fullpath()
if (len != -1) { if (len != -1) {
path[len] = 0; path[len] = 0;
} else { } else {
error_msg("%s: %s\n", proc, strerror(errno)); perror_msg("%s", proc);
return NULL; return NULL;
} }
return strdup(path); return strdup(path);
@ -78,7 +78,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
rc = Link(busybox, command); rc = Link(busybox, command);
if (rc) { if (rc) {
error_msg("%s: %s\n", command, strerror(errno)); perror_msg("%s", command);
} }
} }
} }

View File

@ -317,7 +317,7 @@ extern int tar_main(int argc, char **argv)
else else
tarFd = open(tarName, O_RDONLY); tarFd = open(tarName, O_RDONLY);
if (tarFd < 0) if (tarFd < 0)
error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno)); perror_msg_and_die("Error opening '%s'", tarName);
#ifdef BB_FEATURE_TAR_GZIP #ifdef BB_FEATURE_TAR_GZIP
/* unzip tarFd in a seperate process */ /* unzip tarFd in a seperate process */
@ -425,8 +425,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE); return( TRUE);
if (create_path(header->name, header->mode) != TRUE) { if (create_path(header->name, header->mode) != TRUE) {
error_msg("%s: Cannot mkdir: %s\n", perror_msg("%s: Cannot mkdir", header->name);
header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
/* make the final component, just in case it was /* make the final component, just in case it was
@ -445,8 +444,8 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE); return( TRUE);
if (link(header->linkname, header->name) < 0) { if (link(header->linkname, header->name) < 0) {
error_msg("%s: Cannot create hard link to '%s': %s\n", perror_msg("%s: Cannot create hard link to '%s'", header->name,
header->name, header->linkname, strerror(errno)); header->linkname);
return( FALSE); return( FALSE);
} }
@ -463,8 +462,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
#ifdef S_ISLNK #ifdef S_ISLNK
if (symlink(header->linkname, header->name) < 0) { if (symlink(header->linkname, header->name) < 0) {
error_msg("%s: Cannot create symlink to '%s': %s\n", perror_msg("%s: Cannot create symlink to '%s'", header->name,
header->name, header->linkname, strerror(errno)); header->linkname);
return( FALSE); return( FALSE);
} }
/* Try to change ownership of the symlink. /* Try to change ownership of the symlink.
@ -493,14 +492,12 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) { if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) { if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
error_msg("%s: Cannot mknod: %s\n", perror_msg("%s: Cannot mknod", header->name);
header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
} else if (S_ISFIFO(header->mode)) { } else if (S_ISFIFO(header->mode)) {
if (mkfifo(header->name, header->mode) < 0) { if (mkfifo(header->name, header->mode) < 0) {
error_msg("%s: Cannot mkfifo: %s\n", perror_msg("%s: Cannot mkfifo", header->name);
header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
} }
@ -790,7 +787,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
close(tarFd); close(tarFd);
if (status > 0) { if (status > 0) {
/* Bummer - we read a partial header */ /* Bummer - we read a partial header */
error_msg( "Error reading tar file: %s\n", strerror(errno)); perror_msg("Error reading tar file");
return ( FALSE); return ( FALSE);
} }
else if (errorFlag==TRUE) { else if (errorFlag==TRUE) {
@ -1007,7 +1004,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
header.typeflag = SYMTYPE; header.typeflag = SYMTYPE;
link_size = readlink(fileName, buffer, sizeof(buffer) - 1); link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
if ( link_size < 0) { if ( link_size < 0) {
error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); perror_msg("Error reading symlink '%s'", header.name);
return ( FALSE); return ( FALSE);
} }
buffer[link_size] = '\0'; buffer[link_size] = '\0';
@ -1165,7 +1162,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
else else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (tbInfo.tarFd < 0) { if (tbInfo.tarFd < 0) {
error_msg( "Error opening '%s': %s\n", tarName, strerror(errno)); perror_msg( "Error opening '%s'", tarName);
freeHardLinkInfo(&tbInfo.hlInfoHead); freeHardLinkInfo(&tbInfo.hlInfoHead);
return ( FALSE); return ( FALSE);
} }

View File

@ -54,7 +54,7 @@ static char *busybox_fullpath()
if (len != -1) { if (len != -1) {
path[len] = 0; path[len] = 0;
} else { } else {
error_msg("%s: %s\n", proc, strerror(errno)); perror_msg("%s", proc);
return NULL; return NULL;
} }
return strdup(path); return strdup(path);
@ -78,7 +78,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
rc = Link(busybox, command); rc = Link(busybox, command);
if (rc) { if (rc) {
error_msg("%s: %s\n", command, strerror(errno)); perror_msg("%s", command);
} }
} }
} }

View File

@ -38,7 +38,7 @@ int chroot_main(int argc, char **argv)
argv++; argv++;
if (chroot(*argv) || (chdir("/"))) { if (chroot(*argv) || (chdir("/"))) {
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno)); perror_msg_and_die("cannot change root directory to %s", *argv);
} }
argc--; argc--;
@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
#endif #endif
} }
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno)); perror_msg_and_die("cannot execute %s", prog);
} }

View File

@ -50,7 +50,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) {
error_msg("Error opening /dev/tty0: %s\n", strerror(errno)); perror_msg("Error opening /dev/tty0");
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -39,13 +39,11 @@ 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) {
error_msg("Error opening /dev/tty1: %s\n", strerror(errno)); perror_msg_and_die("Error opening /dev/tty1");
return EXIT_FAILURE;
} }
if (screen_map_load(fd, stdin)) { if (screen_map_load(fd, stdin)) {
error_msg("Error loading acm: %s\n", strerror(errno)); perror_msg_and_die("Error loading acm");
return EXIT_FAILURE;
} }
write(fd, "\033(K", 3); write(fd, "\033(K", 3);

View File

@ -38,7 +38,7 @@ int chroot_main(int argc, char **argv)
argv++; argv++;
if (chroot(*argv) || (chdir("/"))) { if (chroot(*argv) || (chdir("/"))) {
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno)); perror_msg_and_die("cannot change root directory to %s", *argv);
} }
argc--; argc--;
@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
#endif #endif
} }
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno)); perror_msg_and_die("cannot execute %s", prog);
} }

View File

@ -234,7 +234,7 @@ extern int cut_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) {
error_msg("%s: %s\n", argv[i], strerror(errno)); perror_msg("%s", argv[i]);
} else { } else {
cut_file(file); cut_file(file);
fclose(file); fclose(file);

View File

@ -80,7 +80,7 @@ int head_main(int argc, char **argv)
} }
head(len, fp); head(len, fp);
if (errno) { if (errno) {
error_msg("%s: %s\n", argv[optind], strerror(errno)); perror_msg("%s", argv[optind]);
status = EXIT_FAILURE; status = EXIT_FAILURE;
errno = 0; errno = 0;
} }

View File

@ -181,7 +181,7 @@ static int my_stat(struct dnode *cur)
#ifdef BB_FEATURE_LS_FOLLOWLINKS #ifdef BB_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) { if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) { if (stat(cur->fullname, &cur->dstat)) {
error_msg("%s: %s\n", cur->fullname, strerror(errno)); perror_msg("%s", cur->fullname);
status = EXIT_FAILURE; status = EXIT_FAILURE;
free(cur->fullname); free(cur->fullname);
free(cur); free(cur);
@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur)
} else } else
#endif #endif
if (lstat(cur->fullname, &cur->dstat)) { if (lstat(cur->fullname, &cur->dstat)) {
error_msg("%s: %s\n", cur->fullname, strerror(errno)); perror_msg("%s", cur->fullname);
status = EXIT_FAILURE; status = EXIT_FAILURE;
free(cur->fullname); free(cur->fullname);
free(cur); free(cur);
@ -511,7 +511,7 @@ struct dnode **list_dir(char *path)
nfiles= 0; nfiles= 0;
dir = opendir(path); dir = opendir(path);
if (dir == NULL) { if (dir == NULL) {
error_msg("%s: %s\n", path, strerror(errno)); perror_msg("%s", path);
status = EXIT_FAILURE; status = EXIT_FAILURE;
return(NULL); /* could not open the dir */ return(NULL); /* could not open the dir */
} }

View File

@ -651,13 +651,13 @@ static int md5_file(const char *filename,
} else { } else {
fp = fopen(filename, OPENOPTS(binary)); fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) { if (fp == NULL) {
error_msg("%s: %s\n", filename, strerror(errno)); perror_msg("%s", filename);
return FALSE; return FALSE;
} }
} }
if (md5_stream(fp, md5_result)) { if (md5_stream(fp, md5_result)) {
error_msg("%s: %s\n", filename, strerror(errno)); perror_msg("%s", filename);
if (fp != stdin) if (fp != stdin)
fclose(fp); fclose(fp);
@ -665,7 +665,7 @@ static int md5_file(const char *filename,
} }
if (fp != stdin && fclose(fp) == EOF) { if (fp != stdin && fclose(fp) == EOF) {
error_msg("%s: %s\n", filename, strerror(errno)); perror_msg("%s", filename);
return FALSE; return FALSE;
} }
@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name)
} else { } else {
checkfile_stream = fopen(checkfile_name, "r"); checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) { if (checkfile_stream == NULL) {
error_msg("%s: %s\n", checkfile_name, strerror(errno)); perror_msg("%s", checkfile_name);
return FALSE; return FALSE;
} }
} }
@ -775,7 +775,7 @@ static int md5_check(const char *checkfile_name)
} }
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) { if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); perror_msg("md5sum: %s", checkfile_name);
return FALSE; return FALSE;
} }

View File

@ -31,8 +31,8 @@ extern int pwd_main(int argc, char **argv)
char buf[BUFSIZ + 1]; char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL) if (getcwd(buf, sizeof(buf)) == NULL)
error_msg_and_die("%s\n", strerror(errno)); perror_msg_and_die("getcwd");
printf("%s\n", buf); puts(buf);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
while (optind < argc) { while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) { if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
nfiles--; nfiles--;
error_msg("%s: %s\n", argv[optind-1], strerror(errno)); perror_msg("%s", argv[optind-1]);
status = 1; status = 1;
} }
} }

View File

@ -257,7 +257,7 @@ static int decode (const char *inname,
&& (freopen (outname, "w", stdout) == NULL && (freopen (outname, "w", stdout) == NULL
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) { )) {
error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */ perror_msg("%s", outname); /* */
return FALSE; return FALSE;
} }
@ -302,7 +302,7 @@ int uudecode_main (int argc,
if (decode (argv[optind], outname) != 0) if (decode (argv[optind], outname) != 0)
exit_status = FALSE; exit_status = FALSE;
} else { } else {
error_msg("%s: %s\n", argv[optind], strerror(errno)); perror_msg("%s", argv[optind]);
exit_status = EXIT_FAILURE; exit_status = EXIT_FAILURE;
} }
optind++; optind++;

View File

@ -160,15 +160,12 @@ int uuencode_main (int argc,
trans_ptr = uu_std; /* Standard encoding is old uu format */ trans_ptr = uu_std; /* Standard encoding is old uu format */
/* Parse any options */ /* Parse any options */
while ((opt = getopt (argc, argv, "m")) != EOF) { while ((opt = getopt (argc, argv, "m")) > 0) {
switch (opt) { switch (opt) {
case 'm': case 'm':
trans_ptr = uu_base64; trans_ptr = uu_base64;
break; break;
case 0:
break;
default: default:
usage(uuencode_usage); usage(uuencode_usage);
} }
@ -178,7 +175,7 @@ int uuencode_main (int argc,
case 2: case 2:
/* Optional first argument is input file. */ /* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
error_msg("%s: %s\n", argv[optind], strerror(errno)); perror_msg("%s", argv[optind]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);

19
cp_mv.c
View File

@ -130,8 +130,7 @@ 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) {
error_msg("rename(%s, %s): %s\n", fileName, destName, perror_msg("rename(%s, %s)", fileName, destName);
strerror(errno));
goto do_copyFile; /* Try anyway... */ goto do_copyFile; /* Try anyway... */
} }
else if (errno == EXDEV) else if (errno == EXDEV)
@ -143,7 +142,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (preserveFlag == TRUE && statbuf->st_nlink > 1) { if (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) {
error_msg("link(%s, %s): %s\n", name, destName, strerror(errno)); perror_msg("link(%s, %s)", name, destName);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -162,11 +161,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) {
error_msg("rmdir(%s): %s\n", fileName, strerror(errno)); perror_msg("rmdir(%s)", fileName);
status = FALSE; status = FALSE;
} }
} else if (unlink(fileName) < 0) { } else if (unlink(fileName) < 0) {
error_msg("unlink(%s): %s\n", fileName, strerror(errno)); perror_msg("unlink(%s)", fileName);
status = FALSE; status = FALSE;
} }
return status; return status;
@ -260,20 +259,20 @@ 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) {
error_msg("getcwd(): %s\n", strerror(errno)); perror_msg("getcwd()");
continue; continue;
} }
if (chdir(baseDestName) < 0) { if (chdir(baseDestName) < 0) {
error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno)); perror_msg("chdir(%s)", baseSrcName);
continue; continue;
} }
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
error_msg("getcwd(): %s\n", strerror(errno)); perror_msg("getcwd()");
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 */
error_msg("stat(%s): %s\n", d, strerror(errno)); perror_msg("stat(%s)", d);
state = -1; state = -1;
continue; continue;
} }
@ -290,7 +289,7 @@ extern int cp_mv_main(int argc, char **argv)
} }
} }
if (chdir(pushd) < 0) { if (chdir(pushd) < 0) {
error_msg("chdir(%s): %s\n", pushd, strerror(errno)); perror_msg("chdir(%s)", pushd);
free(pushd); free(pushd);
free(d); free(d);
continue; continue;

2
cut.c
View File

@ -234,7 +234,7 @@ extern int cut_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) {
error_msg("%s: %s\n", argv[i], strerror(errno)); perror_msg("%s", argv[i]);
} else { } else {
cut_file(file); cut_file(file);
fclose(file); fclose(file);

View File

@ -50,7 +50,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) {
error_msg("Error opening /dev/tty0: %s\n", strerror(errno)); perror_msg("Error opening /dev/tty0");
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -757,7 +757,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) {
error_msg("%s: %s\n", argv[i], strerror(errno)); perror_msg("%s", argv[i]);
} else { } else {
process_file(file); process_file(file);
fclose(file); fclose(file);

View File

@ -169,7 +169,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)
error_msg("%s: %s\n", cur_file, strerror(errno)); perror_msg("%s", cur_file);
} }
else { else {
grep_file(file); grep_file(file);

View File

@ -43,10 +43,10 @@ freeramdisk_main(int argc, char **argv)
} }
if ((f = open(argv[1], O_RDWR)) == -1) { if ((f = open(argv[1], O_RDWR)) == -1) {
error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno)); perror_msg_and_die("cannot open %s", argv[1]);
} }
if (ioctl(f, BLKFLSBUF) < 0) { if (ioctl(f, BLKFLSBUF) < 0) {
error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); perror_msg_and_die("failed ioctl on %s", argv[1]);
} }
/* Don't bother closing. Exit does /* Don't bother closing. Exit does
* that, so we can save a few bytes */ * that, so we can save a few bytes */

2
grep.c
View File

@ -169,7 +169,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)
error_msg("%s: %s\n", cur_file, strerror(errno)); perror_msg("%s", cur_file);
} }
else { else {
grep_file(file); grep_file(file);

2
head.c
View File

@ -80,7 +80,7 @@ int head_main(int argc, char **argv)
} }
head(len, fp); head(len, fp);
if (errno) { if (errno) {
error_msg("%s: %s\n", argv[optind], strerror(errno)); perror_msg("%s", argv[optind]);
status = EXIT_FAILURE; status = EXIT_FAILURE;
errno = 0; errno = 0;
} }

View File

@ -78,7 +78,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.32 2000/12/13 16:41:29 andersen Exp $" #ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels. /* 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
@ -284,7 +284,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.32 2000/12/13 16:41:29 andersen Exp $" #ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */
@ -1562,7 +1562,7 @@ static int old_get_kernel_symbols(const char *m_name)
nks = get_kernel_syms(NULL); nks = get_kernel_syms(NULL);
if (nks < 0) { if (nks < 0) {
error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); perror_msg("get_kernel_syms: %s", m_name);
return 0; return 0;
} }
@ -1743,7 +1743,7 @@ old_init_module(const char *m_name, struct obj_file *f,
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
: 0), &routines, symtab); : 0), &routines, symtab);
if (ret) if (ret)
error_msg("init_module: %s: %s\n", m_name, strerror(errno)); perror_msg("init_module: %s", m_name);
free(image); free(image);
free(symtab); free(symtab);
@ -2055,7 +2055,7 @@ static int new_get_kernel_symbols(void)
module_names = xrealloc(module_names, bufsize = ret); module_names = xrealloc(module_names, bufsize = ret);
goto retry_modules_load; goto retry_modules_load;
} }
error_msg("QM_MODULES: %s\n", strerror(errno)); perror_msg("QM_MODULES");
return 0; return 0;
} }
@ -2074,7 +2074,7 @@ static int new_get_kernel_symbols(void)
/* The module was removed out from underneath us. */ /* The module was removed out from underneath us. */
continue; continue;
} }
error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); perror_msg("query_module: QM_INFO: %s", mn);
return 0; return 0;
} }
@ -2089,7 +2089,7 @@ static int new_get_kernel_symbols(void)
/* The module was removed out from underneath us. */ /* The module was removed out from underneath us. */
continue; continue;
default: default:
error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); perror_msg("query_module: QM_SYMBOLS: %s", mn);
return 0; return 0;
} }
} }
@ -2114,7 +2114,7 @@ static int new_get_kernel_symbols(void)
syms = xrealloc(syms, bufsize = ret); syms = xrealloc(syms, bufsize = ret);
goto retry_kern_sym_load; goto retry_kern_sym_load;
} }
error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); perror_msg("kernel: QM_SYMBOLS");
return 0; return 0;
} }
nksyms = nsyms = ret; nksyms = nsyms = ret;
@ -2295,7 +2295,7 @@ new_init_module(const char *m_name, struct obj_file *f,
ret = new_sys_init_module(m_name, (struct new_module *) image); ret = new_sys_init_module(m_name, (struct new_module *) image);
if (ret) if (ret)
error_msg("init_module: %s: %s\n", m_name, strerror(errno)); perror_msg("init_module: %s", m_name);
free(image); free(image);
@ -2680,7 +2680,7 @@ struct obj_file *obj_load(FILE * fp)
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
if (fread(&f->header, sizeof(f->header), 1, fp) != 1) { if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
error_msg("error reading ELF header: %s\n", strerror(errno)); perror_msg("error reading ELF header");
return NULL; return NULL;
} }
@ -2719,7 +2719,7 @@ struct obj_file *obj_load(FILE * fp)
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
fseek(fp, f->header.e_shoff, SEEK_SET); fseek(fp, f->header.e_shoff, SEEK_SET);
if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) { if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
error_msg("error reading ELF section headers: %s\n", strerror(errno)); perror_msg("error reading ELF section headers");
return NULL; return NULL;
} }
@ -2749,7 +2749,7 @@ struct obj_file *obj_load(FILE * fp)
sec->contents = xmalloc(sec->header.sh_size); sec->contents = xmalloc(sec->header.sh_size);
fseek(fp, sec->header.sh_offset, SEEK_SET); fseek(fp, sec->header.sh_offset, SEEK_SET);
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
error_msg("error reading ELF section data: %s\n", strerror(errno)); perror_msg("error reading ELF section data");
return NULL; return NULL;
} }
} else { } else {
@ -3075,7 +3075,7 @@ extern int insmod_main( int argc, char **argv)
m_size); m_size);
goto out; goto out;
default: default:
error_msg("create_module: %s: %s\n", m_name, strerror(errno)); perror_msg("create_module: %s", m_name);
goto out; goto out;
} }

6
kill.c
View File

@ -204,10 +204,10 @@ extern int kill_main(int argc, char **argv)
int pid; int pid;
if (!isdigit(**argv)) if (!isdigit(**argv))
error_msg_and_die( "Bad PID: %s\n", strerror(errno)); perror_msg_and_die( "Bad PID");
pid = strtol(*argv, NULL, 0); pid = strtol(*argv, NULL, 0);
if (kill(pid, sig) != 0) if (kill(pid, sig) != 0)
error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno)); perror_msg_and_die( "Could not kill pid '%d'", pid);
argv++; argv++;
} }
} }
@ -229,7 +229,7 @@ extern int kill_main(int argc, char **argv)
if (*pidList==myPid) if (*pidList==myPid)
continue; continue;
if (kill(*pidList, sig) != 0) if (kill(*pidList, sig) != 0)
error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno)); perror_msg_and_die( "Could not kill pid '%d'", *pidList);
} }
/* Note that we don't bother to free the memory /* Note that we don't bother to free the memory
* allocated in find_pid_by_name(). It will be freed * allocated in find_pid_by_name(). It will be freed

View File

@ -39,13 +39,11 @@ 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) {
error_msg("Error opening /dev/tty1: %s\n", strerror(errno)); perror_msg_and_die("Error opening /dev/tty1");
return EXIT_FAILURE;
} }
if (screen_map_load(fd, stdin)) { if (screen_map_load(fd, stdin)) {
error_msg("Error loading acm: %s\n", strerror(errno)); perror_msg_and_die("Error loading acm");
return EXIT_FAILURE;
} }
write(fd, "\033(K", 3); write(fd, "\033(K", 3);

6
ls.c
View File

@ -181,7 +181,7 @@ static int my_stat(struct dnode *cur)
#ifdef BB_FEATURE_LS_FOLLOWLINKS #ifdef BB_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) { if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) { if (stat(cur->fullname, &cur->dstat)) {
error_msg("%s: %s\n", cur->fullname, strerror(errno)); perror_msg("%s", cur->fullname);
status = EXIT_FAILURE; status = EXIT_FAILURE;
free(cur->fullname); free(cur->fullname);
free(cur); free(cur);
@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur)
} else } else
#endif #endif
if (lstat(cur->fullname, &cur->dstat)) { if (lstat(cur->fullname, &cur->dstat)) {
error_msg("%s: %s\n", cur->fullname, strerror(errno)); perror_msg("%s", cur->fullname);
status = EXIT_FAILURE; status = EXIT_FAILURE;
free(cur->fullname); free(cur->fullname);
free(cur); free(cur);
@ -511,7 +511,7 @@ struct dnode **list_dir(char *path)
nfiles= 0; nfiles= 0;
dir = opendir(path); dir = opendir(path);
if (dir == NULL) { if (dir == NULL) {
error_msg("%s: %s\n", path, strerror(errno)); perror_msg("%s", path);
status = EXIT_FAILURE; status = EXIT_FAILURE;
return(NULL); /* could not open the dir */ return(NULL); /* could not open the dir */
} }

View File

@ -651,13 +651,13 @@ static int md5_file(const char *filename,
} else { } else {
fp = fopen(filename, OPENOPTS(binary)); fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) { if (fp == NULL) {
error_msg("%s: %s\n", filename, strerror(errno)); perror_msg("%s", filename);
return FALSE; return FALSE;
} }
} }
if (md5_stream(fp, md5_result)) { if (md5_stream(fp, md5_result)) {
error_msg("%s: %s\n", filename, strerror(errno)); perror_msg("%s", filename);
if (fp != stdin) if (fp != stdin)
fclose(fp); fclose(fp);
@ -665,7 +665,7 @@ static int md5_file(const char *filename,
} }
if (fp != stdin && fclose(fp) == EOF) { if (fp != stdin && fclose(fp) == EOF) {
error_msg("%s: %s\n", filename, strerror(errno)); perror_msg("%s", filename);
return FALSE; return FALSE;
} }
@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name)
} else { } else {
checkfile_stream = fopen(checkfile_name, "r"); checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) { if (checkfile_stream == NULL) {
error_msg("%s: %s\n", checkfile_name, strerror(errno)); perror_msg("%s", checkfile_name);
return FALSE; return FALSE;
} }
} }
@ -775,7 +775,7 @@ static int md5_check(const char *checkfile_name)
} }
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) { if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); perror_msg("md5sum: %s", checkfile_name);
return FALSE; return FALSE;
} }

View File

@ -39,7 +39,7 @@ int readlink_main(int argc, char **argv)
buf = xrealloc(buf, bufsize); buf = xrealloc(buf, bufsize);
size = readlink(argv[1], buf, bufsize); size = readlink(argv[1], buf, bufsize);
if (size == -1) if (size == -1)
error_msg_and_die("%s: %s\n", argv[1], strerror(errno)); perror_msg_and_die("%s", argv[1]);
} }
buf[size] = '\0'; buf[size] = '\0';

View File

@ -78,7 +78,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.32 2000/12/13 16:41:29 andersen Exp $" #ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels. /* 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
@ -284,7 +284,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.32 2000/12/13 16:41:29 andersen Exp $" #ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */
@ -1562,7 +1562,7 @@ static int old_get_kernel_symbols(const char *m_name)
nks = get_kernel_syms(NULL); nks = get_kernel_syms(NULL);
if (nks < 0) { if (nks < 0) {
error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); perror_msg("get_kernel_syms: %s", m_name);
return 0; return 0;
} }
@ -1743,7 +1743,7 @@ old_init_module(const char *m_name, struct obj_file *f,
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
: 0), &routines, symtab); : 0), &routines, symtab);
if (ret) if (ret)
error_msg("init_module: %s: %s\n", m_name, strerror(errno)); perror_msg("init_module: %s", m_name);
free(image); free(image);
free(symtab); free(symtab);
@ -2055,7 +2055,7 @@ static int new_get_kernel_symbols(void)
module_names = xrealloc(module_names, bufsize = ret); module_names = xrealloc(module_names, bufsize = ret);
goto retry_modules_load; goto retry_modules_load;
} }
error_msg("QM_MODULES: %s\n", strerror(errno)); perror_msg("QM_MODULES");
return 0; return 0;
} }
@ -2074,7 +2074,7 @@ static int new_get_kernel_symbols(void)
/* The module was removed out from underneath us. */ /* The module was removed out from underneath us. */
continue; continue;
} }
error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); perror_msg("query_module: QM_INFO: %s", mn);
return 0; return 0;
} }
@ -2089,7 +2089,7 @@ static int new_get_kernel_symbols(void)
/* The module was removed out from underneath us. */ /* The module was removed out from underneath us. */
continue; continue;
default: default:
error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); perror_msg("query_module: QM_SYMBOLS: %s", mn);
return 0; return 0;
} }
} }
@ -2114,7 +2114,7 @@ static int new_get_kernel_symbols(void)
syms = xrealloc(syms, bufsize = ret); syms = xrealloc(syms, bufsize = ret);
goto retry_kern_sym_load; goto retry_kern_sym_load;
} }
error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); perror_msg("kernel: QM_SYMBOLS");
return 0; return 0;
} }
nksyms = nsyms = ret; nksyms = nsyms = ret;
@ -2295,7 +2295,7 @@ new_init_module(const char *m_name, struct obj_file *f,
ret = new_sys_init_module(m_name, (struct new_module *) image); ret = new_sys_init_module(m_name, (struct new_module *) image);
if (ret) if (ret)
error_msg("init_module: %s: %s\n", m_name, strerror(errno)); perror_msg("init_module: %s", m_name);
free(image); free(image);
@ -2680,7 +2680,7 @@ struct obj_file *obj_load(FILE * fp)
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
if (fread(&f->header, sizeof(f->header), 1, fp) != 1) { if (fread(&f->header, sizeof(f->header), 1, fp) != 1) {
error_msg("error reading ELF header: %s\n", strerror(errno)); perror_msg("error reading ELF header");
return NULL; return NULL;
} }
@ -2719,7 +2719,7 @@ struct obj_file *obj_load(FILE * fp)
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
fseek(fp, f->header.e_shoff, SEEK_SET); fseek(fp, f->header.e_shoff, SEEK_SET);
if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) { if (fread(section_headers, sizeof(ElfW(Shdr)), shnum, fp) != shnum) {
error_msg("error reading ELF section headers: %s\n", strerror(errno)); perror_msg("error reading ELF section headers");
return NULL; return NULL;
} }
@ -2749,7 +2749,7 @@ struct obj_file *obj_load(FILE * fp)
sec->contents = xmalloc(sec->header.sh_size); sec->contents = xmalloc(sec->header.sh_size);
fseek(fp, sec->header.sh_offset, SEEK_SET); fseek(fp, sec->header.sh_offset, SEEK_SET);
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
error_msg("error reading ELF section data: %s\n", strerror(errno)); perror_msg("error reading ELF section data");
return NULL; return NULL;
} }
} else { } else {
@ -3075,7 +3075,7 @@ extern int insmod_main( int argc, char **argv)
m_size); m_size);
goto out; goto out;
default: default:
error_msg("create_module: %s: %s\n", m_name, strerror(errno)); perror_msg("create_module: %s", m_name);
goto out; goto out;
} }

19
mount.c
View File

@ -271,18 +271,18 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
/* open device */ /* open device */
fd = open(device, O_RDONLY); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die("open failed for `%s'", device);
/* How many filesystems? We need to know to allocate enough space */ /* How many filesystems? We need to know to allocate enough space */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS); numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS);
if (numfilesystems<0) if (numfilesystems<0)
error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno)); perror_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS");
fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype)); fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype));
/* Grab the list of available filesystems */ /* Grab the list of available filesystems */
status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist); status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist);
if (status<0) if (status<0)
error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno)); perror_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS");
/* Walk the list trying to mount filesystems /* Walk the list trying to mount filesystems
* that do not claim to be nodev filesystems */ * that do not claim to be nodev filesystems */
@ -307,8 +307,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
if (status == FALSE) { if (status == FALSE) {
if (whineOnErrors == TRUE) { if (whineOnErrors == TRUE) {
error_msg("Mounting %s on %s failed: %s\n", perror_msg("Mounting %s on %s failed", blockDevice, directory);
blockDevice, directory, strerror(errno));
} }
return (FALSE); return (FALSE);
} }
@ -340,18 +339,18 @@ extern int mount_main(int argc, char **argv)
/* open device */ /* open device */
fd = open(device, O_RDONLY); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die("open failed for `%s'", device);
/* How many mounted filesystems? We need to know to /* How many mounted filesystems? We need to know to
* allocate enough space for later... */ * allocate enough space for later... */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS); numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
if (numfilesystems<0) if (numfilesystems<0)
error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS");
mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent)); mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent));
/* Grab the list of mounted filesystems */ /* Grab the list of mounted filesystems */
if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0) if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0)
error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVMTAB_GET_MOUNTS");
for( i = 0 ; i < numfilesystems ; i++) { for( i = 0 ; i < numfilesystems ; i++) {
fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname, fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
@ -453,7 +452,7 @@ extern int mount_main(int argc, char **argv)
fstabmount = TRUE; fstabmount = TRUE;
if (f == NULL) if (f == NULL)
error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno)); perror_msg_and_die( "\nCannot read /etc/fstab");
while ((m = getmntent(f)) != NULL) { while ((m = getmntent(f)) != NULL) {
if (all == FALSE && directory == NULL && ( if (all == FALSE && directory == NULL && (
@ -487,7 +486,7 @@ singlemount:
rc = nfsmount (device, directory, &flags, rc = nfsmount (device, directory, &flags,
&extra_opts, &string_flags, 1); &extra_opts, &string_flags, 1);
if ( rc != 0) { if ( rc != 0) {
error_msg_and_die("nfsmount failed: %s\n", strerror(errno)); perror_msg_and_die("nfsmount failed");
rc = EXIT_FAILURE; rc = EXIT_FAILURE;
} }
} }

View File

@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */ /* vi: set sw=4 ts=4: */
/* /*
* $Id: ping.c,v 1.28 2000/12/07 19:56:48 markw Exp $ * $Id: ping.c,v 1.29 2000/12/18 03:57:16 kraai Exp $
* Mini ping implementation for busybox * Mini ping implementation for busybox
* *
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org> * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@ -325,7 +325,7 @@ static void sendping(int junk)
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
if (i < 0) if (i < 0)
error_msg_and_die("sendto: %s\n", strerror(errno)); perror_msg_and_die("sendto");
else if ((size_t)i != sizeof(packet)) else if ((size_t)i != sizeof(packet))
error_msg_and_die("ping wrote %d chars; %d expected\n", i, error_msg_and_die("ping wrote %d chars; %d expected\n", i,
(int)sizeof(packet)); (int)sizeof(packet));

View File

@ -650,7 +650,7 @@ static int remote_connect(struct in_addr addr, int port)
if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0) if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0)
{ {
error_msg_and_die("Unable to connect to remote host: %s\n", strerror(errno)); perror_msg_and_die("Unable to connect to remote host");
} }
return s; return s;
} }

4
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.28 2000/12/07 19:56:48 markw Exp $ * $Id: ping.c,v 1.29 2000/12/18 03:57:16 kraai Exp $
* Mini ping implementation for busybox * Mini ping implementation for busybox
* *
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org> * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@ -325,7 +325,7 @@ static void sendping(int junk)
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in)); (struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
if (i < 0) if (i < 0)
error_msg_and_die("sendto: %s\n", strerror(errno)); perror_msg_and_die("sendto");
else if ((size_t)i != sizeof(packet)) else if ((size_t)i != sizeof(packet))
error_msg_and_die("ping wrote %d chars; %d expected\n", i, error_msg_and_die("ping wrote %d chars; %d expected\n", i,
(int)sizeof(packet)); (int)sizeof(packet));

View File

@ -204,10 +204,10 @@ extern int kill_main(int argc, char **argv)
int pid; int pid;
if (!isdigit(**argv)) if (!isdigit(**argv))
error_msg_and_die( "Bad PID: %s\n", strerror(errno)); perror_msg_and_die( "Bad PID");
pid = strtol(*argv, NULL, 0); pid = strtol(*argv, NULL, 0);
if (kill(pid, sig) != 0) if (kill(pid, sig) != 0)
error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno)); perror_msg_and_die( "Could not kill pid '%d'", pid);
argv++; argv++;
} }
} }
@ -229,7 +229,7 @@ extern int kill_main(int argc, char **argv)
if (*pidList==myPid) if (*pidList==myPid)
continue; continue;
if (kill(*pidList, sig) != 0) if (kill(*pidList, sig) != 0)
error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno)); perror_msg_and_die( "Could not kill pid '%d'", *pidList);
} }
/* Note that we don't bother to free the memory /* Note that we don't bother to free the memory
* allocated in find_pid_by_name(). It will be freed * allocated in find_pid_by_name(). It will be freed

View File

@ -216,11 +216,11 @@ extern int ps_main(int argc, char **argv)
/* open device */ /* open device */
fd = open(device, O_RDONLY); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die( "open failed for `%s'", device);
/* Find out how many processes there are */ /* Find out how many processes there are */
if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVPS_GET_PID_LIST");
/* Allocate some memory -- grab a few extras just in case /* Allocate some memory -- grab a few extras just in case
* some new processes start up while we wait. The kernel will * some new processes start up while we wait. The kernel will
@ -231,7 +231,7 @@ extern int ps_main(int argc, char **argv)
/* Now grab the pid list */ /* Now grab the pid list */
if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
error_msg_and_die("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); perror_msg_and_die("\nDEVPS_GET_PID_LIST");
#ifdef BB_FEATURE_AUTOWIDTH #ifdef BB_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win); ioctl(fileno(stdout), TIOCGWINSZ, &win);
@ -247,7 +247,7 @@ extern int ps_main(int argc, char **argv)
info.pid = pid_array[i]; info.pid = pid_array[i];
if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
error_msg_and_die("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno)); perror_msg_and_die("\nDEVPS_GET_PID_INFO");
/* Make some adjustments as needed */ /* Make some adjustments as needed */
my_getpwuid(uidName, info.euid); my_getpwuid(uidName, info.euid);
@ -277,7 +277,7 @@ extern int ps_main(int argc, char **argv)
/* close device */ /* close device */
if (close (fd) != 0) if (close (fd) != 0)
error_msg_and_die("close failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die("close failed for `%s'", device);
exit (0); exit (0);
} }

10
ps.c
View File

@ -216,11 +216,11 @@ extern int ps_main(int argc, char **argv)
/* open device */ /* open device */
fd = open(device, O_RDONLY); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die( "open failed for `%s'", device);
/* Find out how many processes there are */ /* Find out how many processes there are */
if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVPS_GET_PID_LIST");
/* Allocate some memory -- grab a few extras just in case /* Allocate some memory -- grab a few extras just in case
* some new processes start up while we wait. The kernel will * some new processes start up while we wait. The kernel will
@ -231,7 +231,7 @@ extern int ps_main(int argc, char **argv)
/* Now grab the pid list */ /* Now grab the pid list */
if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
error_msg_and_die("\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); perror_msg_and_die("\nDEVPS_GET_PID_LIST");
#ifdef BB_FEATURE_AUTOWIDTH #ifdef BB_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win); ioctl(fileno(stdout), TIOCGWINSZ, &win);
@ -247,7 +247,7 @@ extern int ps_main(int argc, char **argv)
info.pid = pid_array[i]; info.pid = pid_array[i];
if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
error_msg_and_die("\nDEVPS_GET_PID_INFO: %s\n", strerror (errno)); perror_msg_and_die("\nDEVPS_GET_PID_INFO");
/* Make some adjustments as needed */ /* Make some adjustments as needed */
my_getpwuid(uidName, info.euid); my_getpwuid(uidName, info.euid);
@ -277,7 +277,7 @@ extern int ps_main(int argc, char **argv)
/* close device */ /* close device */
if (close (fd) != 0) if (close (fd) != 0)
error_msg_and_die("close failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die("close failed for `%s'", device);
exit (0); exit (0);
} }

4
pwd.c
View File

@ -31,8 +31,8 @@ extern int pwd_main(int argc, char **argv)
char buf[BUFSIZ + 1]; char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL) if (getcwd(buf, sizeof(buf)) == NULL)
error_msg_and_die("%s\n", strerror(errno)); perror_msg_and_die("getcwd");
printf("%s\n", buf); puts(buf);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

10
rdate.c
View File

@ -47,15 +47,15 @@ time_t askremotedate(char *host)
int fd; int fd;
if (!(h = gethostbyname(host))) { /* get the IP addr */ if (!(h = gethostbyname(host))) { /* get the IP addr */
error_msg("%s: %s\n", host, strerror(errno)); perror_msg("%s", host);
return(-1); return(-1);
} }
if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */ if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */
error_msg("%s: %s\n", "time", strerror(errno)); perror_msg("%s", "time");
return(-1); return(-1);
} }
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */
error_msg("%s: %s\n", "socket", strerror(errno)); perror_msg("%s", "socket");
return(-1); return(-1);
} }
@ -64,7 +64,7 @@ time_t askremotedate(char *host)
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */ if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */
error_msg("%s: %s\n", host, strerror(errno)); perror_msg("%s", host);
close(fd); close(fd);
return(-1); return(-1);
} }
@ -123,7 +123,7 @@ int rdate_main(int argc, char **argv)
} }
if (setdate) { if (setdate) {
if (stime(&time) < 0) if (stime(&time) < 0)
error_msg_and_die("Could not set time of day: %s\n", strerror(errno)); perror_msg_and_die("Could not set time of day");
} }
if (printdate) { if (printdate) {
fprintf(stdout, "%s", ctime(&time)); fprintf(stdout, "%s", ctime(&time));

View File

@ -39,7 +39,7 @@ int readlink_main(int argc, char **argv)
buf = xrealloc(buf, bufsize); buf = xrealloc(buf, bufsize);
size = readlink(argv[1], buf, bufsize); size = readlink(argv[1], buf, bufsize);
if (size == -1) if (size == -1)
error_msg_and_die("%s: %s\n", argv[1], strerror(errno)); perror_msg_and_die("%s", argv[1]);
} }
buf[size] = '\0'; buf[size] = '\0';

2
sed.c
View File

@ -757,7 +757,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) {
error_msg("%s: %s\n", argv[i], strerror(errno)); perror_msg("%s", argv[i]);
} else { } else {
process_file(file); process_file(file);
fclose(file); fclose(file);

View File

@ -313,7 +313,7 @@ static void doSyslogd (void)
/* Create the syslog file so realpath() can work. */ /* Create the syslog file so realpath() can work. */
close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
if (realpath (_PATH_LOG, lfile) == NULL) if (realpath (_PATH_LOG, lfile) == NULL)
error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno)); perror_msg_and_die ("Could not resolve path to " _PATH_LOG);
unlink (lfile); unlink (lfile);
@ -321,14 +321,14 @@ static void doSyslogd (void)
sunx.sun_family = AF_UNIX; sunx.sun_family = AF_UNIX;
strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno)); perror_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG);
addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno)); perror_msg_and_die ("Could not connect to socket " _PATH_LOG);
if (chmod (lfile, 0666) < 0) if (chmod (lfile, 0666) < 0)
error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno)); perror_msg_and_die ("Could not set permission on " _PATH_LOG);
FD_ZERO (&fds); FD_ZERO (&fds);
FD_SET (sock_fd, &fds); FD_SET (sock_fd, &fds);
@ -351,7 +351,7 @@ static void doSyslogd (void)
if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) {
if (errno == EINTR) continue; /* alarm may have happened. */ if (errno == EINTR) continue; /* alarm may have happened. */
error_msg_and_die ("select error: %s\n", strerror (errno)); perror_msg_and_die ("select error");
} }
for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
@ -365,7 +365,7 @@ static void doSyslogd (void)
pid_t pid; pid_t pid;
if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
error_msg_and_die ("accept error: %s\n", strerror (errno)); perror_msg_and_die ("accept error");
} }
pid = fork(); pid = fork();

View File

@ -313,7 +313,7 @@ static void doSyslogd (void)
/* Create the syslog file so realpath() can work. */ /* Create the syslog file so realpath() can work. */
close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
if (realpath (_PATH_LOG, lfile) == NULL) if (realpath (_PATH_LOG, lfile) == NULL)
error_msg_and_die ("Could not resolve path to " _PATH_LOG ": %s\n", strerror (errno)); perror_msg_and_die ("Could not resolve path to " _PATH_LOG);
unlink (lfile); unlink (lfile);
@ -321,14 +321,14 @@ static void doSyslogd (void)
sunx.sun_family = AF_UNIX; sunx.sun_family = AF_UNIX;
strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
error_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s\n", strerror (errno)); perror_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG);
addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
error_msg_and_die ("Could not connect to socket " _PATH_LOG ": %s\n", strerror (errno)); perror_msg_and_die ("Could not connect to socket " _PATH_LOG);
if (chmod (lfile, 0666) < 0) if (chmod (lfile, 0666) < 0)
error_msg_and_die ("Could not set permission on " _PATH_LOG ": %s\n", strerror (errno)); perror_msg_and_die ("Could not set permission on " _PATH_LOG);
FD_ZERO (&fds); FD_ZERO (&fds);
FD_SET (sock_fd, &fds); FD_SET (sock_fd, &fds);
@ -351,7 +351,7 @@ static void doSyslogd (void)
if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) {
if (errno == EINTR) continue; /* alarm may have happened. */ if (errno == EINTR) continue; /* alarm may have happened. */
error_msg_and_die ("select error: %s\n", strerror (errno)); perror_msg_and_die ("select error");
} }
for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
@ -365,7 +365,7 @@ static void doSyslogd (void)
pid_t pid; pid_t pid;
if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
error_msg_and_die ("accept error: %s\n", strerror (errno)); perror_msg_and_die ("accept error");
} }
pid = fork(); pid = fork();

25
tar.c
View File

@ -317,7 +317,7 @@ extern int tar_main(int argc, char **argv)
else else
tarFd = open(tarName, O_RDONLY); tarFd = open(tarName, O_RDONLY);
if (tarFd < 0) if (tarFd < 0)
error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno)); perror_msg_and_die("Error opening '%s'", tarName);
#ifdef BB_FEATURE_TAR_GZIP #ifdef BB_FEATURE_TAR_GZIP
/* unzip tarFd in a seperate process */ /* unzip tarFd in a seperate process */
@ -425,8 +425,7 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE); return( TRUE);
if (create_path(header->name, header->mode) != TRUE) { if (create_path(header->name, header->mode) != TRUE) {
error_msg("%s: Cannot mkdir: %s\n", perror_msg("%s: Cannot mkdir", header->name);
header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
/* make the final component, just in case it was /* make the final component, just in case it was
@ -445,8 +444,8 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE); return( TRUE);
if (link(header->linkname, header->name) < 0) { if (link(header->linkname, header->name) < 0) {
error_msg("%s: Cannot create hard link to '%s': %s\n", perror_msg("%s: Cannot create hard link to '%s'", header->name,
header->name, header->linkname, strerror(errno)); header->linkname);
return( FALSE); return( FALSE);
} }
@ -463,8 +462,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
#ifdef S_ISLNK #ifdef S_ISLNK
if (symlink(header->linkname, header->name) < 0) { if (symlink(header->linkname, header->name) < 0) {
error_msg("%s: Cannot create symlink to '%s': %s\n", perror_msg("%s: Cannot create symlink to '%s'", header->name,
header->name, header->linkname, strerror(errno)); header->linkname);
return( FALSE); return( FALSE);
} }
/* Try to change ownership of the symlink. /* Try to change ownership of the symlink.
@ -493,14 +492,12 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) { if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) { if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
error_msg("%s: Cannot mknod: %s\n", perror_msg("%s: Cannot mknod", header->name);
header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
} else if (S_ISFIFO(header->mode)) { } else if (S_ISFIFO(header->mode)) {
if (mkfifo(header->name, header->mode) < 0) { if (mkfifo(header->name, header->mode) < 0) {
error_msg("%s: Cannot mkfifo: %s\n", perror_msg("%s: Cannot mkfifo", header->name);
header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
} }
@ -790,7 +787,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
close(tarFd); close(tarFd);
if (status > 0) { if (status > 0) {
/* Bummer - we read a partial header */ /* Bummer - we read a partial header */
error_msg( "Error reading tar file: %s\n", strerror(errno)); perror_msg("Error reading tar file");
return ( FALSE); return ( FALSE);
} }
else if (errorFlag==TRUE) { else if (errorFlag==TRUE) {
@ -1007,7 +1004,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
header.typeflag = SYMTYPE; header.typeflag = SYMTYPE;
link_size = readlink(fileName, buffer, sizeof(buffer) - 1); link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
if ( link_size < 0) { if ( link_size < 0) {
error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); perror_msg("Error reading symlink '%s'", header.name);
return ( FALSE); return ( FALSE);
} }
buffer[link_size] = '\0'; buffer[link_size] = '\0';
@ -1165,7 +1162,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
else else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644); tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (tbInfo.tarFd < 0) { if (tbInfo.tarFd < 0) {
error_msg( "Error opening '%s': %s\n", tarName, strerror(errno)); perror_msg( "Error opening '%s'", tarName);
freeHardLinkInfo(&tbInfo.hlInfoHead); freeHardLinkInfo(&tbInfo.hlInfoHead);
return ( FALSE); return ( FALSE);
} }

2
tee.c
View File

@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
while (optind < argc) { while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) { if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
nfiles--; nfiles--;
error_msg("%s: %s\n", argv[optind-1], strerror(errno)); perror_msg("%s", argv[optind-1]);
status = 1; status = 1;
} }
} }

View File

@ -650,7 +650,7 @@ static int remote_connect(struct in_addr addr, int port)
if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0) if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0)
{ {
error_msg_and_die("Unable to connect to remote host: %s\n", strerror(errno)); perror_msg_and_die("Unable to connect to remote host");
} }
return s; return s;
} }

View File

@ -43,10 +43,10 @@ freeramdisk_main(int argc, char **argv)
} }
if ((f = open(argv[1], O_RDWR)) == -1) { if ((f = open(argv[1], O_RDWR)) == -1) {
error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno)); perror_msg_and_die("cannot open %s", argv[1]);
} }
if (ioctl(f, BLKFLSBUF) < 0) { if (ioctl(f, BLKFLSBUF) < 0) {
error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); perror_msg_and_die("failed ioctl on %s", argv[1]);
} }
/* Don't bother closing. Exit does /* Don't bother closing. Exit does
* that, so we can save a few bytes */ * that, so we can save a few bytes */

View File

@ -271,18 +271,18 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
/* open device */ /* open device */
fd = open(device, O_RDONLY); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die("open failed for `%s'", device);
/* How many filesystems? We need to know to allocate enough space */ /* How many filesystems? We need to know to allocate enough space */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS); numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS);
if (numfilesystems<0) if (numfilesystems<0)
error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno)); perror_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS");
fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype)); fslist = (struct k_fstype *) xcalloc ( numfilesystems, sizeof(struct k_fstype));
/* Grab the list of available filesystems */ /* Grab the list of available filesystems */
status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist); status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist);
if (status<0) if (status<0)
error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno)); perror_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS");
/* Walk the list trying to mount filesystems /* Walk the list trying to mount filesystems
* that do not claim to be nodev filesystems */ * that do not claim to be nodev filesystems */
@ -307,8 +307,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
if (status == FALSE) { if (status == FALSE) {
if (whineOnErrors == TRUE) { if (whineOnErrors == TRUE) {
error_msg("Mounting %s on %s failed: %s\n", perror_msg("Mounting %s on %s failed", blockDevice, directory);
blockDevice, directory, strerror(errno));
} }
return (FALSE); return (FALSE);
} }
@ -340,18 +339,18 @@ extern int mount_main(int argc, char **argv)
/* open device */ /* open device */
fd = open(device, O_RDONLY); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die("open failed for `%s'", device);
/* How many mounted filesystems? We need to know to /* How many mounted filesystems? We need to know to
* allocate enough space for later... */ * allocate enough space for later... */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS); numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
if (numfilesystems<0) if (numfilesystems<0)
error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS");
mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent)); mntentlist = (struct k_mntent *) xcalloc ( numfilesystems, sizeof(struct k_mntent));
/* Grab the list of mounted filesystems */ /* Grab the list of mounted filesystems */
if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0) if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0)
error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVMTAB_GET_MOUNTS");
for( i = 0 ; i < numfilesystems ; i++) { for( i = 0 ; i < numfilesystems ; i++) {
fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname, fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
@ -453,7 +452,7 @@ extern int mount_main(int argc, char **argv)
fstabmount = TRUE; fstabmount = TRUE;
if (f == NULL) if (f == NULL)
error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno)); perror_msg_and_die( "\nCannot read /etc/fstab");
while ((m = getmntent(f)) != NULL) { while ((m = getmntent(f)) != NULL) {
if (all == FALSE && directory == NULL && ( if (all == FALSE && directory == NULL && (
@ -487,7 +486,7 @@ singlemount:
rc = nfsmount (device, directory, &flags, rc = nfsmount (device, directory, &flags,
&extra_opts, &string_flags, 1); &extra_opts, &string_flags, 1);
if ( rc != 0) { if ( rc != 0) {
error_msg_and_die("nfsmount failed: %s\n", strerror(errno)); perror_msg_and_die("nfsmount failed");
rc = EXIT_FAILURE; rc = EXIT_FAILURE;
} }
} }

View File

@ -47,15 +47,15 @@ time_t askremotedate(char *host)
int fd; int fd;
if (!(h = gethostbyname(host))) { /* get the IP addr */ if (!(h = gethostbyname(host))) { /* get the IP addr */
error_msg("%s: %s\n", host, strerror(errno)); perror_msg("%s", host);
return(-1); return(-1);
} }
if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */ if ((tserv = getservbyname("time", "tcp")) == NULL) { /* find port # */
error_msg("%s: %s\n", "time", strerror(errno)); perror_msg("%s", "time");
return(-1); return(-1);
} }
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { /* get net connection */
error_msg("%s: %s\n", "socket", strerror(errno)); perror_msg("%s", "socket");
return(-1); return(-1);
} }
@ -64,7 +64,7 @@ time_t askremotedate(char *host)
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */ if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { /* connect to time server */
error_msg("%s: %s\n", host, strerror(errno)); perror_msg("%s", host);
close(fd); close(fd);
return(-1); return(-1);
} }
@ -123,7 +123,7 @@ int rdate_main(int argc, char **argv)
} }
if (setdate) { if (setdate) {
if (stime(&time) < 0) if (stime(&time) < 0)
error_msg_and_die("Could not set time of day: %s\n", strerror(errno)); perror_msg_and_die("Could not set time of day");
} }
if (printdate) { if (printdate) {
fprintf(stdout, "%s", ctime(&time)); fprintf(stdout, "%s", ctime(&time));

View File

@ -1313,11 +1313,11 @@ extern pid_t* find_pid_by_name( char* pidName)
/* open device */ /* open device */
fd = open(device, O_RDONLY); fd = open(device, O_RDONLY);
if (fd < 0) if (fd < 0)
error_msg_and_die( "open failed for `%s': %s\n", device, strerror (errno)); perror_msg_and_die( "open failed for `%s'", device);
/* Find out how many processes there are */ /* Find out how many processes there are */
if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0) if (ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids)<0)
error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVPS_GET_PID_LIST");
/* Allocate some memory -- grab a few extras just in case /* Allocate some memory -- grab a few extras just in case
* some new processes start up while we wait. The kernel will * some new processes start up while we wait. The kernel will
@ -1328,7 +1328,7 @@ extern pid_t* find_pid_by_name( char* pidName)
/* Now grab the pid list */ /* Now grab the pid list */
if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0) if (ioctl (fd, DEVPS_GET_PID_LIST, pid_array)<0)
error_msg_and_die( "\nDEVPS_GET_PID_LIST: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVPS_GET_PID_LIST");
/* Now search for a match */ /* Now search for a match */
for (i=1, j=0; i<pid_array[0] ; i++) { for (i=1, j=0; i<pid_array[0] ; i++) {
@ -1337,7 +1337,7 @@ extern pid_t* find_pid_by_name( char* pidName)
info.pid = pid_array[i]; info.pid = pid_array[i];
if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0) if (ioctl (fd, DEVPS_GET_PID_INFO, &info)<0)
error_msg_and_die( "\nDEVPS_GET_PID_INFO: %s\n", strerror (errno)); perror_msg_and_die( "\nDEVPS_GET_PID_INFO");
/* Make sure we only match on the process name */ /* Make sure we only match on the process name */
p=info.command_line+1; p=info.command_line+1;
@ -1361,7 +1361,7 @@ extern pid_t* find_pid_by_name( char* pidName)
/* close device */ /* close device */
if (close (fd) != 0) if (close (fd) != 0)
error_msg_and_die( "close failed for `%s': %s\n",device, strerror (errno)); perror_msg_and_die( "close failed for `%s'", device);
return pidList; return pidList;
} }
@ -1387,7 +1387,7 @@ extern pid_t* find_pid_by_name( char* pidName)
dir = opendir("/proc"); dir = opendir("/proc");
if (!dir) if (!dir)
error_msg_and_die( "Cannot open /proc: %s\n", strerror (errno)); perror_msg_and_die( "Cannot open /proc");
while ((next = readdir(dir)) != NULL) { while ((next = readdir(dir)) != NULL) {
FILE *status; FILE *status;
@ -1764,7 +1764,7 @@ FILE *wfopen(const char *path, const char *mode)
{ {
FILE *fp; FILE *fp;
if ((fp = fopen(path, mode)) == NULL) { if ((fp = fopen(path, mode)) == NULL) {
error_msg("%s: %s\n", path, strerror(errno)); perror_msg("%s", path);
errno = 0; errno = 0;
} }
return fp; return fp;
@ -1778,7 +1778,7 @@ FILE *xfopen(const char *path, const char *mode)
{ {
FILE *fp; FILE *fp;
if ((fp = fopen(path, mode)) == NULL) if ((fp = fopen(path, mode)) == NULL)
error_msg_and_die("%s: %s\n", path, strerror(errno)); perror_msg_and_die("%s", path);
return fp; return fp;
} }
#endif #endif

View File

@ -257,7 +257,7 @@ static int decode (const char *inname,
&& (freopen (outname, "w", stdout) == NULL && (freopen (outname, "w", stdout) == NULL
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) { )) {
error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */ perror_msg("%s", outname); /* */
return FALSE; return FALSE;
} }
@ -302,7 +302,7 @@ int uudecode_main (int argc,
if (decode (argv[optind], outname) != 0) if (decode (argv[optind], outname) != 0)
exit_status = FALSE; exit_status = FALSE;
} else { } else {
error_msg("%s: %s\n", argv[optind], strerror(errno)); perror_msg("%s", argv[optind]);
exit_status = EXIT_FAILURE; exit_status = EXIT_FAILURE;
} }
optind++; optind++;

View File

@ -160,15 +160,12 @@ int uuencode_main (int argc,
trans_ptr = uu_std; /* Standard encoding is old uu format */ trans_ptr = uu_std; /* Standard encoding is old uu format */
/* Parse any options */ /* Parse any options */
while ((opt = getopt (argc, argv, "m")) != EOF) { while ((opt = getopt (argc, argv, "m")) > 0) {
switch (opt) { switch (opt) {
case 'm': case 'm':
trans_ptr = uu_base64; trans_ptr = uu_base64;
break; break;
case 0:
break;
default: default:
usage(uuencode_usage); usage(uuencode_usage);
} }
@ -178,7 +175,7 @@ int uuencode_main (int argc,
case 2: case 2:
/* Optional first argument is input file. */ /* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) { if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
error_msg("%s: %s\n", argv[optind], strerror(errno)); perror_msg("%s", argv[optind]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);