Changed names of functions in utility.c and all affected files, to make

compliant with the style guide. Everybody rebuild your tags file!
This commit is contained in:
Mark Whitley 2000-12-07 19:56:48 +00:00
parent 7b5c16ebe5
commit f57c944e09
155 changed files with 1019 additions and 1019 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 {
errorMsg("%s: %s\n", proc, strerror(errno)); error_msg("%s: %s\n", proc, strerror(errno));
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) {
errorMsg("%s: %s\n", command, strerror(errno)); error_msg("%s: %s\n", command, strerror(errno));
} }
} }
} }

24
ar.c
View File

@ -106,7 +106,7 @@ static int checkTarMagic(int srcFd)
headerStart = lseek(srcFd, 0, SEEK_CUR); headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR); lseek(srcFd, (off_t) 257, SEEK_CUR);
fullRead(srcFd, magic, 6); full_read(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET); lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0) if (strncmp(magic, "ustar", 5)!=0)
return(FALSE); return(FALSE);
@ -123,7 +123,7 @@ static int readTarHeader(int srcFd, headerL_t *current)
off_t initialOffset; off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR); initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) { if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
lseek(srcFd, initialOffset, SEEK_SET); lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE); return(FALSE);
} }
@ -157,8 +157,8 @@ static int checkArMagic(int srcFd)
char arMagic[8]; char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR); headerStart = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, arMagic, 8) != 8) { if (full_read(srcFd, arMagic, 8) != 8) {
errorMsg("fatal error\n"); error_msg("fatal error\n");
return (FALSE); return (FALSE);
} }
lseek(srcFd, headerStart, SEEK_SET); lseek(srcFd, headerStart, SEEK_SET);
@ -178,7 +178,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
off_t initialOffset; off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR); initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) { if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
lseek(srcFd, initialOffset, SEEK_SET); lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE); return(FALSE);
} }
@ -215,7 +215,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
if (entry->size > MAX_NAME_LENGTH) if (entry->size > MAX_NAME_LENGTH)
entry->size = MAX_NAME_LENGTH; entry->size = MAX_NAME_LENGTH;
fullRead(srcFd, tempName, entry->size); full_read(srcFd, tempName, entry->size);
tempName[entry->size-3]='\0'; tempName[entry->size-3]='\0';
/* read the second header for this entry */ /* read the second header for this entry */
@ -226,7 +226,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
if ((entry->name[0]='/') && (entry->name[1]='0')) if ((entry->name[0]='/') && (entry->name[1]='0'))
strcpy(entry->name, tempName); strcpy(entry->name, tempName);
else { else {
errorMsg("Invalid long filename\n"); error_msg("Invalid long filename\n");
return(FALSE); return(FALSE);
} }
} }
@ -343,7 +343,7 @@ extern int ar_main(int argc, char **argv)
usage(ar_usage); usage(ar_usage);
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0) if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
fatalError("Cannot read %s\n", argv[optind]); error_msg_and_die("Cannot read %s\n", argv[optind]);
optind++; optind++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t)); entry = (headerL_t *) xmalloc(sizeof(headerL_t));
@ -368,8 +368,8 @@ extern int ar_main(int argc, char **argv)
while(extractList->next != NULL) { while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) { if (funct & EXT_TO_FILE) {
if (isDirectory(extractList->name, TRUE, NULL)==FALSE) if (is_directory(extractList->name, TRUE, NULL)==FALSE)
createPath(extractList->name, 0666); create_path(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode); dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET); lseek(srcFd, extractList->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size); copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
@ -380,9 +380,9 @@ extern int ar_main(int argc, char **argv)
} }
if ( (funct & DISPLAY) || (funct & VERBOSE)) { if ( (funct & DISPLAY) || (funct & VERBOSE)) {
if (funct & VERBOSE) if (funct & VERBOSE)
printf("%s %d/%d %8d %s ", modeString(extractList->mode), printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
extractList->uid, extractList->gid, extractList->uid, extractList->gid,
extractList->size, timeString(extractList->mtime)); extractList->size, time_string(extractList->mtime));
printf("%s\n", extractList->name); printf("%s\n", extractList->name);
} }
extractList=extractList->next; extractList=extractList->next;

View File

@ -106,7 +106,7 @@ static int checkTarMagic(int srcFd)
headerStart = lseek(srcFd, 0, SEEK_CUR); headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR); lseek(srcFd, (off_t) 257, SEEK_CUR);
fullRead(srcFd, magic, 6); full_read(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET); lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0) if (strncmp(magic, "ustar", 5)!=0)
return(FALSE); return(FALSE);
@ -123,7 +123,7 @@ static int readTarHeader(int srcFd, headerL_t *current)
off_t initialOffset; off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR); initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) { if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
lseek(srcFd, initialOffset, SEEK_SET); lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE); return(FALSE);
} }
@ -157,8 +157,8 @@ static int checkArMagic(int srcFd)
char arMagic[8]; char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR); headerStart = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, arMagic, 8) != 8) { if (full_read(srcFd, arMagic, 8) != 8) {
errorMsg("fatal error\n"); error_msg("fatal error\n");
return (FALSE); return (FALSE);
} }
lseek(srcFd, headerStart, SEEK_SET); lseek(srcFd, headerStart, SEEK_SET);
@ -178,7 +178,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
off_t initialOffset; off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR); initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) { if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
lseek(srcFd, initialOffset, SEEK_SET); lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE); return(FALSE);
} }
@ -215,7 +215,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
if (entry->size > MAX_NAME_LENGTH) if (entry->size > MAX_NAME_LENGTH)
entry->size = MAX_NAME_LENGTH; entry->size = MAX_NAME_LENGTH;
fullRead(srcFd, tempName, entry->size); full_read(srcFd, tempName, entry->size);
tempName[entry->size-3]='\0'; tempName[entry->size-3]='\0';
/* read the second header for this entry */ /* read the second header for this entry */
@ -226,7 +226,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
if ((entry->name[0]='/') && (entry->name[1]='0')) if ((entry->name[0]='/') && (entry->name[1]='0'))
strcpy(entry->name, tempName); strcpy(entry->name, tempName);
else { else {
errorMsg("Invalid long filename\n"); error_msg("Invalid long filename\n");
return(FALSE); return(FALSE);
} }
} }
@ -343,7 +343,7 @@ extern int ar_main(int argc, char **argv)
usage(ar_usage); usage(ar_usage);
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0) if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
fatalError("Cannot read %s\n", argv[optind]); error_msg_and_die("Cannot read %s\n", argv[optind]);
optind++; optind++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t)); entry = (headerL_t *) xmalloc(sizeof(headerL_t));
@ -368,8 +368,8 @@ extern int ar_main(int argc, char **argv)
while(extractList->next != NULL) { while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) { if (funct & EXT_TO_FILE) {
if (isDirectory(extractList->name, TRUE, NULL)==FALSE) if (is_directory(extractList->name, TRUE, NULL)==FALSE)
createPath(extractList->name, 0666); create_path(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode); dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET); lseek(srcFd, extractList->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size); copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
@ -380,9 +380,9 @@ extern int ar_main(int argc, char **argv)
} }
if ( (funct & DISPLAY) || (funct & VERBOSE)) { if ( (funct & DISPLAY) || (funct & VERBOSE)) {
if (funct & VERBOSE) if (funct & VERBOSE)
printf("%s %d/%d %8d %s ", modeString(extractList->mode), printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
extractList->uid, extractList->gid, extractList->uid, extractList->gid,
extractList->size, timeString(extractList->mtime)); extractList->size, time_string(extractList->mtime));
printf("%s\n", extractList->name); printf("%s\n", extractList->name);
} }
extractList=extractList->next; extractList=extractList->next;

View File

@ -113,7 +113,7 @@ static char *license_msg[] = {
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG #ifdef DEBUG
# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} # define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
# define Trace(x) fprintf x # define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;} # define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;} # define Tracevv(x) {if (verbose>1) fprintf x ;}
@ -297,7 +297,7 @@ int in; /* input file descriptor */
method = (int) get_byte(); method = (int) get_byte();
if (method != DEFLATED) { if (method != DEFLATED) {
errorMsg("unknown method %d -- get newer version of gzip\n", method); error_msg("unknown method %d -- get newer version of gzip\n", method);
exit_code = ERROR; exit_code = ERROR;
return -1; return -1;
} }
@ -1114,13 +1114,13 @@ int in, out; /* input and output file descriptors */
int res = inflate(); int res = inflate();
if (res == 3) { if (res == 3) {
errorMsg(memory_exhausted); error_msg(memory_exhausted);
} else if (res != 0) { } else if (res != 0) {
errorMsg("invalid compressed data--format violated\n"); error_msg("invalid compressed data--format violated\n");
} }
} else { } else {
errorMsg("internal error, invalid method\n"); error_msg("internal error, invalid method\n");
} }
/* Get the crc and original length */ /* Get the crc and original length */
@ -1149,10 +1149,10 @@ int in, out; /* input and output file descriptors */
/* Validate decompression */ /* Validate decompression */
if (orig_crc != updcrc(outbuf, 0)) { if (orig_crc != updcrc(outbuf, 0)) {
errorMsg("invalid compressed data--crc error\n"); error_msg("invalid compressed data--crc error\n");
} }
if (orig_len != (ulg) bytes_out) { if (orig_len != (ulg) bytes_out) {
errorMsg("invalid compressed data--length error\n"); error_msg("invalid compressed data--length error\n");
} }
/* Check if there are more entries in a pkzip file */ /* Check if there are more entries in a pkzip file */
@ -1225,9 +1225,9 @@ int gunzip_main(int argc, char **argv)
} }
if (isatty(fileno(stdin)) && fromstdin==1 && force==0) if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
fatalError( "data not read from terminal. Use -f to force it.\n"); error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0) if (isatty(fileno(stdout)) && tostdout==1 && force==0)
fatalError( "data not written to terminal. Use -f to force it.\n"); error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
@ -1265,7 +1265,7 @@ int gunzip_main(int argc, char **argv)
if (argc <= 0) if (argc <= 0)
usage(gunzip_usage); usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) { if (strlen(*argv) > MAX_PATH_LEN) {
errorMsg(name_too_long); error_msg(name_too_long);
exit(WARNING); exit(WARNING);
} }
strcpy(ifname, *argv); strcpy(ifname, *argv);
@ -1304,7 +1304,7 @@ int gunzip_main(int argc, char **argv)
/* And get to work */ /* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) { if (strlen(ifname) > MAX_PATH_LEN - 4) {
errorMsg(name_too_long); error_msg(name_too_long);
exit(WARNING); exit(WARNING);
} }
strcpy(ofname, ifname); strcpy(ofname, ifname);

View File

@ -114,7 +114,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array # define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \ # define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
if (array == NULL) errorMsg(memory_exhausted); \ if (array == NULL) error_msg(memory_exhausted); \
} }
# define FREE(array) {if (array != NULL) free(array), array=NULL;} # define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else #else
@ -251,7 +251,7 @@ extern int save_orig_name; /* set if original name must be saved */
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG #ifdef DEBUG
# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} # define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
# define Trace(x) fprintf x # define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;} # define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;} # define Tracevv(x) {if (verbose>1) fprintf x ;}
@ -1381,7 +1381,7 @@ int length;
(char *) window + start, length) != EQUAL) { (char *) window + start, length) != EQUAL) {
fprintf(stderr, fprintf(stderr,
" start %d, match %d, length %d\n", start, match, length); " start %d, match %d, length %d\n", start, match, length);
errorMsg("invalid match\n"); error_msg("invalid match\n");
} }
if (verbose > 1) { if (verbose > 1) {
fprintf(stderr, "\\[%d,%d]", start - match, length); fprintf(stderr, "\\[%d,%d]", start - match, length);
@ -1819,9 +1819,9 @@ int gzip_main(int argc, char **argv)
} }
if (isatty(fileno(stdin)) && fromstdin==1 && force==0) if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
fatalError( "data not read from terminal. Use -f to force it.\n"); error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0) if (isatty(fileno(stdout)) && tostdout==1 && force==0)
fatalError( "data not written to terminal. Use -f to force it.\n"); error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) { if (foreground) {
@ -2900,7 +2900,7 @@ int eof; /* true if this is the last block for a file */
#endif #endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0) if (buf == (char *) 0)
errorMsg("block vanished\n"); error_msg("block vanished\n");
copy_block(buf, (unsigned) stored_len, 0); /* without header */ copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3; compressed_len = stored_len << 3;
@ -3083,7 +3083,7 @@ local void set_file_type()
bin_freq += dyn_ltree[n++].Freq; bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
if (*file_type == BINARY && translate_eol) { if (*file_type == BINARY && translate_eol) {
errorMsg("-l used on binary file\n"); error_msg("-l used on binary file\n");
} }
} }
@ -3239,13 +3239,13 @@ char *env; /* name of environment variable */
nargv = (char **) calloc(*argcp + 1, sizeof(char *)); nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL) if (nargv == NULL)
errorMsg(memory_exhausted); error_msg(memory_exhausted);
oargv = *argvp; oargv = *argvp;
*argvp = nargv; *argvp = nargv;
/* Copy the program name first */ /* Copy the program name first */
if (oargc-- < 0) if (oargc-- < 0)
errorMsg("argc<=0\n"); error_msg("argc<=0\n");
*(nargv++) = *(oargv++); *(nargv++) = *(oargv++);
/* Then copy the environment args */ /* Then copy the environment args */

View File

@ -193,10 +193,10 @@ extern int tar_main(int argc, char **argv)
break; break;
case 'f': case 'f':
if (*tarName != '-') if (*tarName != '-')
fatalError( "Only one 'f' option allowed\n"); error_msg_and_die( "Only one 'f' option allowed\n");
tarName = *(++argv); tarName = *(++argv);
if (tarName == NULL) if (tarName == NULL)
fatalError( "Option requires an argument: No file specified\n"); error_msg_and_die( "Option requires an argument: No file specified\n");
stopIt=TRUE; stopIt=TRUE;
break; break;
#if defined BB_FEATURE_TAR_EXCLUDE #if defined BB_FEATURE_TAR_EXCLUDE
@ -205,7 +205,7 @@ extern int tar_main(int argc, char **argv)
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
excludeList[excludeListSize] = *(++argv); excludeList[excludeListSize] = *(++argv);
if (excludeList[excludeListSize] == NULL) if (excludeList[excludeListSize] == NULL)
fatalError( "Option requires an argument: No file specified\n"); error_msg_and_die( "Option requires an argument: No file specified\n");
/* Remove leading "/"s */ /* Remove leading "/"s */
if (*excludeList[excludeListSize] =='/') if (*excludeList[excludeListSize] =='/')
excludeList[excludeListSize] = (excludeList[excludeListSize])+1; excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
@ -216,13 +216,13 @@ extern int tar_main(int argc, char **argv)
} }
case 'X': case 'X':
if (*excludeFileName != '-') if (*excludeFileName != '-')
fatalError("Only one 'X' option allowed\n"); error_msg_and_die("Only one 'X' option allowed\n");
excludeFileName = *(++argv); excludeFileName = *(++argv);
if (excludeFileName == NULL) if (excludeFileName == NULL)
fatalError("Option requires an argument: No file specified\n"); error_msg_and_die("Option requires an argument: No file specified\n");
fileList = fopen (excludeFileName, "rt"); fileList = fopen (excludeFileName, "rt");
if (! fileList) if (! fileList)
fatalError("Exclude file: file not found\n"); error_msg_and_die("Exclude file: file not found\n");
while (!feof(fileList)) { while (!feof(fileList)) {
fscanf(fileList, "%s", file); fscanf(fileList, "%s", file);
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
@ -253,7 +253,7 @@ extern int tar_main(int argc, char **argv)
*/ */
if (createFlag == TRUE) { if (createFlag == TRUE) {
#ifndef BB_FEATURE_TAR_CREATE #ifndef BB_FEATURE_TAR_CREATE
fatalError( "This version of tar was not compiled with tar creation support.\n"); error_msg_and_die( "This version of tar was not compiled with tar creation support.\n");
#else #else
status = writeTarFile(tarName, verboseFlag, argv, excludeList); status = writeTarFile(tarName, verboseFlag, argv, excludeList);
#endif #endif
@ -271,7 +271,7 @@ extern int tar_main(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
flagError: flagError:
fatalError( "Exactly one of 'c', 'x' or 't' must be specified\n"); error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified\n");
} }
static void static void
@ -301,10 +301,10 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
if (extractFlag==TRUE && tostdoutFlag==FALSE) { if (extractFlag==TRUE && tostdoutFlag==FALSE) {
/* Create the path to the file, just in case it isn't there... /* Create the path to the file, just in case it isn't there...
* This should not screw up path permissions or anything. */ * This should not screw up path permissions or anything. */
createPath(header->name, 0777); create_path(header->name, 0777);
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY, if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
header->mode & ~S_IFMT)) < 0) { header->mode & ~S_IFMT)) < 0) {
errorMsg(io_error, header->name, strerror(errno)); error_msg(io_error, header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
} }
@ -322,9 +322,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
readSize = size; readSize = size;
writeSize = size; writeSize = size;
} }
if ( (readSize = fullRead(header->tarFd, buffer, readSize)) <= 0 ) { if ( (readSize = full_read(header->tarFd, buffer, readSize)) <= 0 ) {
/* Tarball seems to have a problem */ /* Tarball seems to have a problem */
errorMsg("Unexpected EOF in archive\n"); error_msg("Unexpected EOF in archive\n");
return( FALSE); return( FALSE);
} }
if ( readSize < writeSize ) if ( readSize < writeSize )
@ -333,9 +333,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
/* Write out the file, if we are supposed to be doing that */ /* Write out the file, if we are supposed to be doing that */
if (extractFlag==TRUE) { if (extractFlag==TRUE) {
if ((actualWriteSz=fullWrite(outFd, buffer, writeSize)) != writeSize ) { if ((actualWriteSz=full_write(outFd, buffer, writeSize)) != writeSize ) {
/* Output file seems to have a problem */ /* Output file seems to have a problem */
errorMsg(io_error, header->name, strerror(errno)); error_msg(io_error, header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
} else { } else {
@ -361,13 +361,13 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
if (extractFlag==FALSE || tostdoutFlag==TRUE) if (extractFlag==FALSE || tostdoutFlag==TRUE)
return( TRUE); return( TRUE);
if (createPath(header->name, header->mode) != TRUE) { if (create_path(header->name, header->mode) != TRUE) {
errorMsg("%s: Cannot mkdir: %s\n", error_msg("%s: Cannot mkdir: %s\n",
header->name, strerror(errno)); 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
* omitted by createPath() (which will skip the * omitted by create_path() (which will skip the
* directory if it doesn't have a terminating '/') */ * directory if it doesn't have a terminating '/') */
if (mkdir(header->name, header->mode) == 0) { if (mkdir(header->name, header->mode) == 0) {
fixUpPermissions(header); fixUpPermissions(header);
@ -382,7 +382,7 @@ 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) {
errorMsg("%s: Cannot create hard link to '%s': %s\n", error_msg("%s: Cannot create hard link to '%s': %s\n",
header->name, header->linkname, strerror(errno)); header->name, header->linkname, strerror(errno));
return( FALSE); return( FALSE);
} }
@ -400,7 +400,7 @@ 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) {
errorMsg("%s: Cannot create symlink to '%s': %s\n", error_msg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname, strerror(errno)); header->name, header->linkname, strerror(errno));
return( FALSE); return( FALSE);
} }
@ -415,7 +415,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
/* Do not change permissions or date on symlink, /* Do not change permissions or date on symlink,
* since it changes the pointed to file instead. duh. */ * since it changes the pointed to file instead. duh. */
#else #else
errorMsg("%s: Cannot create symlink to '%s': %s\n", error_msg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname, header->name, header->linkname,
"symlinks not supported"); "symlinks not supported");
#endif #endif
@ -430,13 +430,13 @@ 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) {
errorMsg("%s: Cannot mknod: %s\n", error_msg("%s: Cannot mknod: %s\n",
header->name, strerror(errno)); 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) {
errorMsg("%s: Cannot mkfifo: %s\n", error_msg("%s: Cannot mkfifo: %s\n",
header->name, strerror(errno)); header->name, strerror(errno));
return( FALSE); return( FALSE);
} }
@ -455,9 +455,9 @@ static long getOctal(const char *cp, int size)
long val = 0; long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--); for(;(size > 0) && (*cp == ' '); cp++, size--);
if ((size == 0) || !isOctal(*cp)) if ((size == 0) || !is_octal(*cp))
return -1; return -1;
for(; (size > 0) && isOctal(*cp); size--) { for(; (size > 0) && is_octal(*cp); size--) {
val = val * 8 + *cp++ - '0'; val = val * 8 + *cp++ - '0';
} }
for (;(size > 0) && (*cp == ' '); cp++, size--); for (;(size > 0) && (*cp == ' '); cp++, size--);
@ -484,7 +484,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
++*(header->name); ++*(header->name);
if (alreadyWarned == FALSE) { if (alreadyWarned == FALSE) {
errorMsg("Removing leading '/' from member names\n"); error_msg("Removing leading '/' from member names\n");
alreadyWarned = TRUE; alreadyWarned = TRUE;
} }
} }
@ -538,7 +538,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
else else
tarFd = open(tarName, O_RDONLY); tarFd = open(tarName, O_RDONLY);
if (tarFd < 0) { if (tarFd < 0) {
errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno)); error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
return ( FALSE); return ( FALSE);
} }
@ -547,7 +547,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
umask(0); umask(0);
/* Read the tar file, and iterate over it one file at a time */ /* Read the tar file, and iterate over it one file at a time */
while ( (status = fullRead(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) { while ( (status = full_read(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
/* Try to read the header */ /* Try to read the header */
if ( readTarHeader(&rawHeader, &header) == FALSE ) { if ( readTarHeader(&rawHeader, &header) == FALSE ) {
@ -555,7 +555,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
goto endgame; goto endgame;
} else { } else {
errorFlag=TRUE; errorFlag=TRUE;
errorMsg("Bad tar header, skipping\n"); error_msg("Bad tar header, skipping\n");
continue; continue;
} }
} }
@ -572,7 +572,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
} }
if ( skipNextHeaderFlag == TRUE ) { if ( skipNextHeaderFlag == TRUE ) {
skipNextHeaderFlag=FALSE; skipNextHeaderFlag=FALSE;
errorMsg(name_longer_than_foo, NAME_SIZE); error_msg(name_longer_than_foo, NAME_SIZE);
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE) if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
errorFlag = TRUE; errorFlag = TRUE;
continue; continue;
@ -638,7 +638,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
char buf[35]; char buf[35];
struct tm *tm = localtime (&(header.mtime)); struct tm *tm = localtime (&(header.mtime));
len=printf("%s ", modeString(header.mode)); len=printf("%s ", mode_string(header.mode));
memset(buf, 0, 8*sizeof(char)); memset(buf, 0, 8*sizeof(char));
my_getpwuid(buf, header.uid); my_getpwuid(buf, header.uid);
if (! *buf) if (! *buf)
@ -731,7 +731,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
break; break;
#endif #endif
default: default:
errorMsg("Unknown file type '%c' in tar file\n", header.type); error_msg("Unknown file type '%c' in tar file\n", header.type);
close( tarFd); close( tarFd);
return( FALSE); return( FALSE);
} }
@ -739,11 +739,11 @@ static int readTarFile(const char* tarName, 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 */
errorMsg( "Error reading '%s': %s\n", tarName, strerror(errno)); error_msg( "Error reading '%s': %s\n", tarName, strerror(errno));
return ( FALSE); return ( FALSE);
} }
else if (errorFlag==TRUE) { else if (errorFlag==TRUE) {
errorMsg( "Error exit delayed from previous errors\n"); error_msg( "Error exit delayed from previous errors\n");
return( FALSE); return( FALSE);
} else } else
return( status); return( status);
@ -753,13 +753,13 @@ endgame:
close( tarFd); close( tarFd);
if (extractList != NULL) { if (extractList != NULL) {
for (; *extractList != NULL; extractList++) { for (; *extractList != NULL; extractList++) {
errorMsg("%s: Not found in archive\n", *extractList); error_msg("%s: Not found in archive\n", *extractList);
errorFlag = TRUE; errorFlag = TRUE;
} }
} }
if ( *(header.name) == '\0' ) { if ( *(header.name) == '\0' ) {
if (errorFlag==TRUE) if (errorFlag==TRUE)
errorMsg( "Error exit delayed from previous errors\n"); error_msg( "Error exit delayed from previous errors\n");
else else
return( TRUE); return( TRUE);
} }
@ -903,7 +903,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
if (*fileName=='/') { if (*fileName=='/') {
static int alreadyWarned=FALSE; static int alreadyWarned=FALSE;
if (alreadyWarned==FALSE) { if (alreadyWarned==FALSE) {
errorMsg("Removing leading '/' from member names\n"); error_msg("Removing leading '/' from member names\n");
alreadyWarned=TRUE; alreadyWarned=TRUE;
} }
strncpy(header.name, fileName+1, sizeof(header.name)); strncpy(header.name, fileName+1, sizeof(header.name));
@ -956,7 +956,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) {
errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno)); error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
return ( FALSE); return ( FALSE);
} }
buffer[link_size] = '\0'; buffer[link_size] = '\0';
@ -978,7 +978,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
header.typeflag = REGTYPE; header.typeflag = REGTYPE;
putOctal(header.size, sizeof(header.size), statbuf->st_size); putOctal(header.size, sizeof(header.size), statbuf->st_size);
} else { } else {
errorMsg("%s: Unknown file type\n", fileName); error_msg("%s: Unknown file type\n", fileName);
return ( FALSE); return ( FALSE);
} }
@ -994,8 +994,8 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
putOctal(header.chksum, 7, chksum); putOctal(header.chksum, 7, chksum);
/* Now write the header out to disk */ /* Now write the header out to disk */
if ((size=fullWrite(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) { if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
errorMsg(io_error, fileName, strerror(errno)); error_msg(io_error, fileName, strerror(errno));
return ( FALSE); return ( FALSE);
} }
/* Pad the header up to the tar block size */ /* Pad the header up to the tar block size */
@ -1036,7 +1036,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
/* It is against the rules to archive a socket */ /* It is against the rules to archive a socket */
if (S_ISSOCK(statbuf->st_mode)) { if (S_ISSOCK(statbuf->st_mode)) {
errorMsg("%s: socket ignored\n", fileName); error_msg("%s: socket ignored\n", fileName);
return( TRUE); return( TRUE);
} }
@ -1045,12 +1045,12 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
* the new tarball */ * the new tarball */
if (tbInfo->statBuf.st_dev == statbuf->st_dev && if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
tbInfo->statBuf.st_ino == statbuf->st_ino) { tbInfo->statBuf.st_ino == statbuf->st_ino) {
errorMsg("%s: file is the archive; skipping\n", fileName); error_msg("%s: file is the archive; skipping\n", fileName);
return( TRUE); return( TRUE);
} }
if (strlen(fileName) >= NAME_SIZE) { if (strlen(fileName) >= NAME_SIZE) {
errorMsg(name_longer_than_foo, NAME_SIZE); error_msg(name_longer_than_foo, NAME_SIZE);
return ( TRUE); return ( TRUE);
} }
@ -1067,21 +1067,21 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
/* open the file we want to archive, and make sure all is well */ /* open the file we want to archive, and make sure all is well */
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) { if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
errorMsg("%s: Cannot open: %s\n", fileName, strerror(errno)); error_msg("%s: Cannot open: %s\n", fileName, strerror(errno));
return( FALSE); return( FALSE);
} }
/* write the file to the archive */ /* write the file to the archive */
while ( (size = fullRead(inputFileFd, buffer, sizeof(buffer))) > 0 ) { while ( (size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
if (fullWrite(tbInfo->tarFd, buffer, size) != size ) { if (full_write(tbInfo->tarFd, buffer, size) != size ) {
/* Output file seems to have a problem */ /* Output file seems to have a problem */
errorMsg(io_error, fileName, strerror(errno)); error_msg(io_error, fileName, strerror(errno));
return( FALSE); return( FALSE);
} }
readSize+=size; readSize+=size;
} }
if (size == -1) { if (size == -1) {
errorMsg(io_error, fileName, strerror(errno)); error_msg(io_error, fileName, strerror(errno));
return( FALSE); return( FALSE);
} }
/* Pad the file up to the tar block size */ /* Pad the file up to the tar block size */
@ -1106,7 +1106,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
/* Make sure there is at least one file to tar up. */ /* Make sure there is at least one file to tar up. */
if (*argv == NULL) if (*argv == NULL)
fatalError("Cowardly refusing to create an empty archive\n"); error_msg_and_die("Cowardly refusing to create an empty archive\n");
/* Open the tar file for writing. */ /* Open the tar file for writing. */
if (!strcmp(tarName, "-")) if (!strcmp(tarName, "-"))
@ -1114,7 +1114,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) {
errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno)); error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
freeHardLinkInfo(&tbInfo.hlInfoHead); freeHardLinkInfo(&tbInfo.hlInfoHead);
return ( FALSE); return ( FALSE);
} }
@ -1122,7 +1122,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
/* Store the stat info for the tarball's file, so /* Store the stat info for the tarball's file, so
* can avoid including the tarball into itself.... */ * can avoid including the tarball into itself.... */
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0) if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
fatalError(io_error, tarName, strerror(errno)); error_msg_and_die(io_error, tarName, strerror(errno));
/* Set the umask for this process so it doesn't /* Set the umask for this process so it doesn't
* screw up permission setting for us later. */ * screw up permission setting for us later. */
@ -1130,7 +1130,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
/* Read the directory/files and iterate over them one at a time */ /* Read the directory/files and iterate over them one at a time */
while (*argv != NULL) { while (*argv != NULL) {
if (recursiveAction(*argv++, TRUE, FALSE, FALSE, if (recursive_action(*argv++, TRUE, FALSE, FALSE,
writeFileToTarball, writeFileToTarball, writeFileToTarball, writeFileToTarball,
(void*) &tbInfo) == FALSE) { (void*) &tbInfo) == FALSE) {
errorFlag = TRUE; errorFlag = TRUE;
@ -1149,7 +1149,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
/* Hang up the tools, close up shop, head home */ /* Hang up the tools, close up shop, head home */
close(tarFd); close(tarFd);
if (errorFlag == TRUE) { if (errorFlag == TRUE) {
errorMsg("Error exit delayed from previous errors\n"); error_msg("Error exit delayed from previous errors\n");
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 {
errorMsg("%s: %s\n", proc, strerror(errno)); error_msg("%s: %s\n", proc, strerror(errno));
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) {
errorMsg("%s: %s\n", command, strerror(errno)); error_msg("%s: %s\n", command, strerror(errno));
} }
} }
} }

View File

@ -55,8 +55,8 @@
#define BUF_SIZE 8192 #define BUF_SIZE 8192
#define EXPAND_ALLOC 1024 #define EXPAND_ALLOC 1024
static inline int isDecimal(ch) { return ((ch >= '0') && (ch <= '9')); } static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
static inline int isOctal(ch) { return ((ch >= '0') && (ch <= '7')); } static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
/* Macros for min/max. */ /* Macros for min/max. */
#ifndef MIN #ifndef MIN
@ -119,14 +119,14 @@ extern const char *applet_name;
extern int applet_name_compare(const void *x, const void *y); extern int applet_name_compare(const void *x, const void *y);
extern void usage(const char *usage) __attribute__ ((noreturn)); extern void usage(const char *usage) __attribute__ ((noreturn));
extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void perrorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatalPerror(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
const char *modeString(int mode); const char *mode_string(int mode);
const char *timeString(time_t timeVal); const char *time_string(time_t timeVal);
int isDirectory(const char *name, const int followLinks, struct stat *statBuf); int is_directory(const char *name, const int followLinks, struct stat *statBuf);
int isDevice(const char *name); int isDevice(const char *name);
typedef struct ino_dev_hash_bucket_struct { typedef struct ino_dev_hash_bucket_struct {
@ -139,7 +139,7 @@ int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void); void reset_ino_dev_hashtable(void);
int copyFile(const char *srcName, const char *destName, int copy_file(const char *srcName, const char *destName,
int setModes, int followLinks, int forceFlag); int setModes, int followLinks, int forceFlag);
int copy_file_chunk(int srcFd, int dstFd, size_t remaining); int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
char *buildName(const char *dirName, const char *fileName); char *buildName(const char *dirName, const char *fileName);
@ -147,20 +147,20 @@ int makeString(int argc, const char **argv, char *buf, int bufLen);
char *getChunk(int size); char *getChunk(int size);
char *chunkstrdup(const char *str); char *chunkstrdup(const char *str);
void freeChunks(void); void freeChunks(void);
int fullWrite(int fd, const char *buf, int len); int full_write(int fd, const char *buf, int len);
int fullRead(int fd, char *buf, int len); int full_read(int fd, char *buf, int len);
int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst, int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData), int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData), int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
void* userData); void* userData);
extern int createPath (const char *name, int mode); extern int create_path (const char *name, int mode);
extern int parse_mode( const char* s, mode_t* theMode); extern int parse_mode( const char* s, mode_t* theMode);
extern int get_kernel_revision(void); extern int get_kernel_revision(void);
extern int get_console_fd(char* tty_name); extern int get_console_fd(char* tty_name);
extern struct mntent *findMountPoint(const char *name, const char *table); extern struct mntent *find_mount_point(const char *name, const char *table);
extern void write_mtab(char* blockDevice, char* directory, extern void write_mtab(char* blockDevice, char* directory,
char* filesystemType, long flags, char* string_flags); char* filesystemType, long flags, char* string_flags);
extern void erase_mtab(const char * name); extern void erase_mtab(const char * name);
@ -169,8 +169,8 @@ extern char *mtab_first(void **iter);
extern char *mtab_next(void **iter); extern char *mtab_next(void **iter);
extern char *mtab_getinfo(const char *match, const char which); extern char *mtab_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern); extern int check_wildcard_match(const char* text, const char* pattern);
extern long getNum (const char *cp); extern long atoi_w_units (const char *cp);
extern pid_t* findPidByName( char* pidName); extern pid_t* find_pid_by_name( char* pidName);
extern int find_real_root_device_name(char* name); extern int find_real_root_device_name(char* name);
extern char *get_line_from_file(FILE *file); extern char *get_line_from_file(FILE *file);
extern void print_file(FILE *file); extern void print_file(FILE *file);

View File

@ -64,7 +64,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
case CHMOD_APP: case CHMOD_APP:
/* Parse the specified modes */ /* Parse the specified modes */
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) { if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
fatalError( "unknown mode: %s\n", theMode); error_msg_and_die( "unknown mode: %s\n", theMode);
} }
if (chmod(fileName, statbuf->st_mode) == 0) if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE); return (TRUE);
@ -111,7 +111,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
} }
if (argc == 0 || *argv == NULL) { if (argc == 0 || *argv == NULL) {
errorMsg(too_few_args); error_msg(too_few_args);
} }
if (whichApp == CHMOD_APP) { if (whichApp == CHMOD_APP) {
@ -149,24 +149,24 @@ int chmod_chown_chgrp_main(int argc, char **argv)
if (*argv == p) if (*argv == p)
uid = my_getpwnam(*argv); uid = my_getpwnam(*argv);
if (uid == -1) { if (uid == -1) {
fatalError( "unknown user name: %s\n", *argv); error_msg_and_die( "unknown user name: %s\n", *argv);
} }
} }
} }
/* Ok, ready to do the deed now */ /* Ok, ready to do the deed now */
if (argc < 1) { if (argc < 1) {
fatalError(too_few_args); error_msg_and_die(too_few_args);
} }
while (argc-- > 1) { while (argc-- > 1) {
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE, if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) fileAction, fileAction, NULL) == FALSE)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
bad_group: bad_group:
fatalError( "unknown group name: %s\n", groupName); error_msg_and_die( "unknown group name: %s\n", groupName);
} }
/* /*

View File

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

View File

@ -106,7 +106,7 @@ cmdedit_setwidth(int w)
cmdedit_termw = w; cmdedit_termw = w;
cmdedit_scroll = w / 3; cmdedit_scroll = w / 3;
} else { } else {
errorMsg("\n*** Error: minimum screen width is 21\n"); error_msg("\n*** Error: minimum screen width is 21\n");
} }
} }

View File

@ -35,12 +35,12 @@ printf("erik: B\n");
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
num = atoi(argv[i]); num = atoi(argv[i]);
if (num == 0) if (num == 0)
errorMsg("0: illegal VT number\n"); error_msg("0: illegal VT number\n");
else if (num == 1) else if (num == 1)
errorMsg("VT 1 cannot be deallocated\n"); error_msg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) { else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE"); perror("VT_DISALLOCATE");
fatalError("could not deallocate console %d\n", num); error_msg_and_die("could not deallocate console %d\n", num);
} }
} }
printf("erik: C\n"); printf("erik: C\n");

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

View File

@ -39,12 +39,12 @@ int loadacm_main(int argc, char **argv)
fd = open("/dev/tty", O_RDWR); fd = open("/dev/tty", O_RDWR);
if (fd < 0) { if (fd < 0) {
errorMsg("Error opening /dev/tty1: %s\n", strerror(errno)); error_msg("Error opening /dev/tty1: %s\n", strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (screen_map_load(fd, stdin)) { if (screen_map_load(fd, stdin)) {
errorMsg("Error loading acm: %s\n", strerror(errno)); error_msg("Error loading acm: %s\n", strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -72,7 +72,7 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) { if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
errorMsg("16bit screen-map MUST be a regular file.\n"), error_msg("16bit screen-map MUST be a regular file.\n"),
exit(1); exit(1);
else else
perror("fseek failed reading binary 16bit screen-map"), perror("fseek failed reading binary 16bit screen-map"),
@ -83,7 +83,7 @@ int screen_map_load(int fd, FILE * fp)
perror("Cannot read [new] map from file"), exit(1); perror("Cannot read [new] map from file"), exit(1);
#if 0 #if 0
else else
errorMsg("Input screen-map is binary.\n"); error_msg("Input screen-map is binary.\n");
#endif #endif
} }
@ -100,7 +100,7 @@ int screen_map_load(int fd, FILE * fp)
/* rewind... */ /* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"), error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1); exit(1);
else else
perror("fseek failed assuming 8bit screen-map"), exit(1); perror("fseek failed assuming 8bit screen-map"), exit(1);
@ -113,7 +113,7 @@ int screen_map_load(int fd, FILE * fp)
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
/* should not - it succedeed above */ /* should not - it succedeed above */
errorMsg("fseek() returned ESPIPE !\n"), error_msg("fseek() returned ESPIPE !\n"),
exit(1); exit(1);
else else
perror("fseek for binary 8bit screen-map"), exit(1); perror("fseek for binary 8bit screen-map"), exit(1);
@ -123,7 +123,7 @@ int screen_map_load(int fd, FILE * fp)
perror("Cannot read [old] map from file"), exit(1); perror("Cannot read [old] map from file"), exit(1);
#if 0 #if 0
else else
errorMsg("Input screen-map is binary.\n"); error_msg("Input screen-map is binary.\n");
#endif #endif
} }
@ -132,7 +132,7 @@ int screen_map_load(int fd, FILE * fp)
else else
return 0; return 0;
} }
errorMsg("Error parsing symbolic map\n"); error_msg("Error parsing symbolic map\n");
return(1); return(1);
} }

View File

@ -48,7 +48,7 @@ extern int loadfont_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) if (fd < 0)
fatalPerror("Error opening /dev/tty0"); perror_msg_and_die("Error opening /dev/tty0");
loadnewfont(fd); loadnewfont(fd);
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -62,7 +62,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32) if (unit < 1 || unit > 32)
fatalError("Bad character size %d\n", unit); error_msg_and_die("Bad character size %d\n", unit);
for (i = 0; i < fontsize; i++) for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit); memcpy(buf + (32 * i), inbuf + (unit * i), unit);
@ -77,11 +77,11 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
if (ioctl(fd, PIO_FONTX, &cfd) == 0) if (ioctl(fd, PIO_FONTX, &cfd) == 0)
return; /* success */ return; /* success */
perrorMsg("PIO_FONTX ioctl error (trying PIO_FONT)"); perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
} }
#endif #endif
if (ioctl(fd, PIO_FONT, buf)) if (ioctl(fd, PIO_FONT, buf))
fatalPerror("PIO_FONT ioctl error"); perror_msg_and_die("PIO_FONT ioctl error");
} }
static void static void
@ -119,11 +119,11 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) { if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD #ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) { if (errno == ENOIOCTLCMD) {
errorMsg("It seems this kernel is older than 1.1.92\n"); error_msg("It seems this kernel is older than 1.1.92\n");
fatalError("No Unicode mapping table loaded.\n"); error_msg_and_die("No Unicode mapping table loaded.\n");
} else } else
#endif #endif
fatalPerror("PIO_UNIMAPCLR"); perror_msg_and_die("PIO_UNIMAPCLR");
} }
ud.entry_ct = ct; ud.entry_ct = ct;
ud.entries = up; ud.entries = up;
@ -133,7 +133,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
/* change advice parameters */ /* change advice parameters */
} }
#endif #endif
fatalPerror("PIO_UNIMAP"); perror_msg_and_die("PIO_UNIMAP");
} }
} }
@ -150,13 +150,13 @@ static void loadnewfont(int fd)
*/ */
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin); inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin)) if (ferror(stdin))
fatalPerror("Error reading input font"); perror_msg_and_die("Error reading input font");
/* use malloc/realloc in case of giant files; /* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font, maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values and 16kB for the map leaves 32 unicode values
for each font position */ for each font position */
if (!feof(stdin)) if (!feof(stdin))
fatalPerror("Font too large"); perror_msg_and_die("Font too large");
/* test for psf first */ /* test for psf first */
{ {
@ -174,11 +174,11 @@ static void loadnewfont(int fd)
goto no_psf; goto no_psf;
if (psfhdr.mode > PSF_MAXMODE) if (psfhdr.mode > PSF_MAXMODE)
fatalError("Unsupported psf file mode\n"); error_msg_and_die("Unsupported psf file mode\n");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ ) #if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256) if (fontsize != 256)
fatalError("Only fontsize 256 supported\n"); error_msg_and_die("Only fontsize 256 supported\n");
#endif #endif
hastable = (psfhdr.mode & PSF_MODEHASTAB); hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize; unit = psfhdr.charsize;
@ -186,7 +186,7 @@ static void loadnewfont(int fd)
head = head0 + fontsize * unit; head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth)) if (head > inputlth || (!hastable && head != inputlth))
fatalError("Input file: bad length\n"); error_msg_and_die("Input file: bad length\n");
do_loadfont(fd, inbuf + head0, unit, fontsize); do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable) if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize); do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
@ -201,7 +201,7 @@ static void loadnewfont(int fd)
} else { } else {
/* bare font */ /* bare font */
if (inputlth & 0377) if (inputlth & 0377)
fatalError("Bad input file size\n"); error_msg_and_die("Bad input file size\n");
offset = 0; offset = 0;
unit = inputlth / 256; unit = inputlth / 256;
} }

View File

@ -52,14 +52,14 @@ int loadkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) if (fd < 0)
fatalPerror("Error opening /dev/tty0"); perror_msg_and_die("Error opening /dev/tty0");
read(0, buff, 7); read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7)) if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
fatalError("This is not a valid binary keymap.\n"); error_msg_and_die("This is not a valid binary keymap.\n");
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
fatalPerror("Error reading keymap flags"); perror_msg_and_die("Error reading keymap flags");
ibuff = (u_short *) xmalloc(ibuffsz); ibuff = (u_short *) xmalloc(ibuffsz);
@ -68,7 +68,7 @@ int loadkmap_main(int argc, char **argv)
pos = 0; pos = 0;
while (pos < ibuffsz) { while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0) if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
fatalPerror("Error reading keymap"); perror_msg_and_die("Error reading keymap");
pos += readsz; pos += readsz;
} }
for (j = 0; j < NR_KEYS; j++) { for (j = 0; j < NR_KEYS; j++) {

View File

@ -52,18 +52,18 @@ setkeycodes_main(int argc, char** argv)
a.keycode = atoi(argv[2]); a.keycode = atoi(argv[2]);
a.scancode = sc = strtol(argv[1], &ep, 16); a.scancode = sc = strtol(argv[1], &ep, 16);
if (*ep) { if (*ep) {
fatalError("error reading SCANCODE: '%s'\n", argv[1]); error_msg_and_die("error reading SCANCODE: '%s'\n", argv[1]);
} }
if (a.scancode > 127) { if (a.scancode > 127) {
a.scancode -= 0xe000; a.scancode -= 0xe000;
a.scancode += 128; a.scancode += 128;
} }
if (a.scancode > 255 || a.keycode > 127) { if (a.scancode > 255 || a.keycode > 127) {
fatalError("SCANCODE or KEYCODE outside bounds\n"); error_msg_and_die("SCANCODE or KEYCODE outside bounds\n");
} }
if (ioctl(fd,KDSETKEYCODE,&a)) { if (ioctl(fd,KDSETKEYCODE,&a)) {
perror("KDSETKEYCODE"); perror("KDSETKEYCODE");
fatalError("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode); error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
} }
argc -= 2; argc -= 2;
argv += 2; argv += 2;

View File

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

View File

@ -54,12 +54,12 @@ static void decompose_list(const char *list)
/* the list must contain only digits and no more than one minus sign */ /* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) { for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') { if (!isdigit(*ptr) && *ptr != '-') {
fatalError("invalid byte or field list\n"); error_msg_and_die("invalid byte or field list\n");
} }
if (*ptr == '-') { if (*ptr == '-') {
nminus++; nminus++;
if (nminus > 1) { if (nminus > 1) {
fatalError("invalid byte or field list\n"); error_msg_and_die("invalid byte or field list\n");
} }
} }
} }
@ -68,7 +68,7 @@ static void decompose_list(const char *list)
if (nminus == 0) { if (nminus == 0) {
startpos = strtol(list, &ptr, 10); startpos = strtol(list, &ptr, 10);
if (startpos == 0) { if (startpos == 0) {
fatalError("missing list of fields\n"); error_msg_and_die("missing list of fields\n");
} }
endpos = startpos; endpos = startpos;
} }
@ -188,14 +188,14 @@ extern int cut_main(int argc, char **argv)
case 'f': case 'f':
/* make sure they didn't ask for two types of lists */ /* make sure they didn't ask for two types of lists */
if (part != 0) { if (part != 0) {
fatalError("only one type of list may be specified"); error_msg_and_die("only one type of list may be specified");
} }
part = (char)opt; part = (char)opt;
decompose_list(optarg); decompose_list(optarg);
break; break;
case 'd': case 'd':
if (strlen(optarg) > 1) { if (strlen(optarg) > 1) {
fatalError("the delimiter must be a single character\n"); error_msg_and_die("the delimiter must be a single character\n");
} }
delim = optarg[0]; delim = optarg[0];
break; break;
@ -209,16 +209,16 @@ extern int cut_main(int argc, char **argv)
} }
if (part == 0) { if (part == 0) {
fatalError("you must specify a list of bytes, characters, or fields\n"); error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
} }
if (supress_non_delimited_lines && part != 'f') { if (supress_non_delimited_lines && part != 'f') {
fatalError("suppressing non-delimited lines makes sense error_msg_and_die("suppressing non-delimited lines makes sense
only when operating on fields\n"); only when operating on fields\n");
} }
if (delim != '\t' && part != 'f') { if (delim != '\t' && part != 'f') {
fatalError("a delimiter may be specified only when operating on fields\n"); error_msg_and_die("a delimiter may be specified only when operating on fields\n");
} }
/* argv[(optind)..(argc-1)] should be names of file to process. If no /* argv[(optind)..(argc-1)] should be names of file to process. If no
@ -233,7 +233,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) {
errorMsg("%s: %s\n", argv[i], strerror(errno)); error_msg("%s: %s\n", argv[i], strerror(errno));
} else { } else {
cut_file(file); cut_file(file);
fclose(file); fclose(file);

View File

@ -56,7 +56,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
&(tm_time->tm_min), &(tm_time->tm_year)); &(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) { if (nr < 4 || nr > 5) {
fatalError(invalid_date, t_string); error_msg_and_die(invalid_date, t_string);
} }
/* correct for century - minor Y2K problem here? */ /* correct for century - minor Y2K problem here? */
@ -121,7 +121,7 @@ struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */ t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else { } else {
fatalError(invalid_date, t_string); error_msg_and_die(invalid_date, t_string);
} }
*tm_time = t; *tm_time = t;
return (tm_time); return (tm_time);
@ -156,7 +156,7 @@ int date_main(int argc, char **argv)
case 'u': case 'u':
utc = 1; utc = 1;
if (putenv("TZ=UTC0") != 0) if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted); error_msg_and_die(memory_exhausted);
break; break;
case 'd': case 'd':
use_arg = 1; use_arg = 1;
@ -176,7 +176,7 @@ int date_main(int argc, char **argv)
} }
#if 0 #if 0
else { else {
errorMsg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt); error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
usage(date_usage); usage(date_usage);
} }
#endif #endif
@ -205,16 +205,16 @@ int date_main(int argc, char **argv)
/* Correct any day of week and day of year etc fields */ /* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time); tm = mktime(&tm_time);
if (tm < 0) if (tm < 0)
fatalError(invalid_date, date_str); error_msg_and_die(invalid_date, date_str);
if ( utc ) { if ( utc ) {
if (putenv("TZ=UTC0") != 0) if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted); error_msg_and_die(memory_exhausted);
} }
/* if setting time, set it */ /* if setting time, set it */
if (set_time) { if (set_time) {
if (stime(&tm) < 0) { if (stime(&tm) < 0) {
perrorMsg("cannot set date"); perror_msg("cannot set date");
} }
} }
} }

View File

@ -71,28 +71,28 @@ extern int dd_main(int argc, char **argv)
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0)) else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
outFile = ((strchr(*argv, '=')) + 1); outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) { else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1); count = atoi_w_units((strchr(*argv, '=')) + 1);
if (count < 0) { if (count < 0) {
errorMsg("Bad count value %s\n", *argv); error_msg("Bad count value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "bs", 2) == 0) { } else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1); blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
if (blockSize <= 0) { if (blockSize <= 0) {
errorMsg("Bad block size value %s\n", *argv); error_msg("Bad block size value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "skip", 4) == 0) { } else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1); skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) { if (skipBlocks <= 0) {
errorMsg("Bad skip value %s\n", *argv); error_msg("Bad skip value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "seek", 4) == 0) { } else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1); seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) { if (seekBlocks <= 0) {
errorMsg("Bad seek value %s\n", *argv); error_msg("Bad seek value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "conv", 4) == 0) { } else if (strncmp(*argv, "conv", 4) == 0) {
@ -119,7 +119,7 @@ extern int dd_main(int argc, char **argv)
* here anyways... */ * here anyways... */
/* free(buf); */ /* free(buf); */
fatalPerror("%s", inFile); perror_msg_and_die("%s", inFile);
} }
if (outFile == NULL) if (outFile == NULL)
@ -134,7 +134,7 @@ extern int dd_main(int argc, char **argv)
/* close(inFd); /* close(inFd);
free(buf); */ free(buf); */
fatalPerror("%s", outFile); perror_msg_and_die("%s", outFile);
} }
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET); lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
@ -146,13 +146,13 @@ extern int dd_main(int argc, char **argv)
ibs=BUFSIZ; ibs=BUFSIZ;
while (totalSize > outTotal) { while (totalSize > outTotal) {
inCc = fullRead(inFd, buf, ibs); inCc = full_read(inFd, buf, ibs);
inTotal += inCc; inTotal += inCc;
if ( (sync==TRUE) && (inCc>0) ) if ( (sync==TRUE) && (inCc>0) )
while (inCc<ibs) while (inCc<ibs)
buf[inCc++]='\0'; buf[inCc++]='\0';
if ((outCc = fullWrite(outFd, buf, inCc)) < 1){ if ((outCc = full_write(outFd, buf, inCc)) < 1){
if (outCc < 0 ){ if (outCc < 0 ){
perror("Error during write"); perror("Error during write");
} }

View File

@ -36,7 +36,7 @@ static int df(char *device, const char *mountPoint)
long blocks_percent_used; long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) { if (statfs(mountPoint, &s) != 0) {
perrorMsg("%s", mountPoint); perror_msg("%s", mountPoint);
return FALSE; return FALSE;
} }
@ -75,8 +75,8 @@ extern int df_main(int argc, char **argv)
usage(df_usage); usage(df_usage);
} }
while (argc > 1) { while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
errorMsg("%s: can't find mount point.\n", argv[1]); error_msg("%s: can't find mount point.\n", argv[1]);
status = EXIT_FAILURE; status = EXIT_FAILURE;
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir)) } else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
status = EXIT_FAILURE; status = EXIT_FAILURE;
@ -89,7 +89,7 @@ extern int df_main(int argc, char **argv)
mountTable = setmntent(mtab_file, "r"); mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) { if (mountTable == 0) {
perrorMsg("%s", mtab_file); perror_msg("%s", mtab_file);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -97,7 +97,7 @@ static long du(char *filename)
} }
if (len + strlen(name) + 1 > BUFSIZ) { if (len + strlen(name) + 1 > BUFSIZ) {
errorMsg(name_too_long); error_msg(name_too_long);
du_depth--; du_depth--;
return 0; return 0;
} }
@ -156,7 +156,7 @@ int du_main(int argc, char **argv)
for (i=optind; i < argc; i++) { for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0) if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE; status = EXIT_FAILURE;
if (sum && isDirectory(argv[i], FALSE, NULL)) { if (sum && is_directory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]); print_normal(sum, argv[i]);
} }
reset_ino_dev_hashtable(); reset_ino_dev_hashtable();
@ -166,7 +166,7 @@ int du_main(int argc, char **argv)
return status; return status;
} }
/* $Id: du.c,v 1.28 2000/12/06 15:56:31 kraai Exp $ */ /* $Id: du.c,v 1.29 2000/12/07 19:56:48 markw Exp $ */
/* /*
Local Variables: Local Variables:
c-file-style: "linux" c-file-style: "linux"

View File

@ -74,14 +74,14 @@ int expr_main (int argc, char **argv)
VALUE *v; VALUE *v;
if (argc == 1) { if (argc == 1) {
fatalError("too few arguments\n"); error_msg_and_die("too few arguments\n");
} }
args = argv + 1; args = argv + 1;
v = eval (); v = eval ();
if (*args) if (*args)
fatalError ("syntax error\n"); error_msg_and_die ("syntax error\n");
if (v->type == integer) if (v->type == integer)
printf ("%d\n", v->u.i); printf ("%d\n", v->u.i);
@ -216,7 +216,7 @@ static \
int name (l, r) VALUE *l; VALUE *r; \ int name (l, r) VALUE *l; VALUE *r; \
{ \ { \
if (!toarith (l) || !toarith (r)) \ if (!toarith (l) || !toarith (r)) \
fatalError ("non-numeric argument\n"); \ error_msg_and_die ("non-numeric argument\n"); \
return l->u.i op r->u.i; \ return l->u.i op r->u.i; \
} }
@ -224,9 +224,9 @@ int name (l, r) VALUE *l; VALUE *r; \
int name (l, r) VALUE *l; VALUE *r; \ int name (l, r) VALUE *l; VALUE *r; \
{ \ { \
if (!toarith (l) || !toarith (r)) \ if (!toarith (l) || !toarith (r)) \
fatalError ( "non-numeric argument\n"); \ error_msg_and_die ( "non-numeric argument\n"); \
if (r->u.i == 0) \ if (r->u.i == 0) \
fatalError ( "division by zero\n"); \ error_msg_and_die ( "division by zero\n"); \
return l->u.i op r->u.i; \ return l->u.i op r->u.i; \
} }
@ -270,7 +270,7 @@ of a basic regular expression is not portable; it is being ignored",
re_syntax_options = RE_SYNTAX_POSIX_BASIC; re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer); errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) { if (errmsg) {
fatalError("%s\n", errmsg); error_msg_and_die("%s\n", errmsg);
} }
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs); len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
@ -301,19 +301,19 @@ static VALUE *eval7 (void)
VALUE *v; VALUE *v;
if (!*args) if (!*args)
fatalError ( "syntax error\n"); error_msg_and_die ( "syntax error\n");
if (nextarg ("(")) { if (nextarg ("(")) {
args++; args++;
v = eval (); v = eval ();
if (!nextarg (")")) if (!nextarg (")"))
fatalError ( "syntax error\n"); error_msg_and_die ( "syntax error\n");
args++; args++;
return v; return v;
} }
if (nextarg (")")) if (nextarg (")"))
fatalError ( "syntax error\n"); error_msg_and_die ( "syntax error\n");
return str_value (*args++); return str_value (*args++);
} }
@ -327,7 +327,7 @@ static VALUE *eval6 (void)
if (nextarg ("quote")) { if (nextarg ("quote")) {
args++; args++;
if (!*args) if (!*args)
fatalError ( "syntax error\n"); error_msg_and_die ( "syntax error\n");
return str_value (*args++); return str_value (*args++);
} }
else if (nextarg ("length")) { else if (nextarg ("length")) {

View File

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

View File

@ -78,7 +78,7 @@ extern int id_main(int argc, char **argv)
pwnam=my_getpwnam(user); pwnam=my_getpwnam(user);
grnam=my_getgrnam(group); grnam=my_getgrnam(group);
if (gid == -1 || pwnam==-1 || grnam==-1) { if (gid == -1 || pwnam==-1 || grnam==-1) {
fatalError("%s: No such user\n", user); error_msg_and_die("%s: No such user\n", user);
} }
if (no_group) if (no_group)
printf("%ld\n", pwnam); printf("%ld\n", pwnam);

View File

@ -55,9 +55,9 @@ static int fs_link(const char *link_DestName, const char *link_SrcName, const in
strcpy(srcName, link_SrcName); strcpy(srcName, link_SrcName);
if (flag&LN_NODEREFERENCE) if (flag&LN_NODEREFERENCE)
srcIsDir = isDirectory(srcName, TRUE, NULL); srcIsDir = is_directory(srcName, TRUE, NULL);
else else
srcIsDir = isDirectory(srcName, FALSE, NULL); srcIsDir = is_directory(srcName, FALSE, NULL);
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) { if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
strcat(srcName, "/"); strcat(srcName, "/");

View File

@ -35,5 +35,5 @@ extern int logname_main(int argc, char **argv)
puts(user); puts(user);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
fatalError("no login name\n"); error_msg_and_die("no login name\n");
} }

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)) {
errorMsg("%s: %s\n", cur->fullname, strerror(errno)); error_msg("%s: %s\n", cur->fullname, strerror(errno));
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)) {
errorMsg("%s: %s\n", cur->fullname, strerror(errno)); error_msg("%s: %s\n", cur->fullname, strerror(errno));
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) {
errorMsg("%s: %s\n", path, strerror(errno)); error_msg("%s: %s\n", path, strerror(errno));
status = EXIT_FAILURE; status = EXIT_FAILURE;
return(NULL); /* could not open the dir */ return(NULL); /* could not open the dir */
} }
@ -591,7 +591,7 @@ int list_single(struct dnode *dn)
column += 5; column += 5;
break; break;
case LIST_MODEBITS: case LIST_MODEBITS:
fprintf(stdout, "%10s", (char *)modeString(dn->dstat.st_mode)); fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10; column += 10;
break; break;
case LIST_NLINKS: case LIST_NLINKS:

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) {
errorMsg("%s: %s\n", filename, strerror(errno)); error_msg("%s: %s\n", filename, strerror(errno));
return FALSE; return FALSE;
} }
} }
if (md5_stream(fp, md5_result)) { if (md5_stream(fp, md5_result)) {
errorMsg("%s: %s\n", filename, strerror(errno)); error_msg("%s: %s\n", filename, strerror(errno));
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) {
errorMsg("%s: %s\n", filename, strerror(errno)); error_msg("%s: %s\n", filename, strerror(errno));
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) {
errorMsg("%s: %s\n", checkfile_name, strerror(errno)); error_msg("%s: %s\n", checkfile_name, strerror(errno));
return FALSE; return FALSE;
} }
} }
@ -722,7 +722,7 @@ static int md5_check(const char *checkfile_name)
if (split_3(line, line_length, &md5num, &binary, &filename) if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) { || !hex_digits(md5num)) {
if (warn) { if (warn) {
errorMsg("%s: %lu: improperly formatted MD5 checksum line\n", error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
checkfile_name, (unsigned long) line_number); checkfile_name, (unsigned long) line_number);
} }
} else { } else {
@ -770,18 +770,18 @@ static int md5_check(const char *checkfile_name)
free(line); free(line);
if (ferror(checkfile_stream)) { if (ferror(checkfile_stream)) {
errorMsg("%s: read error\n", checkfile_name); /* */ error_msg("%s: read error\n", checkfile_name); /* */
return FALSE; return FALSE;
} }
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) { if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
return FALSE; return FALSE;
} }
if (n_properly_formated_lines == 0) { if (n_properly_formated_lines == 0) {
/* Warn if no tests are found. */ /* Warn if no tests are found. */
errorMsg("%s: no properly formatted MD5 checksum lines found\n", error_msg("%s: no properly formatted MD5 checksum lines found\n",
checkfile_name); checkfile_name);
return FALSE; return FALSE;
} else { } else {
@ -790,13 +790,13 @@ static int md5_check(const char *checkfile_name)
- n_open_or_read_failures); - n_open_or_read_failures);
if (n_open_or_read_failures > 0) { if (n_open_or_read_failures > 0) {
errorMsg("WARNING: %d of %d listed files could not be read\n", error_msg("WARNING: %d of %d listed files could not be read\n",
n_open_or_read_failures, n_properly_formated_lines); n_open_or_read_failures, n_properly_formated_lines);
return FALSE; return FALSE;
} }
if (n_mismatched_checksums > 0) { if (n_mismatched_checksums > 0) {
errorMsg("WARNING: %d of %d computed checksums did NOT match\n", error_msg("WARNING: %d of %d computed checksums did NOT match\n",
n_mismatched_checksums, n_computed_checkums); n_mismatched_checksums, n_computed_checkums);
return FALSE; return FALSE;
} }
@ -861,22 +861,22 @@ int md5sum_main(int argc,
} }
if (file_type_specified && do_check) { if (file_type_specified && do_check) {
errorMsg("the -b and -t options are meaningless when verifying checksums\n"); error_msg("the -b and -t options are meaningless when verifying checksums\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (n_strings > 0 && do_check) { if (n_strings > 0 && do_check) {
errorMsg("the -g and -c options are mutually exclusive\n"); error_msg("the -g and -c options are mutually exclusive\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (status_only && !do_check) { if (status_only && !do_check) {
errorMsg("the -s option is meaningful only when verifying checksums\n"); error_msg("the -s option is meaningful only when verifying checksums\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (warn && !do_check) { if (warn && !do_check) {
errorMsg("the -w option is meaningful only when verifying checksums\n"); error_msg("the -w option is meaningful only when verifying checksums\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -884,7 +884,7 @@ int md5sum_main(int argc,
size_t i; size_t i;
if (optind < argc) { if (optind < argc) {
errorMsg("no files may be specified when using -g\n"); error_msg("no files may be specified when using -g\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
for (i = 0; i < n_strings; ++i) { for (i = 0; i < n_strings; ++i) {
@ -898,7 +898,7 @@ int md5sum_main(int argc,
} }
} else if (do_check) { } else if (do_check) {
if (optind + 1 < argc) { if (optind + 1 < argc) {
errorMsg("only one argument may be specified when using -c\n"); error_msg("only one argument may be specified when using -c\n");
} }
err = md5_check ((optind == argc) ? "-" : argv[optind]); err = md5_check ((optind == argc) ? "-" : argv[optind]);
@ -951,12 +951,12 @@ int md5sum_main(int argc,
} }
if (fclose (stdout) == EOF) { if (fclose (stdout) == EOF) {
errorMsg("write error\n"); error_msg("write error\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (have_read_stdin && fclose (stdin) == EOF) { if (have_read_stdin && fclose (stdin) == EOF) {
errorMsg("standard input\n"); error_msg("standard input\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -50,7 +50,7 @@ extern int mkdir_main(int argc, char **argv)
/* Find the specified modes */ /* Find the specified modes */
mode = 0; mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) { if (parse_mode(*(++argv), &mode) == FALSE) {
errorMsg("Unknown mode: %s\n", *argv); error_msg("Unknown mode: %s\n", *argv);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/* Set the umask for this process so it doesn't /* Set the umask for this process so it doesn't
@ -79,18 +79,18 @@ extern int mkdir_main(int argc, char **argv)
char buf[BUFSIZ + 1]; char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) { if (strlen(*argv) > BUFSIZ - 1) {
errorMsg(name_too_long); error_msg(name_too_long);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
strcpy(buf, *argv); strcpy(buf, *argv);
status = stat(buf, &statBuf); status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) { if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
errorMsg("%s: File exists\n", buf); error_msg("%s: File exists\n", buf);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (parentFlag == TRUE) { if (parentFlag == TRUE) {
strcat(buf, "/"); strcat(buf, "/");
createPath(buf, mode); create_path(buf, mode);
} else { } else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) { if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror(buf); perror(buf);

View File

@ -84,7 +84,7 @@ int mknod_main(int argc, char **argv)
mode |= perm; mode |= perm;
if (mknod(argv[0], mode, dev) != 0) if (mknod(argv[0], mode, dev) != 0)
fatalError("%s: %s\n", argv[0], strerror(errno)); error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -31,7 +31,7 @@ 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)
fatalError("%s\n", strerror(errno)); error_msg_and_die("%s\n", strerror(errno));
printf("%s\n", buf); printf("%s\n", buf);
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -37,7 +37,7 @@ static const char *srcName;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk) static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{ {
if (unlink(fileName) < 0) { if (unlink(fileName) < 0) {
perrorMsg("%s", fileName); perror_msg("%s", fileName);
return (FALSE); return (FALSE);
} }
return (TRUE); return (TRUE);
@ -47,11 +47,11 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
{ {
if (recursiveFlag == FALSE) { if (recursiveFlag == FALSE) {
errno = EISDIR; errno = EISDIR;
perrorMsg("%s", fileName); perror_msg("%s", fileName);
return (FALSE); return (FALSE);
} }
if (rmdir(fileName) < 0) { if (rmdir(fileName) < 0) {
perrorMsg("%s", fileName); perror_msg("%s", fileName);
return (FALSE); return (FALSE);
} }
return (TRUE); return (TRUE);
@ -101,7 +101,7 @@ extern int rm_main(int argc, char **argv)
&& errno == ENOENT) { && errno == ENOENT) {
/* do not reports errors for non-existent files if -f, just skip them */ /* do not reports errors for non-existent files if -f, just skip them */
} else { } else {
if (recursiveAction(srcName, recursiveFlag, FALSE, if (recursive_action(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) { TRUE, fileAction, dirAction, NULL) == FALSE) {
status = EXIT_FAILURE; status = EXIT_FAILURE;
} }

View File

@ -35,7 +35,7 @@ extern int rmdir_main(int argc, char **argv)
while (--argc > 0) { while (--argc > 0) {
if (rmdir(*(++argv)) == -1) { if (rmdir(*(++argv)) == -1) {
perrorMsg("%s", *argv); perror_msg("%s", *argv);
status = EXIT_FAILURE; status = EXIT_FAILURE;
} }
} }

View File

@ -247,7 +247,7 @@ int sort_main(int argc, char **argv)
break; break;
#endif #endif
default: default:
errorMsg("invalid option -- %c\n", opt); error_msg("invalid option -- %c\n", opt);
usage(sort_usage); usage(sort_usage);
} }
} else { } else {
@ -286,4 +286,4 @@ int sort_main(int argc, char **argv)
return(0); return(0);
} }
/* $Id: sort.c,v 1.23 2000/09/28 17:49:59 beppu Exp $ */ /* $Id: sort.c,v 1.24 2000/12/07 19:56:48 markw Exp $ */

View File

@ -225,7 +225,7 @@ int tail_main(int argc, char **argv)
usage(tail_usage); usage(tail_usage);
break; break;
default: default:
errorMsg("\nUnknown arg: %c.\n\n",optopt); error_msg("\nUnknown arg: %c.\n\n",optopt);
usage(tail_usage); usage(tail_usage);
} }
} }
@ -263,7 +263,7 @@ int tail_main(int argc, char **argv)
else else
fd[test] = open(files[test], O_RDONLY); fd[test] = open(files[test], O_RDONLY);
if (fd[test] == -1) if (fd[test] == -1)
fatalError("Unable to open file %s.\n", files[test]); error_msg_and_die("Unable to open file %s.\n", files[test]);
tail_stream(fd[test]); tail_stream(fd[test]);
bs=BUFSIZ; bs=BUFSIZ;

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--;
errorMsg("%s: %s\n", argv[optind-1], strerror(errno)); error_msg("%s: %s\n", argv[optind-1], strerror(errno));
status = 1; status = 1;
} }
} }

View File

@ -184,7 +184,7 @@ test_main(int argc, char** argv)
if (strcmp(applet_name, "[") == 0) { if (strcmp(applet_name, "[") == 0) {
if (strcmp(argv[--argc], "]")) if (strcmp(argv[--argc], "]"))
fatalError("missing ]\n"); error_msg_and_die("missing ]\n");
argv[argc] = NULL; argv[argc] = NULL;
} }
/* Implement special cases from POSIX.2, section 4.62.4 */ /* Implement special cases from POSIX.2, section 4.62.4 */
@ -233,9 +233,9 @@ syntax(op, msg)
char *msg; char *msg;
{ {
if (op && *op) if (op && *op)
fatalError("%s: %s\n", op, msg); error_msg_and_die("%s: %s\n", op, msg);
else else
fatalError("%s\n", msg); error_msg_and_die("%s\n", msg);
} }
static int static int
@ -470,13 +470,13 @@ getn(s)
r = strtol(s, &p, 10); r = strtol(s, &p, 10);
if (errno != 0) if (errno != 0)
fatalError("%s: out of range\n", s); error_msg_and_die("%s: out of range\n", s);
while (isspace(*p)) while (isspace(*p))
p++; p++;
if (*p) if (*p)
fatalError("%s: bad number\n", s); error_msg_and_die("%s: bad number\n", s);
return (int) r; return (int) r;
} }

View File

@ -58,12 +58,12 @@ extern int touch_main(int argc, char **argv)
if (create == FALSE && errno == ENOENT) if (create == FALSE && errno == ENOENT)
return EXIT_SUCCESS; return EXIT_SUCCESS;
else { else {
fatalError("%s", strerror(errno)); error_msg_and_die("%s", strerror(errno));
} }
} }
close(fd); close(fd);
if (utime(*argv, NULL)) { if (utime(*argv, NULL)) {
fatalError("%s", strerror(errno)); error_msg_and_die("%s", strerror(errno));
} }
argc--; argc--;
argv++; argv++;

View File

@ -173,7 +173,7 @@ extern int tr_main(int argc, char **argv)
input_length = complement(input, input_length); input_length = complement(input, input_length);
if (argv[index] != NULL) { if (argv[index] != NULL) {
if (*argv[index] == '\0') if (*argv[index] == '\0')
fatalError("STRING2 cannot be empty\n"); error_msg_and_die("STRING2 cannot be empty\n");
output_length = expand(argv[index], output); output_length = expand(argv[index], output);
map(input, input_length, output, output_length); map(input, input_length, output, output_length);
} }

View File

@ -43,7 +43,7 @@ static int read_stduu (const char *inname)
char *p; char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) { if (fgets (buf, sizeof(buf), stdin) == NULL) {
errorMsg("%s: Short file\n", inname); error_msg("%s: Short file\n", inname);
return FALSE; return FALSE;
} }
p = buf; p = buf;
@ -78,7 +78,7 @@ static int read_stduu (const char *inname)
if (fgets (buf, sizeof(buf), stdin) == NULL if (fgets (buf, sizeof(buf), stdin) == NULL
|| strcmp (buf, "end\n")) { || strcmp (buf, "end\n")) {
errorMsg("%s: No `end' line\n", inname); error_msg("%s: No `end' line\n", inname);
return FALSE; return FALSE;
} }
@ -128,7 +128,7 @@ static int read_base64 (const char *inname)
unsigned char *p; unsigned char *p;
if (fgets (buf, sizeof(buf), stdin) == NULL) { if (fgets (buf, sizeof(buf), stdin) == NULL) {
errorMsg("%s: Short file\n", inname); error_msg("%s: Short file\n", inname);
return FALSE; return FALSE;
} }
p = buf; p = buf;
@ -136,7 +136,7 @@ static int read_base64 (const char *inname)
if (memcmp (buf, "====", 4) == 0) if (memcmp (buf, "====", 4) == 0)
break; break;
if (last_data != 0) { if (last_data != 0) {
errorMsg("%s: data following `=' padding character\n", inname); error_msg("%s: data following `=' padding character\n", inname);
return FALSE; return FALSE;
} }
@ -158,14 +158,14 @@ static int read_base64 (const char *inname)
while ((b64_tab[*p] & '\100') != 0) while ((b64_tab[*p] & '\100') != 0)
if (*p == '\n' || *p++ == '=') { if (*p == '\n' || *p++ == '=') {
errorMsg("%s: illegal line\n", inname); error_msg("%s: illegal line\n", inname);
return FALSE; return FALSE;
} }
c2 = b64_tab[*p++]; c2 = b64_tab[*p++];
while (b64_tab[*p] == '\177') while (b64_tab[*p] == '\177')
if (*p++ == '\n') { if (*p++ == '\n') {
errorMsg("%s: illegal line\n", inname); error_msg("%s: illegal line\n", inname);
return FALSE; return FALSE;
} }
if (*p == '=') { if (*p == '=') {
@ -177,7 +177,7 @@ static int read_base64 (const char *inname)
while (b64_tab[*p] == '\177') while (b64_tab[*p] == '\177')
if (*p++ == '\n') { if (*p++ == '\n') {
errorMsg("%s: illegal line\n", inname); error_msg("%s: illegal line\n", inname);
return FALSE; return FALSE;
} }
putchar (c1 << 2 | c2 >> 4); putchar (c1 << 2 | c2 >> 4);
@ -209,7 +209,7 @@ static int decode (const char *inname,
while (1) { while (1) {
if (fgets (buf, sizeof (buf), stdin) == NULL) { if (fgets (buf, sizeof (buf), stdin) == NULL) {
errorMsg("%s: No `begin' line\n", inname); error_msg("%s: No `begin' line\n", inname);
return FALSE; return FALSE;
} }
@ -234,13 +234,13 @@ static int decode (const char *inname,
while (*p != '/') while (*p != '/')
++p; ++p;
if (*p == '\0') { if (*p == '\0') {
errorMsg("%s: Illegal ~user\n", inname); error_msg("%s: Illegal ~user\n", inname);
return FALSE; return FALSE;
} }
*p++ = '\0'; *p++ = '\0';
pw = getpwnam (buf + 1); pw = getpwnam (buf + 1);
if (pw == NULL) { if (pw == NULL) {
errorMsg("%s: No user `%s'\n", inname, buf + 1); error_msg("%s: No user `%s'\n", inname, buf + 1);
return FALSE; return FALSE;
} }
n = strlen (pw->pw_dir); n = strlen (pw->pw_dir);
@ -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))
)) { )) {
errorMsg("%s: %s %s\n", outname, inname, strerror(errno)); /* */ error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
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 {
errorMsg("%s: %s\n", argv[optind], strerror(errno)); error_msg("%s: %s\n", argv[optind], strerror(errno));
exit_status = EXIT_FAILURE; exit_status = EXIT_FAILURE;
} }
optind++; optind++;

View File

@ -142,7 +142,7 @@ static void encode()
} }
if (ferror (stdin)) if (ferror (stdin))
errorMsg("Read error\n"); error_msg("Read error\n");
if (trans_ptr == uu_std) { if (trans_ptr == uu_std) {
putchar (ENC ('\0')); putchar (ENC ('\0'));
@ -178,7 +178,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)) {
errorMsg("%s: %s\n", argv[optind], strerror(errno)); error_msg("%s: %s\n", argv[optind], strerror(errno));
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);
@ -199,7 +199,7 @@ int uuencode_main (int argc,
encode(); encode();
printf(trans_ptr == uu_std ? "end\n" : "====\n"); printf(trans_ptr == uu_std ? "end\n" : "====\n");
if (ferror (stdout)) { if (ferror (stdout)) {
errorMsg("Write error\n"); error_msg("Write error\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -37,5 +37,5 @@ extern int whoami_main(int argc, char **argv)
puts(user); puts(user);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
fatalError("cannot find username for UID %u\n", (unsigned) uid); error_msg_and_die("cannot find username for UID %u\n", (unsigned) uid);
} }

40
cp_mv.c
View File

@ -75,7 +75,7 @@ static void name_too_long__exit (void) __attribute__((noreturn));
static static
void name_too_long__exit (void) void name_too_long__exit (void)
{ {
fatalError(name_too_long); error_msg_and_die(name_too_long);
} }
static void static void
@ -109,14 +109,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (srcDirFlag == TRUE) { if (srcDirFlag == TRUE) {
if (recursiveFlag == FALSE) { if (recursiveFlag == FALSE) {
errorMsg(omitting_directory, baseSrcName); error_msg(omitting_directory, baseSrcName);
return TRUE; return TRUE;
} }
srcBasename = (strstr(fileName, baseSrcName) srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName)); + strlen(baseSrcName));
if (destLen + strlen(srcBasename) > BUFSIZ) { if (destLen + strlen(srcBasename) > BUFSIZ) {
errorMsg(name_too_long); error_msg(name_too_long);
return FALSE; return FALSE;
} }
strcat(destName, srcBasename); strcat(destName, srcBasename);
@ -130,7 +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) {
errorMsg("rename(%s, %s): %s\n", fileName, destName, error_msg("rename(%s, %s): %s\n", fileName, destName,
strerror(errno)); strerror(errno));
goto do_copyFile; /* Try anyway... */ goto do_copyFile; /* Try anyway... */
} }
@ -143,7 +143,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) {
errorMsg("link(%s, %s): %s\n", name, destName, strerror(errno)); error_msg("link(%s, %s): %s\n", name, destName, strerror(errno));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -152,7 +152,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
add_to_ino_dev_hashtable(statbuf, destName); add_to_ino_dev_hashtable(statbuf, destName);
} }
} }
return copyFile(fileName, destName, preserveFlag, followLinks, forceFlag); return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag);
} }
static int static int
@ -162,11 +162,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) {
errorMsg("rmdir(%s): %s\n", fileName, strerror(errno)); error_msg("rmdir(%s): %s\n", fileName, strerror(errno));
status = FALSE; status = FALSE;
} }
} else if (unlink(fileName) < 0) { } else if (unlink(fileName) < 0) {
errorMsg("unlink(%s): %s\n", fileName, strerror(errno)); error_msg("unlink(%s): %s\n", fileName, strerror(errno));
status = FALSE; status = FALSE;
} }
return status; return status;
@ -224,7 +224,7 @@ extern int cp_mv_main(int argc, char **argv)
if (strlen(argv[argc - 1]) > BUFSIZ) { if (strlen(argv[argc - 1]) > BUFSIZ) {
errorMsg(name_too_long); error_msg(name_too_long);
goto exit_false; goto exit_false;
} }
strcpy(baseDestName, argv[argc - 1]); strcpy(baseDestName, argv[argc - 1]);
@ -232,9 +232,9 @@ extern int cp_mv_main(int argc, char **argv)
if (baseDestLen == 0) if (baseDestLen == 0)
goto exit_false; goto exit_false;
destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf); destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf);
if (argc - optind > 2 && destDirFlag == FALSE) { if (argc - optind > 2 && destDirFlag == FALSE) {
errorMsg(not_a_directory, baseDestName); error_msg(not_a_directory, baseDestName);
goto exit_false; goto exit_false;
} }
@ -250,7 +250,7 @@ extern int cp_mv_main(int argc, char **argv)
if (srcLen == 0) continue; /* "" */ if (srcLen == 0) continue; /* "" */
srcDirFlag = isDirectory(baseSrcName, followLinks, &srcStatBuf); srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf);
if ((flags_memo = (recursiveFlag == TRUE && if ((flags_memo = (recursiveFlag == TRUE &&
srcDirFlag == TRUE && destDirFlag == TRUE))) { srcDirFlag == TRUE && destDirFlag == TRUE))) {
@ -260,26 +260,26 @@ 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) {
errorMsg("getcwd(): %s\n", strerror(errno)); error_msg("getcwd(): %s\n", strerror(errno));
continue; continue;
} }
if (chdir(baseDestName) < 0) { if (chdir(baseDestName) < 0) {
errorMsg("chdir(%s): %s\n", baseSrcName, strerror(errno)); error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno));
continue; continue;
} }
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
errorMsg("getcwd(): %s\n", strerror(errno)); error_msg("getcwd(): %s\n", strerror(errno));
continue; continue;
} }
while (!state && *d != '\0') { while (!state && *d != '\0') {
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
errorMsg("stat(%s): %s\n", d, strerror(errno)); error_msg("stat(%s): %s\n", d, strerror(errno));
state = -1; state = -1;
continue; continue;
} }
if ((sb.st_ino == srcStatBuf.st_ino) && if ((sb.st_ino == srcStatBuf.st_ino) &&
(sb.st_dev == srcStatBuf.st_dev)) { (sb.st_dev == srcStatBuf.st_dev)) {
errorMsg("Cannot %s `%s' into a subdirectory of itself, " error_msg("Cannot %s `%s' into a subdirectory of itself, "
"`%s/%s'\n", applet_name, baseSrcName, "`%s/%s'\n", applet_name, baseSrcName,
baseDestName, baseSrcName); baseDestName, baseSrcName);
state = -1; state = -1;
@ -290,7 +290,7 @@ extern int cp_mv_main(int argc, char **argv)
} }
} }
if (chdir(pushd) < 0) { if (chdir(pushd) < 0) {
errorMsg("chdir(%s): %s\n", pushd, strerror(errno)); error_msg("chdir(%s): %s\n", pushd, strerror(errno));
free(pushd); free(pushd);
free(d); free(d);
continue; continue;
@ -305,11 +305,11 @@ extern int cp_mv_main(int argc, char **argv)
status = setjmp(catch); status = setjmp(catch);
if (status == 0) { if (status == 0) {
mv_Action_first_time = 1; mv_Action_first_time = 1;
if (recursiveAction(baseSrcName, if (recursive_action(baseSrcName,
recursiveFlag, followLinks, FALSE, recursiveFlag, followLinks, FALSE,
cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false; cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false;
if (dz_i == is_mv && if (dz_i == is_mv &&
recursiveAction(baseSrcName, recursive_action(baseSrcName,
recursiveFlag, followLinks, TRUE, recursiveFlag, followLinks, TRUE,
rm_Action, rm_Action, NULL) == FALSE) goto exit_false; rm_Action, rm_Action, NULL) == FALSE) goto exit_false;
} }

18
cut.c
View File

@ -54,12 +54,12 @@ static void decompose_list(const char *list)
/* the list must contain only digits and no more than one minus sign */ /* the list must contain only digits and no more than one minus sign */
for (ptr = (char *)list; *ptr; ptr++) { for (ptr = (char *)list; *ptr; ptr++) {
if (!isdigit(*ptr) && *ptr != '-') { if (!isdigit(*ptr) && *ptr != '-') {
fatalError("invalid byte or field list\n"); error_msg_and_die("invalid byte or field list\n");
} }
if (*ptr == '-') { if (*ptr == '-') {
nminus++; nminus++;
if (nminus > 1) { if (nminus > 1) {
fatalError("invalid byte or field list\n"); error_msg_and_die("invalid byte or field list\n");
} }
} }
} }
@ -68,7 +68,7 @@ static void decompose_list(const char *list)
if (nminus == 0) { if (nminus == 0) {
startpos = strtol(list, &ptr, 10); startpos = strtol(list, &ptr, 10);
if (startpos == 0) { if (startpos == 0) {
fatalError("missing list of fields\n"); error_msg_and_die("missing list of fields\n");
} }
endpos = startpos; endpos = startpos;
} }
@ -188,14 +188,14 @@ extern int cut_main(int argc, char **argv)
case 'f': case 'f':
/* make sure they didn't ask for two types of lists */ /* make sure they didn't ask for two types of lists */
if (part != 0) { if (part != 0) {
fatalError("only one type of list may be specified"); error_msg_and_die("only one type of list may be specified");
} }
part = (char)opt; part = (char)opt;
decompose_list(optarg); decompose_list(optarg);
break; break;
case 'd': case 'd':
if (strlen(optarg) > 1) { if (strlen(optarg) > 1) {
fatalError("the delimiter must be a single character\n"); error_msg_and_die("the delimiter must be a single character\n");
} }
delim = optarg[0]; delim = optarg[0];
break; break;
@ -209,16 +209,16 @@ extern int cut_main(int argc, char **argv)
} }
if (part == 0) { if (part == 0) {
fatalError("you must specify a list of bytes, characters, or fields\n"); error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
} }
if (supress_non_delimited_lines && part != 'f') { if (supress_non_delimited_lines && part != 'f') {
fatalError("suppressing non-delimited lines makes sense error_msg_and_die("suppressing non-delimited lines makes sense
only when operating on fields\n"); only when operating on fields\n");
} }
if (delim != '\t' && part != 'f') { if (delim != '\t' && part != 'f') {
fatalError("a delimiter may be specified only when operating on fields\n"); error_msg_and_die("a delimiter may be specified only when operating on fields\n");
} }
/* argv[(optind)..(argc-1)] should be names of file to process. If no /* argv[(optind)..(argc-1)] should be names of file to process. If no
@ -233,7 +233,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) {
errorMsg("%s: %s\n", argv[i], strerror(errno)); error_msg("%s: %s\n", argv[i], strerror(errno));
} else { } else {
cut_file(file); cut_file(file);
fclose(file); fclose(file);

14
date.c
View File

@ -56,7 +56,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
&(tm_time->tm_min), &(tm_time->tm_year)); &(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) { if (nr < 4 || nr > 5) {
fatalError(invalid_date, t_string); error_msg_and_die(invalid_date, t_string);
} }
/* correct for century - minor Y2K problem here? */ /* correct for century - minor Y2K problem here? */
@ -121,7 +121,7 @@ struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */ t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else { } else {
fatalError(invalid_date, t_string); error_msg_and_die(invalid_date, t_string);
} }
*tm_time = t; *tm_time = t;
return (tm_time); return (tm_time);
@ -156,7 +156,7 @@ int date_main(int argc, char **argv)
case 'u': case 'u':
utc = 1; utc = 1;
if (putenv("TZ=UTC0") != 0) if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted); error_msg_and_die(memory_exhausted);
break; break;
case 'd': case 'd':
use_arg = 1; use_arg = 1;
@ -176,7 +176,7 @@ int date_main(int argc, char **argv)
} }
#if 0 #if 0
else { else {
errorMsg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt); error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
usage(date_usage); usage(date_usage);
} }
#endif #endif
@ -205,16 +205,16 @@ int date_main(int argc, char **argv)
/* Correct any day of week and day of year etc fields */ /* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time); tm = mktime(&tm_time);
if (tm < 0) if (tm < 0)
fatalError(invalid_date, date_str); error_msg_and_die(invalid_date, date_str);
if ( utc ) { if ( utc ) {
if (putenv("TZ=UTC0") != 0) if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted); error_msg_and_die(memory_exhausted);
} }
/* if setting time, set it */ /* if setting time, set it */
if (set_time) { if (set_time) {
if (stime(&tm) < 0) { if (stime(&tm) < 0) {
perrorMsg("cannot set date"); perror_msg("cannot set date");
} }
} }
} }

6
dc.c
View File

@ -14,14 +14,14 @@ static unsigned int pointer;
static void push(double a) static void push(double a)
{ {
if (pointer >= (sizeof(stack) / sizeof(*stack))) if (pointer >= (sizeof(stack) / sizeof(*stack)))
fatalError("stack overflow\n"); error_msg_and_die("stack overflow\n");
stack[pointer++] = a; stack[pointer++] = a;
} }
static double pop() static double pop()
{ {
if (pointer == 0) if (pointer == 0)
fatalError("stack underflow\n"); error_msg_and_die("stack underflow\n");
return stack[--pointer]; return stack[--pointer];
} }
@ -120,7 +120,7 @@ static void stack_machine(const char *argument)
} }
o++; o++;
} }
fatalError("%s: syntax error.\n", argument); error_msg_and_die("%s: syntax error.\n", argument);
} }
/* return pointer to next token in buffer and set *buffer to one char /* return pointer to next token in buffer and set *buffer to one char

24
dd.c
View File

@ -71,28 +71,28 @@ extern int dd_main(int argc, char **argv)
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0)) else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
outFile = ((strchr(*argv, '=')) + 1); outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) { else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1); count = atoi_w_units((strchr(*argv, '=')) + 1);
if (count < 0) { if (count < 0) {
errorMsg("Bad count value %s\n", *argv); error_msg("Bad count value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "bs", 2) == 0) { } else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1); blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
if (blockSize <= 0) { if (blockSize <= 0) {
errorMsg("Bad block size value %s\n", *argv); error_msg("Bad block size value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "skip", 4) == 0) { } else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1); skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) { if (skipBlocks <= 0) {
errorMsg("Bad skip value %s\n", *argv); error_msg("Bad skip value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "seek", 4) == 0) { } else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1); seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) { if (seekBlocks <= 0) {
errorMsg("Bad seek value %s\n", *argv); error_msg("Bad seek value %s\n", *argv);
goto usage; goto usage;
} }
} else if (strncmp(*argv, "conv", 4) == 0) { } else if (strncmp(*argv, "conv", 4) == 0) {
@ -119,7 +119,7 @@ extern int dd_main(int argc, char **argv)
* here anyways... */ * here anyways... */
/* free(buf); */ /* free(buf); */
fatalPerror("%s", inFile); perror_msg_and_die("%s", inFile);
} }
if (outFile == NULL) if (outFile == NULL)
@ -134,7 +134,7 @@ extern int dd_main(int argc, char **argv)
/* close(inFd); /* close(inFd);
free(buf); */ free(buf); */
fatalPerror("%s", outFile); perror_msg_and_die("%s", outFile);
} }
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET); lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
@ -146,13 +146,13 @@ extern int dd_main(int argc, char **argv)
ibs=BUFSIZ; ibs=BUFSIZ;
while (totalSize > outTotal) { while (totalSize > outTotal) {
inCc = fullRead(inFd, buf, ibs); inCc = full_read(inFd, buf, ibs);
inTotal += inCc; inTotal += inCc;
if ( (sync==TRUE) && (inCc>0) ) if ( (sync==TRUE) && (inCc>0) )
while (inCc<ibs) while (inCc<ibs)
buf[inCc++]='\0'; buf[inCc++]='\0';
if ((outCc = fullWrite(outFd, buf, inCc)) < 1){ if ((outCc = full_write(outFd, buf, inCc)) < 1){
if (outCc < 0 ){ if (outCc < 0 ){
perror("Error during write"); perror("Error during write");
} }

View File

@ -35,12 +35,12 @@ printf("erik: B\n");
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
num = atoi(argv[i]); num = atoi(argv[i]);
if (num == 0) if (num == 0)
errorMsg("0: illegal VT number\n"); error_msg("0: illegal VT number\n");
else if (num == 1) else if (num == 1)
errorMsg("VT 1 cannot be deallocated\n"); error_msg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) { else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE"); perror("VT_DISALLOCATE");
fatalError("could not deallocate console %d\n", num); error_msg_and_die("could not deallocate console %d\n", num);
} }
} }
printf("erik: C\n"); printf("erik: C\n");

8
df.c
View File

@ -36,7 +36,7 @@ static int df(char *device, const char *mountPoint)
long blocks_percent_used; long blocks_percent_used;
if (statfs(mountPoint, &s) != 0) { if (statfs(mountPoint, &s) != 0) {
perrorMsg("%s", mountPoint); perror_msg("%s", mountPoint);
return FALSE; return FALSE;
} }
@ -75,8 +75,8 @@ extern int df_main(int argc, char **argv)
usage(df_usage); usage(df_usage);
} }
while (argc > 1) { while (argc > 1) {
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) { if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
errorMsg("%s: can't find mount point.\n", argv[1]); error_msg("%s: can't find mount point.\n", argv[1]);
status = EXIT_FAILURE; status = EXIT_FAILURE;
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir)) } else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
status = EXIT_FAILURE; status = EXIT_FAILURE;
@ -89,7 +89,7 @@ extern int df_main(int argc, char **argv)
mountTable = setmntent(mtab_file, "r"); mountTable = setmntent(mtab_file, "r");
if (mountTable == 0) { if (mountTable == 0) {
perrorMsg("%s", mtab_file); perror_msg("%s", mtab_file);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

6
du.c
View File

@ -97,7 +97,7 @@ static long du(char *filename)
} }
if (len + strlen(name) + 1 > BUFSIZ) { if (len + strlen(name) + 1 > BUFSIZ) {
errorMsg(name_too_long); error_msg(name_too_long);
du_depth--; du_depth--;
return 0; return 0;
} }
@ -156,7 +156,7 @@ int du_main(int argc, char **argv)
for (i=optind; i < argc; i++) { for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0) if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE; status = EXIT_FAILURE;
if (sum && isDirectory(argv[i], FALSE, NULL)) { if (sum && is_directory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]); print_normal(sum, argv[i]);
} }
reset_ino_dev_hashtable(); reset_ino_dev_hashtable();
@ -166,7 +166,7 @@ int du_main(int argc, char **argv)
return status; return status;
} }
/* $Id: du.c,v 1.28 2000/12/06 15:56:31 kraai Exp $ */ /* $Id: du.c,v 1.29 2000/12/07 19:56:48 markw Exp $ */
/* /*
Local Variables: Local Variables:
c-file-style: "linux" c-file-style: "linux"

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

View File

@ -35,7 +35,7 @@ extern int dutmp_main(int argc, char **argv)
} else { } else {
file = open(argv[1], O_RDONLY); file = open(argv[1], O_RDONLY);
if (file < 0) { if (file < 0) {
fatalError(io_error, argv[1], strerror(errno)); error_msg_and_die(io_error, argv[1], strerror(errno));
} }
} }

View File

@ -215,14 +215,14 @@ static int get_address(const char *str, int *line, regex_t **regex)
else if (my_str[idx] == '/') { else if (my_str[idx] == '/') {
idx = index_of_next_unescaped_slash(my_str, ++idx); idx = index_of_next_unescaped_slash(my_str, ++idx);
if (idx == -1) if (idx == -1)
fatalError("unterminated match expression\n"); error_msg_and_die("unterminated match expression\n");
my_str[idx] = '\0'; my_str[idx] = '\0';
*regex = (regex_t *)xmalloc(sizeof(regex_t)); *regex = (regex_t *)xmalloc(sizeof(regex_t));
xregcomp(*regex, my_str+1, 0); xregcomp(*regex, my_str+1, 0);
idx++; /* so it points to the next character after the last '/' */ idx++; /* so it points to the next character after the last '/' */
} }
else { else {
errorMsg("get_address: no address found in string\n" error_msg("get_address: no address found in string\n"
"\t(you probably didn't check the string you passed me)\n"); "\t(you probably didn't check the string you passed me)\n");
idx = -1; idx = -1;
} }
@ -258,13 +258,13 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr)
/* verify that the 's' is followed by a 'slash' */ /* verify that the 's' is followed by a 'slash' */
if (substr[++idx] != '/') if (substr[++idx] != '/')
fatalError("bad format in substitution expression\n"); error_msg_and_die("bad format in substitution expression\n");
/* save the match string */ /* save the match string */
oldidx = idx+1; oldidx = idx+1;
idx = index_of_next_unescaped_slash(substr, ++idx); idx = index_of_next_unescaped_slash(substr, ++idx);
if (idx == -1) if (idx == -1)
fatalError("bad format in substitution expression\n"); error_msg_and_die("bad format in substitution expression\n");
match = strdup_substr(substr, oldidx, idx); match = strdup_substr(substr, oldidx, idx);
/* determine the number of back references in the match string */ /* determine the number of back references in the match string */
@ -283,7 +283,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr)
oldidx = idx+1; oldidx = idx+1;
idx = index_of_next_unescaped_slash(substr, ++idx); idx = index_of_next_unescaped_slash(substr, ++idx);
if (idx == -1) if (idx == -1)
fatalError("bad format in substitution expression\n"); error_msg_and_die("bad format in substitution expression\n");
sed_cmd->replace = strdup_substr(substr, oldidx, idx); sed_cmd->replace = strdup_substr(substr, oldidx, idx);
/* process the flags */ /* process the flags */
@ -303,7 +303,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr)
if (strchr("; \t\v\n\r", substr[idx])) if (strchr("; \t\v\n\r", substr[idx]))
goto out; goto out;
/* else */ /* else */
fatalError("bad option in substitution expression\n"); error_msg_and_die("bad option in substitution expression\n");
} }
} }
@ -345,7 +345,7 @@ static int parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr)
*/ */
if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r')) if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r'))
fatalError("bad format in edit expression\n"); error_msg_and_die("bad format in edit expression\n");
/* store the edit line text */ /* store the edit line text */
/* make editline big enough to accomodate the extra '\n' we will tack on /* make editline big enough to accomodate the extra '\n' we will tack on
@ -409,9 +409,9 @@ static char *parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr)
/* last part (mandatory) will be a command */ /* last part (mandatory) will be a command */
if (cmdstr[idx] == '\0') if (cmdstr[idx] == '\0')
fatalError("missing command\n"); error_msg_and_die("missing command\n");
if (!strchr("pdsaic", cmdstr[idx])) /* <-- XXX add new commands here */ if (!strchr("pdsaic", cmdstr[idx])) /* <-- XXX add new commands here */
fatalError("invalid command\n"); error_msg_and_die("invalid command\n");
sed_cmd->cmd = cmdstr[idx]; sed_cmd->cmd = cmdstr[idx];
/* special-case handling for (s)ubstitution */ /* special-case handling for (s)ubstitution */
@ -421,7 +421,7 @@ static char *parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr)
/* special-case handling for (a)ppend, (i)nsert, and (c)hange */ /* special-case handling for (a)ppend, (i)nsert, and (c)hange */
else if (strchr("aic", cmdstr[idx])) { else if (strchr("aic", cmdstr[idx])) {
if (sed_cmd->end_line || sed_cmd->end_match) if (sed_cmd->end_line || sed_cmd->end_match)
fatalError("only a beginning address can be specified for edit commands\n"); error_msg_and_die("only a beginning address can be specified for edit commands\n");
idx += parse_edit_cmd(sed_cmd, &cmdstr[idx]); idx += parse_edit_cmd(sed_cmd, &cmdstr[idx]);
} }
/* if it was a single-letter command (such as 'p' or 'd') we need to /* if it was a single-letter command (such as 'p' or 'd') we need to
@ -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) {
errorMsg("%s: %s\n", argv[i], strerror(errno)); error_msg("%s: %s\n", argv[i], strerror(errno));
} else { } else {
process_file(file); process_file(file);
fclose(file); fclose(file);

20
expr.c
View File

@ -74,14 +74,14 @@ int expr_main (int argc, char **argv)
VALUE *v; VALUE *v;
if (argc == 1) { if (argc == 1) {
fatalError("too few arguments\n"); error_msg_and_die("too few arguments\n");
} }
args = argv + 1; args = argv + 1;
v = eval (); v = eval ();
if (*args) if (*args)
fatalError ("syntax error\n"); error_msg_and_die ("syntax error\n");
if (v->type == integer) if (v->type == integer)
printf ("%d\n", v->u.i); printf ("%d\n", v->u.i);
@ -216,7 +216,7 @@ static \
int name (l, r) VALUE *l; VALUE *r; \ int name (l, r) VALUE *l; VALUE *r; \
{ \ { \
if (!toarith (l) || !toarith (r)) \ if (!toarith (l) || !toarith (r)) \
fatalError ("non-numeric argument\n"); \ error_msg_and_die ("non-numeric argument\n"); \
return l->u.i op r->u.i; \ return l->u.i op r->u.i; \
} }
@ -224,9 +224,9 @@ int name (l, r) VALUE *l; VALUE *r; \
int name (l, r) VALUE *l; VALUE *r; \ int name (l, r) VALUE *l; VALUE *r; \
{ \ { \
if (!toarith (l) || !toarith (r)) \ if (!toarith (l) || !toarith (r)) \
fatalError ( "non-numeric argument\n"); \ error_msg_and_die ( "non-numeric argument\n"); \
if (r->u.i == 0) \ if (r->u.i == 0) \
fatalError ( "division by zero\n"); \ error_msg_and_die ( "division by zero\n"); \
return l->u.i op r->u.i; \ return l->u.i op r->u.i; \
} }
@ -270,7 +270,7 @@ of a basic regular expression is not portable; it is being ignored",
re_syntax_options = RE_SYNTAX_POSIX_BASIC; re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer); errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) { if (errmsg) {
fatalError("%s\n", errmsg); error_msg_and_die("%s\n", errmsg);
} }
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs); len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
@ -301,19 +301,19 @@ static VALUE *eval7 (void)
VALUE *v; VALUE *v;
if (!*args) if (!*args)
fatalError ( "syntax error\n"); error_msg_and_die ( "syntax error\n");
if (nextarg ("(")) { if (nextarg ("(")) {
args++; args++;
v = eval (); v = eval ();
if (!nextarg (")")) if (!nextarg (")"))
fatalError ( "syntax error\n"); error_msg_and_die ( "syntax error\n");
args++; args++;
return v; return v;
} }
if (nextarg (")")) if (nextarg (")"))
fatalError ( "syntax error\n"); error_msg_and_die ( "syntax error\n");
return str_value (*args++); return str_value (*args++);
} }
@ -327,7 +327,7 @@ static VALUE *eval6 (void)
if (nextarg ("quote")) { if (nextarg ("quote")) {
args++; args++;
if (!*args) if (!*args)
fatalError ( "syntax error\n"); error_msg_and_die ( "syntax error\n");
return str_value (*args++); return str_value (*args++);
} }
else if (nextarg ("length")) { else if (nextarg ("length")) {

View File

@ -283,7 +283,7 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn,
} }
} }
#else #else
errorMsg( "mode reading not compiled in\n"); error_msg( "mode reading not compiled in\n");
#endif #endif
return 0; return 0;
} }
@ -433,7 +433,7 @@ extern int fbset_main(int argc, char **argv)
PERROR("fbset(ioctl)"); PERROR("fbset(ioctl)");
if (g_options & OPT_READMODE) { if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) { if (!readmode(&var, modefile, mode)) {
errorMsg("Unknown video mode `%s'\n", mode); error_msg("Unknown video mode `%s'\n", mode);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} }

2
find.c
View File

@ -98,7 +98,7 @@ int find_main(int argc, char **argv)
break; break;
} }
if (recursiveAction(directory, TRUE, FALSE, FALSE, if (recursive_action(directory, TRUE, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) { fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -98,7 +98,7 @@ int find_main(int argc, char **argv)
break; break;
} }
if (recursiveAction(directory, TRUE, FALSE, FALSE, if (recursive_action(directory, TRUE, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) { fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }

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)
errorMsg("%s: %s\n", cur_file, strerror(errno)); error_msg("%s: %s\n", cur_file, strerror(errno));
} }
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) {
fatalError( "cannot open %s: %s\n", argv[1], strerror(errno)); error_msg_and_die( "cannot open %s: %s\n", argv[1], strerror(errno));
} }
if (ioctl(f, BLKFLSBUF) < 0) { if (ioctl(f, BLKFLSBUF) < 0) {
fatalError( "failed ioctl on %s: %s\n", argv[1], strerror(errno)); error_msg_and_die( "failed ioctl on %s: %s\n", argv[1], strerror(errno));
} }
/* 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

@ -296,7 +296,7 @@ static void show_usage(void)
static void die(const char *str) static void die(const char *str)
{ {
errorMsg("%s\n", str); error_msg("%s\n", str);
leave(8); leave(8);
} }

View File

@ -37,7 +37,7 @@
* <misiek@misiek.eu.org>) * <misiek@misiek.eu.org>)
* Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org> * Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org>
* Removed --version/-V and --help/-h in * Removed --version/-V and --help/-h in
* Removed prase_error(), using errorMsg() from Busybox instead * Removed prase_error(), using error_msg() from Busybox instead
* Replaced our_malloc with xmalloc and our_realloc with xrealloc * Replaced our_malloc with xmalloc and our_realloc with xrealloc
* *
*/ */
@ -258,7 +258,7 @@ void add_long_options(char *options)
arg_opt=required_argument; arg_opt=required_argument;
} }
if (strlen(tokptr) == 0) if (strlen(tokptr) == 0)
errorMsg("empty long option after -l or --long argument\n"); error_msg("empty long option after -l or --long argument\n");
} }
add_longopt(tokptr,arg_opt); add_longopt(tokptr,arg_opt);
} }
@ -277,7 +277,7 @@ void set_shell(const char *new_shell)
else if (!strcmp(new_shell,"csh")) else if (!strcmp(new_shell,"csh"))
shell=TCSH; shell=TCSH;
else else
errorMsg("unknown shell after -s or --shell argument\n"); error_msg("unknown shell after -s or --shell argument\n");
} }
@ -326,7 +326,7 @@ int getopt_main(int argc, char *argv[])
printf(" --\n"); printf(" --\n");
exit(0); exit(0);
} else } else
fatalError("missing optstring argument\n"); error_msg_and_die("missing optstring argument\n");
} }
if (argv[1][0] != '-' || compatible) { if (argv[1][0] != '-' || compatible) {
@ -377,7 +377,7 @@ int getopt_main(int argc, char *argv[])
if (!optstr) { if (!optstr) {
if (optind >= argc) if (optind >= argc)
fatalError("missing optstring argument\n"); error_msg_and_die("missing optstring argument\n");
else { else {
optstr=xmalloc(strlen(argv[optind])+1); optstr=xmalloc(strlen(argv[optind])+1);
strcpy(optstr,argv[optind]); strcpy(optstr,argv[optind]);

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

View File

@ -113,7 +113,7 @@ static char *license_msg[] = {
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG #ifdef DEBUG
# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} # define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
# define Trace(x) fprintf x # define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;} # define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;} # define Tracevv(x) {if (verbose>1) fprintf x ;}
@ -297,7 +297,7 @@ int in; /* input file descriptor */
method = (int) get_byte(); method = (int) get_byte();
if (method != DEFLATED) { if (method != DEFLATED) {
errorMsg("unknown method %d -- get newer version of gzip\n", method); error_msg("unknown method %d -- get newer version of gzip\n", method);
exit_code = ERROR; exit_code = ERROR;
return -1; return -1;
} }
@ -1114,13 +1114,13 @@ int in, out; /* input and output file descriptors */
int res = inflate(); int res = inflate();
if (res == 3) { if (res == 3) {
errorMsg(memory_exhausted); error_msg(memory_exhausted);
} else if (res != 0) { } else if (res != 0) {
errorMsg("invalid compressed data--format violated\n"); error_msg("invalid compressed data--format violated\n");
} }
} else { } else {
errorMsg("internal error, invalid method\n"); error_msg("internal error, invalid method\n");
} }
/* Get the crc and original length */ /* Get the crc and original length */
@ -1149,10 +1149,10 @@ int in, out; /* input and output file descriptors */
/* Validate decompression */ /* Validate decompression */
if (orig_crc != updcrc(outbuf, 0)) { if (orig_crc != updcrc(outbuf, 0)) {
errorMsg("invalid compressed data--crc error\n"); error_msg("invalid compressed data--crc error\n");
} }
if (orig_len != (ulg) bytes_out) { if (orig_len != (ulg) bytes_out) {
errorMsg("invalid compressed data--length error\n"); error_msg("invalid compressed data--length error\n");
} }
/* Check if there are more entries in a pkzip file */ /* Check if there are more entries in a pkzip file */
@ -1225,9 +1225,9 @@ int gunzip_main(int argc, char **argv)
} }
if (isatty(fileno(stdin)) && fromstdin==1 && force==0) if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
fatalError( "data not read from terminal. Use -f to force it.\n"); error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0) if (isatty(fileno(stdout)) && tostdout==1 && force==0)
fatalError( "data not written to terminal. Use -f to force it.\n"); error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
@ -1265,7 +1265,7 @@ int gunzip_main(int argc, char **argv)
if (argc <= 0) if (argc <= 0)
usage(gunzip_usage); usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) { if (strlen(*argv) > MAX_PATH_LEN) {
errorMsg(name_too_long); error_msg(name_too_long);
exit(WARNING); exit(WARNING);
} }
strcpy(ifname, *argv); strcpy(ifname, *argv);
@ -1304,7 +1304,7 @@ int gunzip_main(int argc, char **argv)
/* And get to work */ /* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) { if (strlen(ifname) > MAX_PATH_LEN - 4) {
errorMsg(name_too_long); error_msg(name_too_long);
exit(WARNING); exit(WARNING);
} }
strcpy(ofname, ifname); strcpy(ofname, ifname);

18
gzip.c
View File

@ -114,7 +114,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array # define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \ # define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
if (array == NULL) errorMsg(memory_exhausted); \ if (array == NULL) error_msg(memory_exhausted); \
} }
# define FREE(array) {if (array != NULL) free(array), array=NULL;} # define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else #else
@ -251,7 +251,7 @@ extern int save_orig_name; /* set if original name must be saved */
/* Diagnostic functions */ /* Diagnostic functions */
#ifdef DEBUG #ifdef DEBUG
# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);} # define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
# define Trace(x) fprintf x # define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;} # define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;} # define Tracevv(x) {if (verbose>1) fprintf x ;}
@ -1381,7 +1381,7 @@ int length;
(char *) window + start, length) != EQUAL) { (char *) window + start, length) != EQUAL) {
fprintf(stderr, fprintf(stderr,
" start %d, match %d, length %d\n", start, match, length); " start %d, match %d, length %d\n", start, match, length);
errorMsg("invalid match\n"); error_msg("invalid match\n");
} }
if (verbose > 1) { if (verbose > 1) {
fprintf(stderr, "\\[%d,%d]", start - match, length); fprintf(stderr, "\\[%d,%d]", start - match, length);
@ -1819,9 +1819,9 @@ int gzip_main(int argc, char **argv)
} }
if (isatty(fileno(stdin)) && fromstdin==1 && force==0) if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
fatalError( "data not read from terminal. Use -f to force it.\n"); error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
if (isatty(fileno(stdout)) && tostdout==1 && force==0) if (isatty(fileno(stdout)) && tostdout==1 && force==0)
fatalError( "data not written to terminal. Use -f to force it.\n"); error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN; foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) { if (foreground) {
@ -2900,7 +2900,7 @@ int eof; /* true if this is the last block for a file */
#endif #endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0) if (buf == (char *) 0)
errorMsg("block vanished\n"); error_msg("block vanished\n");
copy_block(buf, (unsigned) stored_len, 0); /* without header */ copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3; compressed_len = stored_len << 3;
@ -3083,7 +3083,7 @@ local void set_file_type()
bin_freq += dyn_ltree[n++].Freq; bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII; *file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
if (*file_type == BINARY && translate_eol) { if (*file_type == BINARY && translate_eol) {
errorMsg("-l used on binary file\n"); error_msg("-l used on binary file\n");
} }
} }
@ -3239,13 +3239,13 @@ char *env; /* name of environment variable */
nargv = (char **) calloc(*argcp + 1, sizeof(char *)); nargv = (char **) calloc(*argcp + 1, sizeof(char *));
if (nargv == NULL) if (nargv == NULL)
errorMsg(memory_exhausted); error_msg(memory_exhausted);
oargv = *argvp; oargv = *argvp;
*argvp = nargv; *argvp = nargv;
/* Copy the program name first */ /* Copy the program name first */
if (oargc-- < 0) if (oargc-- < 0)
errorMsg("argc<=0\n"); error_msg("argc<=0\n");
*(nargv++) = *(oargv++); *(nargv++) = *(oargv++);
/* Then copy the environment args */ /* Then copy the environment args */

2
halt.c
View File

@ -28,7 +28,7 @@ extern int halt_main(int argc, char **argv)
{ {
#ifdef BB_FEATURE_LINUXRC #ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */ /* don't assume init's pid == 1 */
return(kill(*(findPidByName("init")), SIGUSR1)); return(kill(*(find_pid_by_name("init")), SIGUSR1));
#else #else
return(kill(1, SIGUSR1)); return(kill(1, SIGUSR1));
#endif #endif

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) {
errorMsg("%s: %s\n", argv[optind], strerror(errno)); error_msg("%s: %s\n", argv[optind], strerror(errno));
status = EXIT_FAILURE; status = EXIT_FAILURE;
errno = 0; errno = 0;
} }

View File

@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */ /* vi: set sw=4 ts=4: */
/* /*
* $Id: hostname.c,v 1.15 2000/10/12 22:30:31 andersen Exp $ * $Id: hostname.c,v 1.16 2000/12/07 19:56:48 markw Exp $
* Mini hostname implementation for busybox * Mini hostname implementation for busybox
* *
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org> * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@ -40,7 +40,7 @@ void do_sethostname(char *s, int isfile)
if (!isfile) { if (!isfile) {
if (sethostname(s, strlen(s)) < 0) { if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM) if (errno == EPERM)
errorMsg("you must be root to change the hostname\n"); error_msg("you must be root to change the hostname\n");
else else
perror("sethostname"); perror("sethostname");
exit(1); exit(1);

2
id.c
View File

@ -78,7 +78,7 @@ extern int id_main(int argc, char **argv)
pwnam=my_getpwnam(user); pwnam=my_getpwnam(user);
grnam=my_getgrnam(group); grnam=my_getgrnam(group);
if (gid == -1 || pwnam==-1 || grnam==-1) { if (gid == -1 || pwnam==-1 || grnam==-1) {
fatalError("%s: No such user\n", user); error_msg_and_die("%s: No such user\n", user);
} }
if (no_group) if (no_group)
printf("%ld\n", pwnam); printf("%ld\n", pwnam);

View File

@ -55,8 +55,8 @@
#define BUF_SIZE 8192 #define BUF_SIZE 8192
#define EXPAND_ALLOC 1024 #define EXPAND_ALLOC 1024
static inline int isDecimal(ch) { return ((ch >= '0') && (ch <= '9')); } static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
static inline int isOctal(ch) { return ((ch >= '0') && (ch <= '7')); } static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
/* Macros for min/max. */ /* Macros for min/max. */
#ifndef MIN #ifndef MIN
@ -119,14 +119,14 @@ extern const char *applet_name;
extern int applet_name_compare(const void *x, const void *y); extern int applet_name_compare(const void *x, const void *y);
extern void usage(const char *usage) __attribute__ ((noreturn)); extern void usage(const char *usage) __attribute__ ((noreturn));
extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void perrorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatalPerror(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
const char *modeString(int mode); const char *mode_string(int mode);
const char *timeString(time_t timeVal); const char *time_string(time_t timeVal);
int isDirectory(const char *name, const int followLinks, struct stat *statBuf); int is_directory(const char *name, const int followLinks, struct stat *statBuf);
int isDevice(const char *name); int isDevice(const char *name);
typedef struct ino_dev_hash_bucket_struct { typedef struct ino_dev_hash_bucket_struct {
@ -139,7 +139,7 @@ int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name); void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
void reset_ino_dev_hashtable(void); void reset_ino_dev_hashtable(void);
int copyFile(const char *srcName, const char *destName, int copy_file(const char *srcName, const char *destName,
int setModes, int followLinks, int forceFlag); int setModes, int followLinks, int forceFlag);
int copy_file_chunk(int srcFd, int dstFd, size_t remaining); int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
char *buildName(const char *dirName, const char *fileName); char *buildName(const char *dirName, const char *fileName);
@ -147,20 +147,20 @@ int makeString(int argc, const char **argv, char *buf, int bufLen);
char *getChunk(int size); char *getChunk(int size);
char *chunkstrdup(const char *str); char *chunkstrdup(const char *str);
void freeChunks(void); void freeChunks(void);
int fullWrite(int fd, const char *buf, int len); int full_write(int fd, const char *buf, int len);
int fullRead(int fd, char *buf, int len); int full_read(int fd, char *buf, int len);
int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst, int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData), int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData), int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
void* userData); void* userData);
extern int createPath (const char *name, int mode); extern int create_path (const char *name, int mode);
extern int parse_mode( const char* s, mode_t* theMode); extern int parse_mode( const char* s, mode_t* theMode);
extern int get_kernel_revision(void); extern int get_kernel_revision(void);
extern int get_console_fd(char* tty_name); extern int get_console_fd(char* tty_name);
extern struct mntent *findMountPoint(const char *name, const char *table); extern struct mntent *find_mount_point(const char *name, const char *table);
extern void write_mtab(char* blockDevice, char* directory, extern void write_mtab(char* blockDevice, char* directory,
char* filesystemType, long flags, char* string_flags); char* filesystemType, long flags, char* string_flags);
extern void erase_mtab(const char * name); extern void erase_mtab(const char * name);
@ -169,8 +169,8 @@ extern char *mtab_first(void **iter);
extern char *mtab_next(void **iter); extern char *mtab_next(void **iter);
extern char *mtab_getinfo(const char *match, const char which); extern char *mtab_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern); extern int check_wildcard_match(const char* text, const char* pattern);
extern long getNum (const char *cp); extern long atoi_w_units (const char *cp);
extern pid_t* findPidByName( char* pidName); extern pid_t* find_pid_by_name( char* pidName);
extern int find_real_root_device_name(char* name); extern int find_real_root_device_name(char* name);
extern char *get_line_from_file(FILE *file); extern char *get_line_from_file(FILE *file);
extern void print_file(FILE *file); extern void print_file(FILE *file);

2
init.c
View File

@ -296,7 +296,7 @@ static int check_free_memory()
unsigned int result, u, s=10; unsigned int result, u, s=10;
if (sysinfo(&info) != 0) { if (sysinfo(&info) != 0) {
perrorMsg("Error checking free memory: "); perror_msg("Error checking free memory: ");
return -1; return -1;
} }

View File

@ -28,7 +28,7 @@ extern int halt_main(int argc, char **argv)
{ {
#ifdef BB_FEATURE_LINUXRC #ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */ /* don't assume init's pid == 1 */
return(kill(*(findPidByName("init")), SIGUSR1)); return(kill(*(find_pid_by_name("init")), SIGUSR1));
#else #else
return(kill(1, SIGUSR1)); return(kill(1, SIGUSR1));
#endif #endif

View File

@ -296,7 +296,7 @@ static int check_free_memory()
unsigned int result, u, s=10; unsigned int result, u, s=10;
if (sysinfo(&info) != 0) { if (sysinfo(&info) != 0) {
perrorMsg("Error checking free memory: "); perror_msg("Error checking free memory: ");
return -1; return -1;
} }

View File

@ -28,7 +28,7 @@ extern int poweroff_main(int argc, char **argv)
{ {
#ifdef BB_FEATURE_LINUXRC #ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */ /* don't assume init's pid == 1 */
return(kill(*(findPidByName("init")), SIGUSR2)); return(kill(*(find_pid_by_name("init")), SIGUSR2));
#else #else
return(kill(1, SIGUSR2)); return(kill(1, SIGUSR2));
#endif #endif

View File

@ -28,7 +28,7 @@ extern int reboot_main(int argc, char **argv)
{ {
#ifdef BB_FEATURE_LINUXRC #ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */ /* don't assume init's pid == 1 */
return(kill(*(findPidByName("init")), SIGINT)); return(kill(*(find_pid_by_name("init")), SIGINT));
#else #else
return(kill(1, SIGINT)); return(kill(1, SIGINT));
#endif #endif

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.30 2000/12/06 18:18:26 andersen Exp $" #ident "$Id: insmod.c,v 1.31 2000/12/07 19:56:48 markw 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.30 2000/12/06 18:18:26 andersen Exp $" #ident "$Id: insmod.c,v 1.31 2000/12/07 19:56:48 markw Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */
@ -1157,7 +1157,7 @@ struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name,
/* Don't report an error if the symbol is coming from /* Don't report an error if the symbol is coming from
the kernel or some external module. */ the kernel or some external module. */
if (secidx <= SHN_HIRESERVE) if (secidx <= SHN_HIRESERVE)
errorMsg("%s multiply defined\n", name); error_msg("%s multiply defined\n", name);
return sym; return sym;
} }
} }
@ -1420,7 +1420,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Also check that the parameter was not resolved from the kernel. */ /* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) { if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
errorMsg("symbol for parameter %s not found\n", p); error_msg("symbol for parameter %s not found\n", p);
return 0; return 0;
} }
@ -1433,7 +1433,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q)); str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) { for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') { if (*q == '\0') {
errorMsg("improperly terminated string argument for %s\n", p); error_msg("improperly terminated string argument for %s\n", p);
return 0; return 0;
} else if (*q == '\\') } else if (*q == '\\')
switch (*++q) { switch (*++q) {
@ -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) {
errorMsg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno));
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)
errorMsg("init_module: %s: %s\n", m_name, strerror(errno)); error_msg("init_module: %s: %s\n", m_name, strerror(errno));
free(image); free(image);
free(symtab); free(symtab);
@ -1786,7 +1786,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
p = get_modinfo_value(f, key); p = get_modinfo_value(f, key);
key += 5; key += 5;
if (p == NULL) { if (p == NULL) {
errorMsg("invalid parameter %s\n", key); error_msg("invalid parameter %s\n", key);
return 0; return 0;
} }
@ -1794,7 +1794,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Also check that the parameter was not resolved from the kernel. */ /* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) { if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
errorMsg("symbol for parameter %s not found\n", key); error_msg("symbol for parameter %s not found\n", key);
return 0; return 0;
} }
@ -1822,7 +1822,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q)); str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) { for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') { if (*q == '\0') {
errorMsg("improperly terminated string argument for %s\n", error_msg("improperly terminated string argument for %s\n",
key); key);
return 0; return 0;
} else if (*q == '\\') } else if (*q == '\\')
@ -1916,7 +1916,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Get the size of each member */ /* Get the size of each member */
/* Probably we should do that outside the loop ? */ /* Probably we should do that outside the loop ? */
if (!isdigit(*(p + 1))) { if (!isdigit(*(p + 1))) {
errorMsg("parameter type 'c' for %s must be followed by" error_msg("parameter type 'c' for %s must be followed by"
" the maximum size\n", key); " the maximum size\n", key);
return 0; return 0;
} }
@ -1924,7 +1924,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Check length */ /* Check length */
if (strlen(str) >= charssize) { if (strlen(str) >= charssize) {
errorMsg("string too long for %s (max %ld)\n", key, error_msg("string too long for %s (max %ld)\n", key,
charssize - 1); charssize - 1);
return 0; return 0;
} }
@ -1953,7 +1953,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
break; break;
default: default:
errorMsg("unknown parameter type '%c' for %s\n", *p, key); error_msg("unknown parameter type '%c' for %s\n", *p, key);
return 0; return 0;
} }
} }
@ -1972,21 +1972,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
case ',': case ',':
if (++n > max) { if (++n > max) {
errorMsg("too many values for %s (max %d)\n", key, max); error_msg("too many values for %s (max %d)\n", key, max);
return 0; return 0;
} }
++q; ++q;
break; break;
default: default:
errorMsg("invalid argument syntax for %s\n", key); error_msg("invalid argument syntax for %s\n", key);
return 0; return 0;
} }
} }
end_of_arg: end_of_arg:
if (n < min) { if (n < min) {
errorMsg("too few values for %s (min %d)\n", key, min); error_msg("too few values for %s (min %d)\n", key, min);
return 0; return 0;
} }
@ -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;
} }
errorMsg("QM_MODULES: %s\n", strerror(errno)); error_msg("QM_MODULES: %s\n", strerror(errno));
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;
} }
errorMsg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno));
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:
errorMsg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno));
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;
} }
errorMsg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
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)
errorMsg("init_module: %s: %s\n", m_name, strerror(errno)); error_msg("init_module: %s: %s\n", m_name, strerror(errno));
free(image); free(image);
@ -2372,7 +2372,7 @@ int obj_check_undefineds(struct obj_file *f)
sym->secidx = SHN_ABS; sym->secidx = SHN_ABS;
sym->value = 0; sym->value = 0;
} else { } else {
errorMsg("unresolved symbol %s\n", sym->name); error_msg("unresolved symbol %s\n", sym->name);
ret = 0; ret = 0;
} }
} }
@ -2599,11 +2599,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base)
errmsg = "Unhandled relocation"; errmsg = "Unhandled relocation";
bad_reloc: bad_reloc:
if (extsym) { if (extsym) {
errorMsg("%s of type %ld for %s\n", errmsg, error_msg("%s of type %ld for %s\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info), (long) ELFW(R_TYPE) (rel->r_info),
strtab + extsym->st_name); strtab + extsym->st_name);
} else { } else {
errorMsg("%s of type %ld\n", errmsg, error_msg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info)); (long) ELFW(R_TYPE) (rel->r_info));
} }
ret = 0; ret = 0;
@ -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) {
errorMsg("error reading ELF header: %s\n", strerror(errno)); error_msg("error reading ELF header: %s\n", strerror(errno));
return NULL; return NULL;
} }
@ -2688,25 +2688,25 @@ struct obj_file *obj_load(FILE * fp)
|| f->header.e_ident[EI_MAG1] != ELFMAG1 || f->header.e_ident[EI_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2 || f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) { || f->header.e_ident[EI_MAG3] != ELFMAG3) {
errorMsg("not an ELF file\n"); error_msg("not an ELF file\n");
return NULL; return NULL;
} }
if (f->header.e_ident[EI_CLASS] != ELFCLASSM if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM || f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT || f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) { || !MATCH_MACHINE(f->header.e_machine)) {
errorMsg("ELF file not for this architecture\n"); error_msg("ELF file not for this architecture\n");
return NULL; return NULL;
} }
if (f->header.e_type != ET_REL) { if (f->header.e_type != ET_REL) {
errorMsg("ELF file not a relocatable object\n"); error_msg("ELF file not a relocatable object\n");
return NULL; return NULL;
} }
/* Read the section headers. */ /* Read the section headers. */
if (f->header.e_shentsize != sizeof(ElfW(Shdr))) { if (f->header.e_shentsize != sizeof(ElfW(Shdr))) {
errorMsg("section header size mismatch: %lu != %lu\n", error_msg("section header size mismatch: %lu != %lu\n",
(unsigned long) f->header.e_shentsize, (unsigned long) f->header.e_shentsize,
(unsigned long) sizeof(ElfW(Shdr))); (unsigned long) sizeof(ElfW(Shdr)));
return NULL; return NULL;
@ -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) {
errorMsg("error reading ELF section headers: %s\n", strerror(errno)); error_msg("error reading ELF section headers: %s\n", strerror(errno));
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) {
errorMsg("error reading ELF section data: %s\n", strerror(errno)); error_msg("error reading ELF section data: %s\n", strerror(errno));
return NULL; return NULL;
} }
} else { } else {
@ -2759,11 +2759,11 @@ struct obj_file *obj_load(FILE * fp)
#if SHT_RELM == SHT_REL #if SHT_RELM == SHT_REL
case SHT_RELA: case SHT_RELA:
errorMsg("RELA relocations not supported on this architecture\n"); error_msg("RELA relocations not supported on this architecture\n");
return NULL; return NULL;
#else #else
case SHT_REL: case SHT_REL:
errorMsg("REL relocations not supported on this architecture\n"); error_msg("REL relocations not supported on this architecture\n");
return NULL; return NULL;
#endif #endif
@ -2776,7 +2776,7 @@ struct obj_file *obj_load(FILE * fp)
break; break;
} }
errorMsg("can't handle sections of type %ld\n", error_msg("can't handle sections of type %ld\n",
(long) sec->header.sh_type); (long) sec->header.sh_type);
return NULL; return NULL;
} }
@ -2805,7 +2805,7 @@ struct obj_file *obj_load(FILE * fp)
ElfW(Sym) * sym; ElfW(Sym) * sym;
if (sec->header.sh_entsize != sizeof(ElfW(Sym))) { if (sec->header.sh_entsize != sizeof(ElfW(Sym))) {
errorMsg("symbol size mismatch: %lu != %lu\n", error_msg("symbol size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize, (unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(Sym))); (unsigned long) sizeof(ElfW(Sym)));
return NULL; return NULL;
@ -2837,7 +2837,7 @@ struct obj_file *obj_load(FILE * fp)
case SHT_RELM: case SHT_RELM:
if (sec->header.sh_entsize != sizeof(ElfW(RelM))) { if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
errorMsg("relocation entry size mismatch: %lu != %lu\n", error_msg("relocation entry size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize, (unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(RelM))); (unsigned long) sizeof(ElfW(RelM)));
return NULL; return NULL;
@ -2937,17 +2937,17 @@ extern int insmod_main( int argc, char **argv)
/* Get a filedesc for the module */ /* Get a filedesc for the module */
if ((fp = fopen(*argv, "r")) == NULL) { if ((fp = fopen(*argv, "r")) == NULL) {
/* Hmpf. Could not open it. Search through _PATH_MODULES to find a module named m_name */ /* Hmpf. Could not open it. Search through _PATH_MODULES to find a module named m_name */
if (recursiveAction(_PATH_MODULES, TRUE, FALSE, FALSE, if (recursive_action(_PATH_MODULES, TRUE, FALSE, FALSE,
findNamedModule, 0, m_fullName) == FALSE) findNamedModule, 0, m_fullName) == FALSE)
{ {
if (m_filename[0] == '\0' if (m_filename[0] == '\0'
|| ((fp = fopen(m_filename, "r")) == NULL)) || ((fp = fopen(m_filename, "r")) == NULL))
{ {
errorMsg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES); error_msg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} else } else
fatalError("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES); error_msg_and_die("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
} else } else
memcpy(m_filename, *argv, strlen(*argv)); memcpy(m_filename, *argv, strlen(*argv));
@ -2971,7 +2971,7 @@ extern int insmod_main( int argc, char **argv)
} else { } else {
m_version = old_get_module_version(f, m_strversion); m_version = old_get_module_version(f, m_strversion);
if (m_version == -1) { if (m_version == -1) {
errorMsg("couldn't find the kernel version the module was " error_msg("couldn't find the kernel version the module was "
"compiled for\n"); "compiled for\n");
goto out; goto out;
} }
@ -2979,12 +2979,12 @@ extern int insmod_main( int argc, char **argv)
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) { if (flag_force_load) {
errorMsg("Warning: kernel-module version mismatch\n" error_msg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n" "\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s\n", "\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion); m_filename, m_strversion, k_strversion);
} else { } else {
errorMsg("kernel-module version mismatch\n" error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n" "\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n", "\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion); m_filename, m_strversion, k_strversion);
@ -3002,7 +3002,7 @@ extern int insmod_main( int argc, char **argv)
goto out; goto out;
k_crcs = new_is_kernel_checksummed(); k_crcs = new_is_kernel_checksummed();
#else #else
errorMsg("Not configured to support new kernels\n"); error_msg("Not configured to support new kernels\n");
goto out; goto out;
#endif #endif
} else { } else {
@ -3011,7 +3011,7 @@ extern int insmod_main( int argc, char **argv)
goto out; goto out;
k_crcs = old_is_kernel_checksummed(); k_crcs = old_is_kernel_checksummed();
#else #else
errorMsg("Not configured to support old kernels\n"); error_msg("Not configured to support old kernels\n");
goto out; goto out;
#endif #endif
} }
@ -3068,14 +3068,14 @@ extern int insmod_main( int argc, char **argv)
case 0: case 0:
break; break;
case EEXIST: case EEXIST:
errorMsg("A module named %s already exists\n", m_name); error_msg("A module named %s already exists\n", m_name);
goto out; goto out;
case ENOMEM: case ENOMEM:
errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n", error_msg("Can't allocate kernel memory for module; needed %lu bytes\n",
m_size); m_size);
goto out; goto out;
default: default:
errorMsg("create_module: %s: %s\n", m_name, strerror(errno)); error_msg("create_module: %s: %s\n", m_name, strerror(errno));
goto out; goto out;
} }

14
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))
fatalError( "Bad PID: %s\n", strerror(errno)); error_msg_and_die( "Bad PID: %s\n", strerror(errno));
pid = strtol(*argv, NULL, 0); pid = strtol(*argv, NULL, 0);
if (kill(pid, sig) != 0) if (kill(pid, sig) != 0)
fatalError( "Could not kill pid '%d': %s\n", pid, strerror(errno)); error_msg_and_die( "Could not kill pid '%d': %s\n", pid, strerror(errno));
argv++; argv++;
} }
} }
@ -219,20 +219,20 @@ extern int kill_main(int argc, char **argv)
while (--argc >= 0) { while (--argc >= 0) {
pid_t* pidList; pid_t* pidList;
pidList = findPidByName( *argv); pidList = find_pid_by_name( *argv);
if (!pidList) { if (!pidList) {
all_found = FALSE; all_found = FALSE;
errorMsg( "%s: no process killed\n", *argv); error_msg( "%s: no process killed\n", *argv);
} }
for(; pidList && *pidList!=0; pidList++) { for(; pidList && *pidList!=0; pidList++) {
if (*pidList==myPid) if (*pidList==myPid)
continue; continue;
if (kill(*pidList, sig) != 0) if (kill(*pidList, sig) != 0)
fatalError( "Could not kill pid '%d': %s\n", *pidList, strerror(errno)); error_msg_and_die( "Could not kill pid '%d': %s\n", *pidList, strerror(errno));
} }
/* Note that we don't bother to free the memory /* Note that we don't bother to free the memory
* allocated in findPidByName(). It will be freed * allocated in find_pid_by_name(). It will be freed
* upon exit, so we can save a byte or two */ * upon exit, so we can save a byte or two */
argv++; argv++;
} }
@ -245,5 +245,5 @@ extern int kill_main(int argc, char **argv)
end: end:
fatalError( "bad signal name: %s\n", *argv); error_msg_and_die( "bad signal name: %s\n", *argv);
} }

34
lash.c
View File

@ -250,7 +250,7 @@ static int builtin_exec(struct job *cmd, struct jobSet *junk)
{ {
cmd->progs[0].argv++; cmd->progs[0].argv++;
execvp(cmd->progs[0].argv[0], cmd->progs[0].argv); execvp(cmd->progs[0].argv[0], cmd->progs[0].argv);
fatalError("Exec to %s failed: %s\n", cmd->progs[0].argv[0], error_msg_and_die("Exec to %s failed: %s\n", cmd->progs[0].argv[0],
strerror(errno)); strerror(errno));
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -273,12 +273,12 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList)
if (!jobList->head) { if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) { if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
errorMsg("%s: exactly one argument is expected\n", error_msg("%s: exactly one argument is expected\n",
cmd->progs[0].argv[0]); cmd->progs[0].argv[0]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) { if (sscanf(cmd->progs[0].argv[1], "%%%d", &jobNum) != 1) {
errorMsg("%s: bad argument '%s'\n", error_msg("%s: bad argument '%s'\n",
cmd->progs[0].argv[0], cmd->progs[0].argv[1]); cmd->progs[0].argv[0], cmd->progs[0].argv[1]);
return EXIT_FAILURE; return EXIT_FAILURE;
for (job = jobList->head; job; job = job->next) { for (job = jobList->head; job; job = job->next) {
@ -292,7 +292,7 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList)
} }
if (!job) { if (!job) {
errorMsg("%s: unknown job %d\n", error_msg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum); cmd->progs[0].argv[0], jobNum);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -444,7 +444,7 @@ static int builtin_then(struct job *cmd, struct jobSet *junk)
char* charptr1=cmd->text+5; /* skip over the leading 'then ' */ char* charptr1=cmd->text+5; /* skip over the leading 'then ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) { if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
errorMsg("unexpected token `then'\n"); error_msg("unexpected token `then'\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/* If the if result was FALSE, skip the 'then' stuff */ /* If the if result was FALSE, skip the 'then' stuff */
@ -471,7 +471,7 @@ static int builtin_else(struct job *cmd, struct jobSet *junk)
char* charptr1=cmd->text+5; /* skip over the leading 'else ' */ char* charptr1=cmd->text+5; /* skip over the leading 'else ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) { if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
errorMsg("unexpected token `else'\n"); error_msg("unexpected token `else'\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/* If the if result was TRUE, skip the 'else' stuff */ /* If the if result was TRUE, skip the 'else' stuff */
@ -495,7 +495,7 @@ static int builtin_else(struct job *cmd, struct jobSet *junk)
static int builtin_fi(struct job *cmd, struct jobSet *junk) static int builtin_fi(struct job *cmd, struct jobSet *junk)
{ {
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) { if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
errorMsg("unexpected token `fi'\n"); error_msg("unexpected token `fi'\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/* Clear out the if and then context bits */ /* Clear out the if and then context bits */
@ -646,7 +646,7 @@ static int setupRedirections(struct childProgram *prog)
if (openfd < 0) { if (openfd < 0) {
/* this could get lost if stderr has been redirected, but /* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */ bash and ash both lose it as well (though zsh doesn't!) */
errorMsg("error opening %s: %s\n", redir->filename, error_msg("error opening %s: %s\n", redir->filename,
strerror(errno)); strerror(errno));
return 1; return 1;
} }
@ -820,7 +820,7 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
if (strpbrk(prog->argv[argc_l - 1],"*[]?")!= NULL){ if (strpbrk(prog->argv[argc_l - 1],"*[]?")!= NULL){
rc = glob(prog->argv[argc_l - 1], flags, NULL, &prog->globResult); rc = glob(prog->argv[argc_l - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) { if (rc == GLOB_NOSPACE) {
errorMsg("out of space during glob operation\n"); error_msg("out of space during glob operation\n");
return; return;
} else if (rc == GLOB_NOMATCH || } else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 && (!rc && (prog->globResult.gl_pathc - i) == 1 &&
@ -927,7 +927,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*src == '\\') { if (*src == '\\') {
src++; src++;
if (!*src) { if (!*src) {
errorMsg("character expected after \\\n"); error_msg("character expected after \\\n");
freeJob(job); freeJob(job);
return 1; return 1;
} }
@ -1009,7 +1009,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
chptr++; chptr++;
if (!*chptr) { if (!*chptr) {
errorMsg("file name expected after %c\n", *src); error_msg("file name expected after %c\n", *src);
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -1028,7 +1028,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*prog->argv[argc_l]) if (*prog->argv[argc_l])
argc_l++; argc_l++;
if (!argc_l) { if (!argc_l) {
errorMsg("empty command in pipe\n"); error_msg("empty command in pipe\n");
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -1055,7 +1055,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
src++; src++;
if (!*src) { if (!*src) {
errorMsg("empty command in pipe\n"); error_msg("empty command in pipe\n");
freeJob(job); freeJob(job);
job->numProgs=0; job->numProgs=0;
return 1; return 1;
@ -1114,7 +1114,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
* command line, making extra room as needed */ * command line, making extra room as needed */
--src; --src;
charptr1 = xmalloc(BUFSIZ); charptr1 = xmalloc(BUFSIZ);
while ( (size=fullRead(pipefd[0], charptr1, BUFSIZ-1)) >0) { while ( (size=full_read(pipefd[0], charptr1, BUFSIZ-1)) >0) {
int newSize=src - *commandPtr + size + 1 + strlen(charptr2); int newSize=src - *commandPtr + size + 1 + strlen(charptr2);
if (newSize > BUFSIZ) { if (newSize > BUFSIZ) {
*commandPtr=xrealloc(*commandPtr, src - *commandPtr + *commandPtr=xrealloc(*commandPtr, src - *commandPtr +
@ -1145,7 +1145,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
case '\\': case '\\':
src++; src++;
if (!*src) { if (!*src) {
errorMsg("character expected after \\\n"); error_msg("character expected after \\\n");
freeJob(job); freeJob(job);
return 1; return 1;
} }
@ -1291,7 +1291,7 @@ static int runCommand(struct job *newJob, struct jobSet *jobList, int inBg, int
#endif #endif
execvp(newJob->progs[i].argv[0], newJob->progs[i].argv); execvp(newJob->progs[i].argv[0], newJob->progs[i].argv);
fatalError("%s: %s\n", newJob->progs[i].argv[0], error_msg_and_die("%s: %s\n", newJob->progs[i].argv[0],
strerror(errno)); strerror(errno));
} }
if (outPipe[1]!=-1) { if (outPipe[1]!=-1) {
@ -1495,7 +1495,7 @@ int shell_main(int argc_l, char **argv_l)
case 'c': case 'c':
input = NULL; input = NULL;
if (local_pending_command != 0) if (local_pending_command != 0)
fatalError("multiple -c arguments\n"); error_msg_and_die("multiple -c arguments\n");
local_pending_command = xstrdup(argv[optind]); local_pending_command = xstrdup(argv[optind]);
optind++; optind++;
argv = argv+optind; argv = argv+optind;

4
ln.c
View File

@ -55,9 +55,9 @@ static int fs_link(const char *link_DestName, const char *link_SrcName, const in
strcpy(srcName, link_SrcName); strcpy(srcName, link_SrcName);
if (flag&LN_NODEREFERENCE) if (flag&LN_NODEREFERENCE)
srcIsDir = isDirectory(srcName, TRUE, NULL); srcIsDir = is_directory(srcName, TRUE, NULL);
else else
srcIsDir = isDirectory(srcName, FALSE, NULL); srcIsDir = is_directory(srcName, FALSE, NULL);
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) { if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
strcat(srcName, "/"); strcat(srcName, "/");

View File

@ -39,12 +39,12 @@ int loadacm_main(int argc, char **argv)
fd = open("/dev/tty", O_RDWR); fd = open("/dev/tty", O_RDWR);
if (fd < 0) { if (fd < 0) {
errorMsg("Error opening /dev/tty1: %s\n", strerror(errno)); error_msg("Error opening /dev/tty1: %s\n", strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (screen_map_load(fd, stdin)) { if (screen_map_load(fd, stdin)) {
errorMsg("Error loading acm: %s\n", strerror(errno)); error_msg("Error loading acm: %s\n", strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -72,7 +72,7 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) { if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
errorMsg("16bit screen-map MUST be a regular file.\n"), error_msg("16bit screen-map MUST be a regular file.\n"),
exit(1); exit(1);
else else
perror("fseek failed reading binary 16bit screen-map"), perror("fseek failed reading binary 16bit screen-map"),
@ -83,7 +83,7 @@ int screen_map_load(int fd, FILE * fp)
perror("Cannot read [new] map from file"), exit(1); perror("Cannot read [new] map from file"), exit(1);
#if 0 #if 0
else else
errorMsg("Input screen-map is binary.\n"); error_msg("Input screen-map is binary.\n");
#endif #endif
} }
@ -100,7 +100,7 @@ int screen_map_load(int fd, FILE * fp)
/* rewind... */ /* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"), error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1); exit(1);
else else
perror("fseek failed assuming 8bit screen-map"), exit(1); perror("fseek failed assuming 8bit screen-map"), exit(1);
@ -113,7 +113,7 @@ int screen_map_load(int fd, FILE * fp)
if (-1 == fseek(fp, 0, SEEK_SET)) { if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE) if (errno == ESPIPE)
/* should not - it succedeed above */ /* should not - it succedeed above */
errorMsg("fseek() returned ESPIPE !\n"), error_msg("fseek() returned ESPIPE !\n"),
exit(1); exit(1);
else else
perror("fseek for binary 8bit screen-map"), exit(1); perror("fseek for binary 8bit screen-map"), exit(1);
@ -123,7 +123,7 @@ int screen_map_load(int fd, FILE * fp)
perror("Cannot read [old] map from file"), exit(1); perror("Cannot read [old] map from file"), exit(1);
#if 0 #if 0
else else
errorMsg("Input screen-map is binary.\n"); error_msg("Input screen-map is binary.\n");
#endif #endif
} }
@ -132,7 +132,7 @@ int screen_map_load(int fd, FILE * fp)
else else
return 0; return 0;
} }
errorMsg("Error parsing symbolic map\n"); error_msg("Error parsing symbolic map\n");
return(1); return(1);
} }

View File

@ -48,7 +48,7 @@ extern int loadfont_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) if (fd < 0)
fatalPerror("Error opening /dev/tty0"); perror_msg_and_die("Error opening /dev/tty0");
loadnewfont(fd); loadnewfont(fd);
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -62,7 +62,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32) if (unit < 1 || unit > 32)
fatalError("Bad character size %d\n", unit); error_msg_and_die("Bad character size %d\n", unit);
for (i = 0; i < fontsize; i++) for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit); memcpy(buf + (32 * i), inbuf + (unit * i), unit);
@ -77,11 +77,11 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
if (ioctl(fd, PIO_FONTX, &cfd) == 0) if (ioctl(fd, PIO_FONTX, &cfd) == 0)
return; /* success */ return; /* success */
perrorMsg("PIO_FONTX ioctl error (trying PIO_FONT)"); perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
} }
#endif #endif
if (ioctl(fd, PIO_FONT, buf)) if (ioctl(fd, PIO_FONT, buf))
fatalPerror("PIO_FONT ioctl error"); perror_msg_and_die("PIO_FONT ioctl error");
} }
static void static void
@ -119,11 +119,11 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) { if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD #ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) { if (errno == ENOIOCTLCMD) {
errorMsg("It seems this kernel is older than 1.1.92\n"); error_msg("It seems this kernel is older than 1.1.92\n");
fatalError("No Unicode mapping table loaded.\n"); error_msg_and_die("No Unicode mapping table loaded.\n");
} else } else
#endif #endif
fatalPerror("PIO_UNIMAPCLR"); perror_msg_and_die("PIO_UNIMAPCLR");
} }
ud.entry_ct = ct; ud.entry_ct = ct;
ud.entries = up; ud.entries = up;
@ -133,7 +133,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
/* change advice parameters */ /* change advice parameters */
} }
#endif #endif
fatalPerror("PIO_UNIMAP"); perror_msg_and_die("PIO_UNIMAP");
} }
} }
@ -150,13 +150,13 @@ static void loadnewfont(int fd)
*/ */
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin); inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin)) if (ferror(stdin))
fatalPerror("Error reading input font"); perror_msg_and_die("Error reading input font");
/* use malloc/realloc in case of giant files; /* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font, maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values and 16kB for the map leaves 32 unicode values
for each font position */ for each font position */
if (!feof(stdin)) if (!feof(stdin))
fatalPerror("Font too large"); perror_msg_and_die("Font too large");
/* test for psf first */ /* test for psf first */
{ {
@ -174,11 +174,11 @@ static void loadnewfont(int fd)
goto no_psf; goto no_psf;
if (psfhdr.mode > PSF_MAXMODE) if (psfhdr.mode > PSF_MAXMODE)
fatalError("Unsupported psf file mode\n"); error_msg_and_die("Unsupported psf file mode\n");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256); fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ ) #if !defined( PIO_FONTX ) || defined( __sparc__ )
if (fontsize != 256) if (fontsize != 256)
fatalError("Only fontsize 256 supported\n"); error_msg_and_die("Only fontsize 256 supported\n");
#endif #endif
hastable = (psfhdr.mode & PSF_MODEHASTAB); hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize; unit = psfhdr.charsize;
@ -186,7 +186,7 @@ static void loadnewfont(int fd)
head = head0 + fontsize * unit; head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth)) if (head > inputlth || (!hastable && head != inputlth))
fatalError("Input file: bad length\n"); error_msg_and_die("Input file: bad length\n");
do_loadfont(fd, inbuf + head0, unit, fontsize); do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable) if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize); do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
@ -201,7 +201,7 @@ static void loadnewfont(int fd)
} else { } else {
/* bare font */ /* bare font */
if (inputlth & 0377) if (inputlth & 0377)
fatalError("Bad input file size\n"); error_msg_and_die("Bad input file size\n");
offset = 0; offset = 0;
unit = inputlth / 256; unit = inputlth / 256;
} }

View File

@ -52,14 +52,14 @@ int loadkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR); fd = open("/dev/tty0", O_RDWR);
if (fd < 0) if (fd < 0)
fatalPerror("Error opening /dev/tty0"); perror_msg_and_die("Error opening /dev/tty0");
read(0, buff, 7); read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7)) if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
fatalError("This is not a valid binary keymap.\n"); error_msg_and_die("This is not a valid binary keymap.\n");
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
fatalPerror("Error reading keymap flags"); perror_msg_and_die("Error reading keymap flags");
ibuff = (u_short *) xmalloc(ibuffsz); ibuff = (u_short *) xmalloc(ibuffsz);
@ -68,7 +68,7 @@ int loadkmap_main(int argc, char **argv)
pos = 0; pos = 0;
while (pos < ibuffsz) { while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0) if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
fatalPerror("Error reading keymap"); perror_msg_and_die("Error reading keymap");
pos += readsz; pos += readsz;
} }
for (j = 0; j < NR_KEYS; j++) { for (j = 0; j < NR_KEYS; j++) {

View File

@ -85,14 +85,14 @@ static int pencode(char *s)
*s = '\0'; *s = '\0';
fac = decode(save, facilitynames); fac = decode(save, facilitynames);
if (fac < 0) if (fac < 0)
fatalError("unknown facility name: %s\n", save); error_msg_and_die("unknown facility name: %s\n", save);
*s++ = '.'; *s++ = '.';
} else { } else {
s = save; s = save;
} }
lev = decode(s, prioritynames); lev = decode(s, prioritynames);
if (lev < 0) if (lev < 0)
fatalError("unknown priority name: %s\n", save); error_msg_and_die("unknown priority name: %s\n", save);
return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)); return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK));
} }
@ -152,7 +152,7 @@ extern int logger_main(int argc, char **argv)
if (argc >= 1) if (argc >= 1)
message = *argv; message = *argv;
else else
fatalError("No message\n"); error_msg_and_die("No message\n");
} }
openlog(name, option, (pri | LOG_FACMASK)); openlog(name, option, (pri | LOG_FACMASK));

View File

@ -35,5 +35,5 @@ extern int logname_main(int argc, char **argv)
puts(user); puts(user);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
fatalError("no login name\n"); error_msg_and_die("no login name\n");
} }

8
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)) {
errorMsg("%s: %s\n", cur->fullname, strerror(errno)); error_msg("%s: %s\n", cur->fullname, strerror(errno));
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)) {
errorMsg("%s: %s\n", cur->fullname, strerror(errno)); error_msg("%s: %s\n", cur->fullname, strerror(errno));
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) {
errorMsg("%s: %s\n", path, strerror(errno)); error_msg("%s: %s\n", path, strerror(errno));
status = EXIT_FAILURE; status = EXIT_FAILURE;
return(NULL); /* could not open the dir */ return(NULL); /* could not open the dir */
} }
@ -591,7 +591,7 @@ int list_single(struct dnode *dn)
column += 5; column += 5;
break; break;
case LIST_MODEBITS: case LIST_MODEBITS:
fprintf(stdout, "%10s", (char *)modeString(dn->dstat.st_mode)); fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10; column += 10;
break; break;
case LIST_NLINKS: case LIST_NLINKS:

View File

@ -83,7 +83,7 @@ extern int lsmod_main(int argc, char **argv)
module_names = xmalloc(bufsize = 256); module_names = xmalloc(bufsize = 256);
deps = xmalloc(bufsize); deps = xmalloc(bufsize);
if (query_module(NULL, QM_MODULES, module_names, bufsize, &nmod)) { if (query_module(NULL, QM_MODULES, module_names, bufsize, &nmod)) {
fatalError("QM_MODULES: %s\n", strerror(errno)); error_msg_and_die("QM_MODULES: %s\n", strerror(errno));
} }
printf("Module Size Used by\n"); printf("Module Size Used by\n");
@ -94,7 +94,7 @@ extern int lsmod_main(int argc, char **argv)
continue; continue;
} }
/* else choke */ /* else choke */
fatalError("module %s: QM_INFO: %s\n", mn, strerror(errno)); error_msg_and_die("module %s: QM_INFO: %s\n", mn, strerror(errno));
} }
while (query_module(mn, QM_REFS, deps, bufsize, &count)) { while (query_module(mn, QM_REFS, deps, bufsize, &count)) {
if (errno == ENOENT) { if (errno == ENOENT) {
@ -102,7 +102,7 @@ extern int lsmod_main(int argc, char **argv)
continue; continue;
} }
if (errno != ENOSPC) { if (errno != ENOSPC) {
fatalError("module %s: QM_REFS: %s", mn, strerror(errno)); error_msg_and_die("module %s: QM_REFS: %s", mn, strerror(errno));
} }
deps = xrealloc(deps, bufsize = count); deps = xrealloc(deps, bufsize = count);
} }
@ -153,7 +153,7 @@ extern int lsmod_main(int argc, char **argv)
close(fd); close(fd);
return 0; return 0;
} }
fatalError("/proc/modules: %s\n", strerror(errno)); error_msg_and_die("/proc/modules: %s\n", strerror(errno));
return 1; return 1;
} }

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) {
errorMsg("%s: %s\n", filename, strerror(errno)); error_msg("%s: %s\n", filename, strerror(errno));
return FALSE; return FALSE;
} }
} }
if (md5_stream(fp, md5_result)) { if (md5_stream(fp, md5_result)) {
errorMsg("%s: %s\n", filename, strerror(errno)); error_msg("%s: %s\n", filename, strerror(errno));
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) {
errorMsg("%s: %s\n", filename, strerror(errno)); error_msg("%s: %s\n", filename, strerror(errno));
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) {
errorMsg("%s: %s\n", checkfile_name, strerror(errno)); error_msg("%s: %s\n", checkfile_name, strerror(errno));
return FALSE; return FALSE;
} }
} }
@ -722,7 +722,7 @@ static int md5_check(const char *checkfile_name)
if (split_3(line, line_length, &md5num, &binary, &filename) if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) { || !hex_digits(md5num)) {
if (warn) { if (warn) {
errorMsg("%s: %lu: improperly formatted MD5 checksum line\n", error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
checkfile_name, (unsigned long) line_number); checkfile_name, (unsigned long) line_number);
} }
} else { } else {
@ -770,18 +770,18 @@ static int md5_check(const char *checkfile_name)
free(line); free(line);
if (ferror(checkfile_stream)) { if (ferror(checkfile_stream)) {
errorMsg("%s: read error\n", checkfile_name); /* */ error_msg("%s: read error\n", checkfile_name); /* */
return FALSE; return FALSE;
} }
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) { if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno)); error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
return FALSE; return FALSE;
} }
if (n_properly_formated_lines == 0) { if (n_properly_formated_lines == 0) {
/* Warn if no tests are found. */ /* Warn if no tests are found. */
errorMsg("%s: no properly formatted MD5 checksum lines found\n", error_msg("%s: no properly formatted MD5 checksum lines found\n",
checkfile_name); checkfile_name);
return FALSE; return FALSE;
} else { } else {
@ -790,13 +790,13 @@ static int md5_check(const char *checkfile_name)
- n_open_or_read_failures); - n_open_or_read_failures);
if (n_open_or_read_failures > 0) { if (n_open_or_read_failures > 0) {
errorMsg("WARNING: %d of %d listed files could not be read\n", error_msg("WARNING: %d of %d listed files could not be read\n",
n_open_or_read_failures, n_properly_formated_lines); n_open_or_read_failures, n_properly_formated_lines);
return FALSE; return FALSE;
} }
if (n_mismatched_checksums > 0) { if (n_mismatched_checksums > 0) {
errorMsg("WARNING: %d of %d computed checksums did NOT match\n", error_msg("WARNING: %d of %d computed checksums did NOT match\n",
n_mismatched_checksums, n_computed_checkums); n_mismatched_checksums, n_computed_checkums);
return FALSE; return FALSE;
} }
@ -861,22 +861,22 @@ int md5sum_main(int argc,
} }
if (file_type_specified && do_check) { if (file_type_specified && do_check) {
errorMsg("the -b and -t options are meaningless when verifying checksums\n"); error_msg("the -b and -t options are meaningless when verifying checksums\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (n_strings > 0 && do_check) { if (n_strings > 0 && do_check) {
errorMsg("the -g and -c options are mutually exclusive\n"); error_msg("the -g and -c options are mutually exclusive\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (status_only && !do_check) { if (status_only && !do_check) {
errorMsg("the -s option is meaningful only when verifying checksums\n"); error_msg("the -s option is meaningful only when verifying checksums\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (warn && !do_check) { if (warn && !do_check) {
errorMsg("the -w option is meaningful only when verifying checksums\n"); error_msg("the -w option is meaningful only when verifying checksums\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -884,7 +884,7 @@ int md5sum_main(int argc,
size_t i; size_t i;
if (optind < argc) { if (optind < argc) {
errorMsg("no files may be specified when using -g\n"); error_msg("no files may be specified when using -g\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
for (i = 0; i < n_strings; ++i) { for (i = 0; i < n_strings; ++i) {
@ -898,7 +898,7 @@ int md5sum_main(int argc,
} }
} else if (do_check) { } else if (do_check) {
if (optind + 1 < argc) { if (optind + 1 < argc) {
errorMsg("only one argument may be specified when using -c\n"); error_msg("only one argument may be specified when using -c\n");
} }
err = md5_check ((optind == argc) ? "-" : argv[optind]); err = md5_check ((optind == argc) ? "-" : argv[optind]);
@ -951,12 +951,12 @@ int md5sum_main(int argc,
} }
if (fclose (stdout) == EOF) { if (fclose (stdout) == EOF) {
errorMsg("write error\n"); error_msg("write error\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (have_read_stdin && fclose (stdin) == EOF) { if (have_read_stdin && fclose (stdin) == EOF) {
errorMsg("standard input\n"); error_msg("standard input\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -14,14 +14,14 @@ static unsigned int pointer;
static void push(double a) static void push(double a)
{ {
if (pointer >= (sizeof(stack) / sizeof(*stack))) if (pointer >= (sizeof(stack) / sizeof(*stack)))
fatalError("stack overflow\n"); error_msg_and_die("stack overflow\n");
stack[pointer++] = a; stack[pointer++] = a;
} }
static double pop() static double pop()
{ {
if (pointer == 0) if (pointer == 0)
fatalError("stack underflow\n"); error_msg_and_die("stack underflow\n");
return stack[--pointer]; return stack[--pointer];
} }
@ -120,7 +120,7 @@ static void stack_machine(const char *argument)
} }
o++; o++;
} }
fatalError("%s: syntax error.\n", argument); error_msg_and_die("%s: syntax error.\n", argument);
} }
/* return pointer to next token in buffer and set *buffer to one char /* return pointer to next token in buffer and set *buffer to one char

View File

@ -35,7 +35,7 @@ extern int dutmp_main(int argc, char **argv)
} else { } else {
file = open(argv[1], O_RDONLY); file = open(argv[1], O_RDONLY);
if (file < 0) { if (file < 0) {
fatalError(io_error, argv[1], strerror(errno)); error_msg_and_die(io_error, argv[1], strerror(errno));
} }
} }

View File

@ -75,7 +75,7 @@ extern int mt_main(int argc, char **argv)
} }
if (code->name == 0) { if (code->name == 0) {
errorMsg("unrecognized opcode %s.\n", argv[1]); error_msg("unrecognized opcode %s.\n", argv[1]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

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)
fatalError("%s: %s\n", argv[1], strerror(errno)); error_msg_and_die("%s: %s\n", argv[1], strerror(errno));
} }
buf[size] = '\0'; buf[size] = '\0';

View File

@ -50,7 +50,7 @@ extern int mkdir_main(int argc, char **argv)
/* Find the specified modes */ /* Find the specified modes */
mode = 0; mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) { if (parse_mode(*(++argv), &mode) == FALSE) {
errorMsg("Unknown mode: %s\n", *argv); error_msg("Unknown mode: %s\n", *argv);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
/* Set the umask for this process so it doesn't /* Set the umask for this process so it doesn't
@ -79,18 +79,18 @@ extern int mkdir_main(int argc, char **argv)
char buf[BUFSIZ + 1]; char buf[BUFSIZ + 1];
if (strlen(*argv) > BUFSIZ - 1) { if (strlen(*argv) > BUFSIZ - 1) {
errorMsg(name_too_long); error_msg(name_too_long);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
strcpy(buf, *argv); strcpy(buf, *argv);
status = stat(buf, &statBuf); status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) { if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
errorMsg("%s: File exists\n", buf); error_msg("%s: File exists\n", buf);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (parentFlag == TRUE) { if (parentFlag == TRUE) {
strcat(buf, "/"); strcat(buf, "/");
createPath(buf, mode); create_path(buf, mode);
} else { } else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) { if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror(buf); perror(buf);

View File

@ -262,7 +262,7 @@ static inline int bit(char * a,unsigned int i)
*/ */
static volatile void die(char *str) static volatile void die(char *str)
{ {
errorMsg("%s\n", str); error_msg("%s\n", str);
exit(8); exit(8);
} }
@ -796,7 +796,7 @@ extern int mkfs_minix_main(int argc, char **argv)
#ifdef BB_FEATURE_MINIX2 #ifdef BB_FEATURE_MINIX2
version2 = 1; version2 = 1;
#else #else
errorMsg("%s: not compiled with minix v2 support\n", error_msg("%s: not compiled with minix v2 support\n",
device_name); device_name);
exit(-1); exit(-1);
#endif #endif

View File

@ -84,7 +84,7 @@ int mknod_main(int argc, char **argv)
mode |= perm; mode |= perm;
if (mknod(argv[0], mode, dev) != 0) if (mknod(argv[0], mode, dev) != 0)
fatalError("%s: %s\n", argv[0], strerror(errno)); error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -87,7 +87,7 @@ static void init_signature_page()
#ifdef PAGE_SIZE #ifdef PAGE_SIZE
if (pagesize != PAGE_SIZE) if (pagesize != PAGE_SIZE)
errorMsg("Assuming pages of size %d\n", pagesize); error_msg("Assuming pages of size %d\n", pagesize);
#endif #endif
signature_page = (int *) xmalloc(pagesize); signature_page = (int *) xmalloc(pagesize);
memset(signature_page, 0, pagesize); memset(signature_page, 0, pagesize);
@ -175,7 +175,7 @@ static int bit_test_and_clear(unsigned int *addr, unsigned int nr)
void die(const char *str) void die(const char *str)
{ {
errorMsg("%s\n", str); error_msg("%s\n", str);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -316,14 +316,14 @@ int mkswap_main(int argc, char **argv)
} }
} }
if (!device_name) { if (!device_name) {
errorMsg("error: Nowhere to set up swap on?\n"); error_msg("error: Nowhere to set up swap on?\n");
usage(mkswap_usage); usage(mkswap_usage);
} }
sz = get_size(device_name); sz = get_size(device_name);
if (!PAGES) { if (!PAGES) {
PAGES = sz; PAGES = sz;
} else if (PAGES > sz && !force) { } else if (PAGES > sz && !force) {
errorMsg("error: size %ld is larger than device size %d\n", error_msg("error: size %ld is larger than device size %d\n",
PAGES * (pagesize / 1024), sz * (pagesize / 1024)); PAGES * (pagesize / 1024), sz * (pagesize / 1024));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -339,11 +339,11 @@ int mkswap_main(int argc, char **argv)
version = 1; version = 1;
} }
if (version != 0 && version != 1) { if (version != 0 && version != 1) {
errorMsg("error: unknown version %d\n", version); error_msg("error: unknown version %d\n", version);
usage(mkswap_usage); usage(mkswap_usage);
} }
if (PAGES < 10) { if (PAGES < 10) {
errorMsg("error: swap area needs to be at least %ldkB\n", error_msg("error: swap area needs to be at least %ldkB\n",
(long) (10 * pagesize / 1024)); (long) (10 * pagesize / 1024));
usage(mkswap_usage); usage(mkswap_usage);
} }
@ -362,7 +362,7 @@ int mkswap_main(int argc, char **argv)
#endif #endif
if (PAGES > maxpages) { if (PAGES > maxpages) {
PAGES = maxpages; PAGES = maxpages;
errorMsg("warning: truncating swap area to %ldkB\n", error_msg("warning: truncating swap area to %ldkB\n",
PAGES * pagesize / 1024); PAGES * pagesize / 1024);
} }
@ -389,7 +389,7 @@ int mkswap_main(int argc, char **argv)
for (sum = 0; q >= (unsigned short *) buffer;) for (sum = 0; q >= (unsigned short *) buffer;)
sum ^= *q--; sum ^= *q--;
if (!sum) { if (!sum) {
errorMsg("Device '%s' contains a valid Sun disklabel.\n" error_msg("Device '%s' contains a valid Sun disklabel.\n"
"This probably means creating v0 swap would destroy your partition table\n" "This probably means creating v0 swap would destroy your partition table\n"
"No swap created. If you really want to create swap v0 on that device, use\n" "No swap created. If you really want to create swap v0 on that device, use\n"
"the -f option to force it.\n", device_name); "the -f option to force it.\n", device_name);

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.30 2000/12/06 18:18:26 andersen Exp $" #ident "$Id: insmod.c,v 1.31 2000/12/07 19:56:48 markw 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.30 2000/12/06 18:18:26 andersen Exp $" #ident "$Id: insmod.c,v 1.31 2000/12/07 19:56:48 markw Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */
@ -1157,7 +1157,7 @@ struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name,
/* Don't report an error if the symbol is coming from /* Don't report an error if the symbol is coming from
the kernel or some external module. */ the kernel or some external module. */
if (secidx <= SHN_HIRESERVE) if (secidx <= SHN_HIRESERVE)
errorMsg("%s multiply defined\n", name); error_msg("%s multiply defined\n", name);
return sym; return sym;
} }
} }
@ -1420,7 +1420,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Also check that the parameter was not resolved from the kernel. */ /* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) { if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
errorMsg("symbol for parameter %s not found\n", p); error_msg("symbol for parameter %s not found\n", p);
return 0; return 0;
} }
@ -1433,7 +1433,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q)); str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) { for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') { if (*q == '\0') {
errorMsg("improperly terminated string argument for %s\n", p); error_msg("improperly terminated string argument for %s\n", p);
return 0; return 0;
} else if (*q == '\\') } else if (*q == '\\')
switch (*++q) { switch (*++q) {
@ -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) {
errorMsg("get_kernel_syms: %s: %s\n", m_name, strerror(errno)); error_msg("get_kernel_syms: %s: %s\n", m_name, strerror(errno));
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)
errorMsg("init_module: %s: %s\n", m_name, strerror(errno)); error_msg("init_module: %s: %s\n", m_name, strerror(errno));
free(image); free(image);
free(symtab); free(symtab);
@ -1786,7 +1786,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
p = get_modinfo_value(f, key); p = get_modinfo_value(f, key);
key += 5; key += 5;
if (p == NULL) { if (p == NULL) {
errorMsg("invalid parameter %s\n", key); error_msg("invalid parameter %s\n", key);
return 0; return 0;
} }
@ -1794,7 +1794,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Also check that the parameter was not resolved from the kernel. */ /* Also check that the parameter was not resolved from the kernel. */
if (sym == NULL || sym->secidx > SHN_HIRESERVE) { if (sym == NULL || sym->secidx > SHN_HIRESERVE) {
errorMsg("symbol for parameter %s not found\n", key); error_msg("symbol for parameter %s not found\n", key);
return 0; return 0;
} }
@ -1822,7 +1822,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q)); str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) { for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') { if (*q == '\0') {
errorMsg("improperly terminated string argument for %s\n", error_msg("improperly terminated string argument for %s\n",
key); key);
return 0; return 0;
} else if (*q == '\\') } else if (*q == '\\')
@ -1916,7 +1916,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Get the size of each member */ /* Get the size of each member */
/* Probably we should do that outside the loop ? */ /* Probably we should do that outside the loop ? */
if (!isdigit(*(p + 1))) { if (!isdigit(*(p + 1))) {
errorMsg("parameter type 'c' for %s must be followed by" error_msg("parameter type 'c' for %s must be followed by"
" the maximum size\n", key); " the maximum size\n", key);
return 0; return 0;
} }
@ -1924,7 +1924,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Check length */ /* Check length */
if (strlen(str) >= charssize) { if (strlen(str) >= charssize) {
errorMsg("string too long for %s (max %ld)\n", key, error_msg("string too long for %s (max %ld)\n", key,
charssize - 1); charssize - 1);
return 0; return 0;
} }
@ -1953,7 +1953,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
break; break;
default: default:
errorMsg("unknown parameter type '%c' for %s\n", *p, key); error_msg("unknown parameter type '%c' for %s\n", *p, key);
return 0; return 0;
} }
} }
@ -1972,21 +1972,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
case ',': case ',':
if (++n > max) { if (++n > max) {
errorMsg("too many values for %s (max %d)\n", key, max); error_msg("too many values for %s (max %d)\n", key, max);
return 0; return 0;
} }
++q; ++q;
break; break;
default: default:
errorMsg("invalid argument syntax for %s\n", key); error_msg("invalid argument syntax for %s\n", key);
return 0; return 0;
} }
} }
end_of_arg: end_of_arg:
if (n < min) { if (n < min) {
errorMsg("too few values for %s (min %d)\n", key, min); error_msg("too few values for %s (min %d)\n", key, min);
return 0; return 0;
} }
@ -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;
} }
errorMsg("QM_MODULES: %s\n", strerror(errno)); error_msg("QM_MODULES: %s\n", strerror(errno));
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;
} }
errorMsg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno)); error_msg("query_module: QM_INFO: %s: %s\n", mn, strerror(errno));
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:
errorMsg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno)); error_msg("query_module: QM_SYMBOLS: %s: %s\n", mn, strerror(errno));
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;
} }
errorMsg("kernel: QM_SYMBOLS: %s\n", strerror(errno)); error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
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)
errorMsg("init_module: %s: %s\n", m_name, strerror(errno)); error_msg("init_module: %s: %s\n", m_name, strerror(errno));
free(image); free(image);
@ -2372,7 +2372,7 @@ int obj_check_undefineds(struct obj_file *f)
sym->secidx = SHN_ABS; sym->secidx = SHN_ABS;
sym->value = 0; sym->value = 0;
} else { } else {
errorMsg("unresolved symbol %s\n", sym->name); error_msg("unresolved symbol %s\n", sym->name);
ret = 0; ret = 0;
} }
} }
@ -2599,11 +2599,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base)
errmsg = "Unhandled relocation"; errmsg = "Unhandled relocation";
bad_reloc: bad_reloc:
if (extsym) { if (extsym) {
errorMsg("%s of type %ld for %s\n", errmsg, error_msg("%s of type %ld for %s\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info), (long) ELFW(R_TYPE) (rel->r_info),
strtab + extsym->st_name); strtab + extsym->st_name);
} else { } else {
errorMsg("%s of type %ld\n", errmsg, error_msg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info)); (long) ELFW(R_TYPE) (rel->r_info));
} }
ret = 0; ret = 0;
@ -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) {
errorMsg("error reading ELF header: %s\n", strerror(errno)); error_msg("error reading ELF header: %s\n", strerror(errno));
return NULL; return NULL;
} }
@ -2688,25 +2688,25 @@ struct obj_file *obj_load(FILE * fp)
|| f->header.e_ident[EI_MAG1] != ELFMAG1 || f->header.e_ident[EI_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2 || f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) { || f->header.e_ident[EI_MAG3] != ELFMAG3) {
errorMsg("not an ELF file\n"); error_msg("not an ELF file\n");
return NULL; return NULL;
} }
if (f->header.e_ident[EI_CLASS] != ELFCLASSM if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM || f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT || f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) { || !MATCH_MACHINE(f->header.e_machine)) {
errorMsg("ELF file not for this architecture\n"); error_msg("ELF file not for this architecture\n");
return NULL; return NULL;
} }
if (f->header.e_type != ET_REL) { if (f->header.e_type != ET_REL) {
errorMsg("ELF file not a relocatable object\n"); error_msg("ELF file not a relocatable object\n");
return NULL; return NULL;
} }
/* Read the section headers. */ /* Read the section headers. */
if (f->header.e_shentsize != sizeof(ElfW(Shdr))) { if (f->header.e_shentsize != sizeof(ElfW(Shdr))) {
errorMsg("section header size mismatch: %lu != %lu\n", error_msg("section header size mismatch: %lu != %lu\n",
(unsigned long) f->header.e_shentsize, (unsigned long) f->header.e_shentsize,
(unsigned long) sizeof(ElfW(Shdr))); (unsigned long) sizeof(ElfW(Shdr)));
return NULL; return NULL;
@ -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) {
errorMsg("error reading ELF section headers: %s\n", strerror(errno)); error_msg("error reading ELF section headers: %s\n", strerror(errno));
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) {
errorMsg("error reading ELF section data: %s\n", strerror(errno)); error_msg("error reading ELF section data: %s\n", strerror(errno));
return NULL; return NULL;
} }
} else { } else {
@ -2759,11 +2759,11 @@ struct obj_file *obj_load(FILE * fp)
#if SHT_RELM == SHT_REL #if SHT_RELM == SHT_REL
case SHT_RELA: case SHT_RELA:
errorMsg("RELA relocations not supported on this architecture\n"); error_msg("RELA relocations not supported on this architecture\n");
return NULL; return NULL;
#else #else
case SHT_REL: case SHT_REL:
errorMsg("REL relocations not supported on this architecture\n"); error_msg("REL relocations not supported on this architecture\n");
return NULL; return NULL;
#endif #endif
@ -2776,7 +2776,7 @@ struct obj_file *obj_load(FILE * fp)
break; break;
} }
errorMsg("can't handle sections of type %ld\n", error_msg("can't handle sections of type %ld\n",
(long) sec->header.sh_type); (long) sec->header.sh_type);
return NULL; return NULL;
} }
@ -2805,7 +2805,7 @@ struct obj_file *obj_load(FILE * fp)
ElfW(Sym) * sym; ElfW(Sym) * sym;
if (sec->header.sh_entsize != sizeof(ElfW(Sym))) { if (sec->header.sh_entsize != sizeof(ElfW(Sym))) {
errorMsg("symbol size mismatch: %lu != %lu\n", error_msg("symbol size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize, (unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(Sym))); (unsigned long) sizeof(ElfW(Sym)));
return NULL; return NULL;
@ -2837,7 +2837,7 @@ struct obj_file *obj_load(FILE * fp)
case SHT_RELM: case SHT_RELM:
if (sec->header.sh_entsize != sizeof(ElfW(RelM))) { if (sec->header.sh_entsize != sizeof(ElfW(RelM))) {
errorMsg("relocation entry size mismatch: %lu != %lu\n", error_msg("relocation entry size mismatch: %lu != %lu\n",
(unsigned long) sec->header.sh_entsize, (unsigned long) sec->header.sh_entsize,
(unsigned long) sizeof(ElfW(RelM))); (unsigned long) sizeof(ElfW(RelM)));
return NULL; return NULL;
@ -2937,17 +2937,17 @@ extern int insmod_main( int argc, char **argv)
/* Get a filedesc for the module */ /* Get a filedesc for the module */
if ((fp = fopen(*argv, "r")) == NULL) { if ((fp = fopen(*argv, "r")) == NULL) {
/* Hmpf. Could not open it. Search through _PATH_MODULES to find a module named m_name */ /* Hmpf. Could not open it. Search through _PATH_MODULES to find a module named m_name */
if (recursiveAction(_PATH_MODULES, TRUE, FALSE, FALSE, if (recursive_action(_PATH_MODULES, TRUE, FALSE, FALSE,
findNamedModule, 0, m_fullName) == FALSE) findNamedModule, 0, m_fullName) == FALSE)
{ {
if (m_filename[0] == '\0' if (m_filename[0] == '\0'
|| ((fp = fopen(m_filename, "r")) == NULL)) || ((fp = fopen(m_filename, "r")) == NULL))
{ {
errorMsg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES); error_msg("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} else } else
fatalError("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES); error_msg_and_die("No module named '%s' found in '%s'\n", m_fullName, _PATH_MODULES);
} else } else
memcpy(m_filename, *argv, strlen(*argv)); memcpy(m_filename, *argv, strlen(*argv));
@ -2971,7 +2971,7 @@ extern int insmod_main( int argc, char **argv)
} else { } else {
m_version = old_get_module_version(f, m_strversion); m_version = old_get_module_version(f, m_strversion);
if (m_version == -1) { if (m_version == -1) {
errorMsg("couldn't find the kernel version the module was " error_msg("couldn't find the kernel version the module was "
"compiled for\n"); "compiled for\n");
goto out; goto out;
} }
@ -2979,12 +2979,12 @@ extern int insmod_main( int argc, char **argv)
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) { if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) { if (flag_force_load) {
errorMsg("Warning: kernel-module version mismatch\n" error_msg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n" "\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s\n", "\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion); m_filename, m_strversion, k_strversion);
} else { } else {
errorMsg("kernel-module version mismatch\n" error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n" "\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n", "\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion); m_filename, m_strversion, k_strversion);
@ -3002,7 +3002,7 @@ extern int insmod_main( int argc, char **argv)
goto out; goto out;
k_crcs = new_is_kernel_checksummed(); k_crcs = new_is_kernel_checksummed();
#else #else
errorMsg("Not configured to support new kernels\n"); error_msg("Not configured to support new kernels\n");
goto out; goto out;
#endif #endif
} else { } else {
@ -3011,7 +3011,7 @@ extern int insmod_main( int argc, char **argv)
goto out; goto out;
k_crcs = old_is_kernel_checksummed(); k_crcs = old_is_kernel_checksummed();
#else #else
errorMsg("Not configured to support old kernels\n"); error_msg("Not configured to support old kernels\n");
goto out; goto out;
#endif #endif
} }
@ -3068,14 +3068,14 @@ extern int insmod_main( int argc, char **argv)
case 0: case 0:
break; break;
case EEXIST: case EEXIST:
errorMsg("A module named %s already exists\n", m_name); error_msg("A module named %s already exists\n", m_name);
goto out; goto out;
case ENOMEM: case ENOMEM:
errorMsg("Can't allocate kernel memory for module; needed %lu bytes\n", error_msg("Can't allocate kernel memory for module; needed %lu bytes\n",
m_size); m_size);
goto out; goto out;
default: default:
errorMsg("create_module: %s: %s\n", m_name, strerror(errno)); error_msg("create_module: %s: %s\n", m_name, strerror(errno));
goto out; goto out;
} }

View File

@ -83,7 +83,7 @@ extern int lsmod_main(int argc, char **argv)
module_names = xmalloc(bufsize = 256); module_names = xmalloc(bufsize = 256);
deps = xmalloc(bufsize); deps = xmalloc(bufsize);
if (query_module(NULL, QM_MODULES, module_names, bufsize, &nmod)) { if (query_module(NULL, QM_MODULES, module_names, bufsize, &nmod)) {
fatalError("QM_MODULES: %s\n", strerror(errno)); error_msg_and_die("QM_MODULES: %s\n", strerror(errno));
} }
printf("Module Size Used by\n"); printf("Module Size Used by\n");
@ -94,7 +94,7 @@ extern int lsmod_main(int argc, char **argv)
continue; continue;
} }
/* else choke */ /* else choke */
fatalError("module %s: QM_INFO: %s\n", mn, strerror(errno)); error_msg_and_die("module %s: QM_INFO: %s\n", mn, strerror(errno));
} }
while (query_module(mn, QM_REFS, deps, bufsize, &count)) { while (query_module(mn, QM_REFS, deps, bufsize, &count)) {
if (errno == ENOENT) { if (errno == ENOENT) {
@ -102,7 +102,7 @@ extern int lsmod_main(int argc, char **argv)
continue; continue;
} }
if (errno != ENOSPC) { if (errno != ENOSPC) {
fatalError("module %s: QM_REFS: %s", mn, strerror(errno)); error_msg_and_die("module %s: QM_REFS: %s", mn, strerror(errno));
} }
deps = xrealloc(deps, bufsize = count); deps = xrealloc(deps, bufsize = count);
} }
@ -153,7 +153,7 @@ extern int lsmod_main(int argc, char **argv)
close(fd); close(fd);
return 0; return 0;
} }
fatalError("/proc/modules: %s\n", strerror(errno)); error_msg_and_die("/proc/modules: %s\n", strerror(errno));
return 1; return 1;
} }

28
mount.c
View File

@ -132,22 +132,22 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
specialfile = find_unused_loop_device(); specialfile = find_unused_loop_device();
if (specialfile == NULL) { if (specialfile == NULL) {
errorMsg("Could not find a spare loop device\n"); error_msg("Could not find a spare loop device\n");
return (FALSE); return (FALSE);
} }
if (set_loop(specialfile, lofile, 0, &loro)) { if (set_loop(specialfile, lofile, 0, &loro)) {
errorMsg("Could not setup loop device\n"); error_msg("Could not setup loop device\n");
return (FALSE); return (FALSE);
} }
if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */ if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */
errorMsg("WARNING: loop device is read-only\n"); error_msg("WARNING: loop device is read-only\n");
flags &= ~MS_RDONLY; flags &= ~MS_RDONLY;
} }
} }
#endif #endif
status = mount(specialfile, dir, filesystemtype, flags, string_flags); status = mount(specialfile, dir, filesystemtype, flags, string_flags);
if (errno == EROFS) { if (errno == EROFS) {
errorMsg("%s is write-protected, mounting read-only\n", specialfile); error_msg("%s is write-protected, mounting read-only\n", specialfile);
status = mount(specialfile, dir, filesystemtype, flags |= MS_RDONLY, string_flags); status = mount(specialfile, dir, filesystemtype, flags |= MS_RDONLY, string_flags);
} }
} }
@ -173,7 +173,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
#endif #endif
if (errno == EPERM) { if (errno == EPERM) {
fatalError("permission denied. Are you root?\n"); error_msg_and_die("permission denied. Are you root?\n");
} }
return (FALSE); return (FALSE);
@ -273,18 +273,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)
fatalError("open failed for `%s': %s\n", device, strerror (errno)); error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno));
/* 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)
fatalError("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno)); error_msg_and_die("\nDEVMTAB_COUNT_FILESYSTEMS: %s\n", strerror (errno));
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)
fatalError("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno)); error_msg_and_die("\nDEVMTAB_GET_FILESYSTEMS: %s\n", strerror (errno));
/* 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 */
@ -309,7 +309,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
if (status == FALSE) { if (status == FALSE) {
if (whineOnErrors == TRUE) { if (whineOnErrors == TRUE) {
errorMsg("Mounting %s on %s failed: %s\n", error_msg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno)); blockDevice, directory, strerror(errno));
} }
return (FALSE); return (FALSE);
@ -342,18 +342,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)
fatalError("open failed for `%s': %s\n", device, strerror (errno)); error_msg_and_die("open failed for `%s': %s\n", device, strerror (errno));
/* 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)
fatalError( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno)); error_msg_and_die( "\nDEVMTAB_COUNT_MOUNTS: %s\n", strerror (errno));
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)
fatalError( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno)); error_msg_and_die( "\nDEVMTAB_GET_MOUNTS: %s\n", strerror (errno));
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,
@ -455,7 +455,7 @@ extern int mount_main(int argc, char **argv)
fstabmount = TRUE; fstabmount = TRUE;
if (f == NULL) if (f == NULL)
fatalError( "\nCannot read /etc/fstab: %s\n", strerror (errno)); error_msg_and_die( "\nCannot read /etc/fstab: %s\n", strerror (errno));
while ((m = getmntent(f)) != NULL) { while ((m = getmntent(f)) != NULL) {
if (all == FALSE && directory == NULL && ( if (all == FALSE && directory == NULL && (
@ -488,7 +488,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) {
fatalError("nfsmount failed: %s\n", strerror(errno)); error_msg_and_die("nfsmount failed: %s\n", strerror(errno));
rc = EXIT_FAILURE; rc = EXIT_FAILURE;
} }
} }

2
mt.c
View File

@ -75,7 +75,7 @@ extern int mt_main(int argc, char **argv)
} }
if (code->name == 0) { if (code->name == 0) {
errorMsg("unrecognized opcode %s.\n", argv[1]); error_msg("unrecognized opcode %s.\n", argv[1]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

Some files were not shown because too many files have changed in this diff Show More