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) {
path[len] = 0;
} else {
errorMsg("%s: %s\n", proc, strerror(errno));
error_msg("%s: %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
@ -78,7 +78,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
rc = Link(busybox, command);
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);
lseek(srcFd, (off_t) 257, SEEK_CUR);
fullRead(srcFd, magic, 6);
full_read(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0)
return(FALSE);
@ -123,7 +123,7 @@ static int readTarHeader(int srcFd, headerL_t *current)
off_t initialOffset;
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);
return(FALSE);
}
@ -157,8 +157,8 @@ static int checkArMagic(int srcFd)
char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, arMagic, 8) != 8) {
errorMsg("fatal error\n");
if (full_read(srcFd, arMagic, 8) != 8) {
error_msg("fatal error\n");
return (FALSE);
}
lseek(srcFd, headerStart, SEEK_SET);
@ -178,7 +178,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
off_t initialOffset;
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);
return(FALSE);
}
@ -215,7 +215,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
if (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';
/* 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'))
strcpy(entry->name, tempName);
else {
errorMsg("Invalid long filename\n");
error_msg("Invalid long filename\n");
return(FALSE);
}
}
@ -343,7 +343,7 @@ extern int ar_main(int argc, char **argv)
usage(ar_usage);
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++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
@ -368,8 +368,8 @@ extern int ar_main(int argc, char **argv)
while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) {
if (isDirectory(extractList->name, TRUE, NULL)==FALSE)
createPath(extractList->name, 0666);
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
create_path(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET);
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 & 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->size, timeString(extractList->mtime));
extractList->size, time_string(extractList->mtime));
printf("%s\n", extractList->name);
}
extractList=extractList->next;

View File

@ -106,7 +106,7 @@ static int checkTarMagic(int srcFd)
headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR);
fullRead(srcFd, magic, 6);
full_read(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0)
return(FALSE);
@ -123,7 +123,7 @@ static int readTarHeader(int srcFd, headerL_t *current)
off_t initialOffset;
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);
return(FALSE);
}
@ -157,8 +157,8 @@ static int checkArMagic(int srcFd)
char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR);
if (fullRead(srcFd, arMagic, 8) != 8) {
errorMsg("fatal error\n");
if (full_read(srcFd, arMagic, 8) != 8) {
error_msg("fatal error\n");
return (FALSE);
}
lseek(srcFd, headerStart, SEEK_SET);
@ -178,7 +178,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
off_t initialOffset;
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);
return(FALSE);
}
@ -215,7 +215,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
if (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';
/* 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'))
strcpy(entry->name, tempName);
else {
errorMsg("Invalid long filename\n");
error_msg("Invalid long filename\n");
return(FALSE);
}
}
@ -343,7 +343,7 @@ extern int ar_main(int argc, char **argv)
usage(ar_usage);
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++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
@ -368,8 +368,8 @@ extern int ar_main(int argc, char **argv)
while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) {
if (isDirectory(extractList->name, TRUE, NULL)==FALSE)
createPath(extractList->name, 0666);
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
create_path(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET);
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 & 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->size, timeString(extractList->mtime));
extractList->size, time_string(extractList->mtime));
printf("%s\n", extractList->name);
}
extractList=extractList->next;

View File

@ -113,7 +113,7 @@ static char *license_msg[] = {
/* Diagnostic functions */
#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 Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
@ -297,7 +297,7 @@ int in; /* input file descriptor */
method = (int) get_byte();
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;
return -1;
}
@ -1114,13 +1114,13 @@ int in, out; /* input and output file descriptors */
int res = inflate();
if (res == 3) {
errorMsg(memory_exhausted);
error_msg(memory_exhausted);
} else if (res != 0) {
errorMsg("invalid compressed data--format violated\n");
error_msg("invalid compressed data--format violated\n");
}
} else {
errorMsg("internal error, invalid method\n");
error_msg("internal error, invalid method\n");
}
/* Get the crc and original length */
@ -1149,10 +1149,10 @@ int in, out; /* input and output file descriptors */
/* Validate decompression */
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) {
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 */
@ -1225,9 +1225,9 @@ int gunzip_main(int argc, char **argv)
}
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)
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;
@ -1265,7 +1265,7 @@ int gunzip_main(int argc, char **argv)
if (argc <= 0)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
errorMsg(name_too_long);
error_msg(name_too_long);
exit(WARNING);
}
strcpy(ifname, *argv);
@ -1304,7 +1304,7 @@ int gunzip_main(int argc, char **argv)
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
errorMsg(name_too_long);
error_msg(name_too_long);
exit(WARNING);
}
strcpy(ofname, ifname);

View File

@ -114,7 +114,7 @@ extern int method; /* compression method */
# define DECLARE(type, array, size) type * array
# define ALLOC(type, array, size) { \
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;}
#else
@ -251,7 +251,7 @@ extern int save_orig_name; /* set if original name must be saved */
/* Diagnostic functions */
#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 Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
@ -1381,7 +1381,7 @@ int length;
(char *) window + start, length) != EQUAL) {
fprintf(stderr,
" start %d, match %d, length %d\n", start, match, length);
errorMsg("invalid match\n");
error_msg("invalid match\n");
}
if (verbose > 1) {
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)
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)
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;
if (foreground) {
@ -2900,7 +2900,7 @@ int eof; /* true if this is the last block for a file */
#endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0)
errorMsg("block vanished\n");
error_msg("block vanished\n");
copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3;
@ -3083,7 +3083,7 @@ local void set_file_type()
bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
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 *));
if (nargv == NULL)
errorMsg(memory_exhausted);
error_msg(memory_exhausted);
oargv = *argvp;
*argvp = nargv;
/* Copy the program name first */
if (oargc-- < 0)
errorMsg("argc<=0\n");
error_msg("argc<=0\n");
*(nargv++) = *(oargv++);
/* Then copy the environment args */

View File

@ -193,10 +193,10 @@ extern int tar_main(int argc, char **argv)
break;
case 'f':
if (*tarName != '-')
fatalError( "Only one 'f' option allowed\n");
error_msg_and_die( "Only one 'f' option allowed\n");
tarName = *(++argv);
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;
break;
#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[excludeListSize] = *(++argv);
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 */
if (*excludeList[excludeListSize] =='/')
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
@ -216,13 +216,13 @@ extern int tar_main(int argc, char **argv)
}
case 'X':
if (*excludeFileName != '-')
fatalError("Only one 'X' option allowed\n");
error_msg_and_die("Only one 'X' option allowed\n");
excludeFileName = *(++argv);
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");
if (! fileList)
fatalError("Exclude file: file not found\n");
error_msg_and_die("Exclude file: file not found\n");
while (!feof(fileList)) {
fscanf(fileList, "%s", file);
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
@ -253,7 +253,7 @@ extern int tar_main(int argc, char **argv)
*/
if (createFlag == TRUE) {
#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
status = writeTarFile(tarName, verboseFlag, argv, excludeList);
#endif
@ -271,7 +271,7 @@ extern int tar_main(int argc, char **argv)
return EXIT_FAILURE;
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
@ -301,10 +301,10 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
if (extractFlag==TRUE && tostdoutFlag==FALSE) {
/* Create the path to the file, just in case it isn't there...
* 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,
header->mode & ~S_IFMT)) < 0) {
errorMsg(io_error, header->name, strerror(errno));
error_msg(io_error, header->name, strerror(errno));
return( FALSE);
}
}
@ -322,9 +322,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
readSize = 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 */
errorMsg("Unexpected EOF in archive\n");
error_msg("Unexpected EOF in archive\n");
return( FALSE);
}
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 */
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 */
errorMsg(io_error, header->name, strerror(errno));
error_msg(io_error, header->name, strerror(errno));
return( FALSE);
}
} else {
@ -361,13 +361,13 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
if (extractFlag==FALSE || tostdoutFlag==TRUE)
return( TRUE);
if (createPath(header->name, header->mode) != TRUE) {
errorMsg("%s: Cannot mkdir: %s\n",
if (create_path(header->name, header->mode) != TRUE) {
error_msg("%s: Cannot mkdir: %s\n",
header->name, strerror(errno));
return( FALSE);
}
/* 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 '/') */
if (mkdir(header->name, header->mode) == 0) {
fixUpPermissions(header);
@ -382,7 +382,7 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE);
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));
return( FALSE);
}
@ -400,7 +400,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
#ifdef S_ISLNK
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));
return( FALSE);
}
@ -415,7 +415,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
/* Do not change permissions or date on symlink,
* since it changes the pointed to file instead. duh. */
#else
errorMsg("%s: Cannot create symlink to '%s': %s\n",
error_msg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname,
"symlinks not supported");
#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 (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));
return( FALSE);
}
} else if (S_ISFIFO(header->mode)) {
if (mkfifo(header->name, header->mode) < 0) {
errorMsg("%s: Cannot mkfifo: %s\n",
error_msg("%s: Cannot mkfifo: %s\n",
header->name, strerror(errno));
return( FALSE);
}
@ -455,9 +455,9 @@ static long getOctal(const char *cp, int size)
long val = 0;
for(;(size > 0) && (*cp == ' '); cp++, size--);
if ((size == 0) || !isOctal(*cp))
if ((size == 0) || !is_octal(*cp))
return -1;
for(; (size > 0) && isOctal(*cp); size--) {
for(; (size > 0) && is_octal(*cp); size--) {
val = val * 8 + *cp++ - '0';
}
for (;(size > 0) && (*cp == ' '); cp++, size--);
@ -484,7 +484,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
++*(header->name);
if (alreadyWarned == FALSE) {
errorMsg("Removing leading '/' from member names\n");
error_msg("Removing leading '/' from member names\n");
alreadyWarned = TRUE;
}
}
@ -538,7 +538,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
else
tarFd = open(tarName, O_RDONLY);
if (tarFd < 0) {
errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno));
error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
return ( FALSE);
}
@ -547,7 +547,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
umask(0);
/* 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 */
if ( readTarHeader(&rawHeader, &header) == FALSE ) {
@ -555,7 +555,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
goto endgame;
} else {
errorFlag=TRUE;
errorMsg("Bad tar header, skipping\n");
error_msg("Bad tar header, skipping\n");
continue;
}
}
@ -572,7 +572,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
}
if ( skipNextHeaderFlag == TRUE ) {
skipNextHeaderFlag=FALSE;
errorMsg(name_longer_than_foo, NAME_SIZE);
error_msg(name_longer_than_foo, NAME_SIZE);
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
errorFlag = TRUE;
continue;
@ -638,7 +638,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
char buf[35];
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));
my_getpwuid(buf, header.uid);
if (! *buf)
@ -731,7 +731,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
break;
#endif
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);
return( FALSE);
}
@ -739,11 +739,11 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
close(tarFd);
if (status > 0) {
/* 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);
}
else if (errorFlag==TRUE) {
errorMsg( "Error exit delayed from previous errors\n");
error_msg( "Error exit delayed from previous errors\n");
return( FALSE);
} else
return( status);
@ -753,13 +753,13 @@ endgame:
close( tarFd);
if (extractList != NULL) {
for (; *extractList != NULL; extractList++) {
errorMsg("%s: Not found in archive\n", *extractList);
error_msg("%s: Not found in archive\n", *extractList);
errorFlag = TRUE;
}
}
if ( *(header.name) == '\0' ) {
if (errorFlag==TRUE)
errorMsg( "Error exit delayed from previous errors\n");
error_msg( "Error exit delayed from previous errors\n");
else
return( TRUE);
}
@ -903,7 +903,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
if (*fileName=='/') {
static int alreadyWarned=FALSE;
if (alreadyWarned==FALSE) {
errorMsg("Removing leading '/' from member names\n");
error_msg("Removing leading '/' from member names\n");
alreadyWarned=TRUE;
}
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;
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
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);
}
buffer[link_size] = '\0';
@ -978,7 +978,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
header.typeflag = REGTYPE;
putOctal(header.size, sizeof(header.size), statbuf->st_size);
} else {
errorMsg("%s: Unknown file type\n", fileName);
error_msg("%s: Unknown file type\n", fileName);
return ( FALSE);
}
@ -994,8 +994,8 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
putOctal(header.chksum, 7, chksum);
/* Now write the header out to disk */
if ((size=fullWrite(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
errorMsg(io_error, fileName, strerror(errno));
if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
error_msg(io_error, fileName, strerror(errno));
return ( FALSE);
}
/* 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 */
if (S_ISSOCK(statbuf->st_mode)) {
errorMsg("%s: socket ignored\n", fileName);
error_msg("%s: socket ignored\n", fileName);
return( TRUE);
}
@ -1045,12 +1045,12 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
* the new tarball */
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
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);
}
if (strlen(fileName) >= NAME_SIZE) {
errorMsg(name_longer_than_foo, NAME_SIZE);
error_msg(name_longer_than_foo, NAME_SIZE);
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 */
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);
}
/* write the file to the archive */
while ( (size = fullRead(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
if (fullWrite(tbInfo->tarFd, buffer, size) != size ) {
while ( (size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
if (full_write(tbInfo->tarFd, buffer, size) != size ) {
/* Output file seems to have a problem */
errorMsg(io_error, fileName, strerror(errno));
error_msg(io_error, fileName, strerror(errno));
return( FALSE);
}
readSize+=size;
}
if (size == -1) {
errorMsg(io_error, fileName, strerror(errno));
error_msg(io_error, fileName, strerror(errno));
return( FALSE);
}
/* 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. */
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. */
if (!strcmp(tarName, "-"))
@ -1114,7 +1114,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
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);
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
* can avoid including the tarball into itself.... */
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
* 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 */
while (*argv != NULL) {
if (recursiveAction(*argv++, TRUE, FALSE, FALSE,
if (recursive_action(*argv++, TRUE, FALSE, FALSE,
writeFileToTarball, writeFileToTarball,
(void*) &tbInfo) == FALSE) {
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 */
close(tarFd);
if (errorFlag == TRUE) {
errorMsg("Error exit delayed from previous errors\n");
error_msg("Error exit delayed from previous errors\n");
freeHardLinkInfo(&tbInfo.hlInfoHead);
return(FALSE);
}

View File

@ -54,7 +54,7 @@ static char *busybox_fullpath()
if (len != -1) {
path[len] = 0;
} else {
errorMsg("%s: %s\n", proc, strerror(errno));
error_msg("%s: %s\n", proc, strerror(errno));
return NULL;
}
return strdup(path);
@ -78,7 +78,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
rc = Link(busybox, command);
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 EXPAND_ALLOC 1024
static inline int isDecimal(ch) { return ((ch >= '0') && (ch <= '9')); }
static inline int isOctal(ch) { return ((ch >= '0') && (ch <= '7')); }
static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
/* Macros for min/max. */
#ifndef MIN
@ -119,14 +119,14 @@ extern const char *applet_name;
extern int applet_name_compare(const void *x, const void *y);
extern void usage(const char *usage) __attribute__ ((noreturn));
extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void perrorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatalPerror(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void perror_msg(const char *s, ...) __attribute__ ((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 *timeString(time_t timeVal);
int isDirectory(const char *name, const int followLinks, struct stat *statBuf);
const char *mode_string(int mode);
const char *time_string(time_t timeVal);
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
int isDevice(const char *name);
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 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 copy_file_chunk(int srcFd, int dstFd, size_t remaining);
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 *chunkstrdup(const char *str);
void freeChunks(void);
int fullWrite(int fd, const char *buf, int len);
int fullRead(int fd, char *buf, int len);
int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
int full_write(int fd, const char *buf, int len);
int full_read(int fd, char *buf, int len);
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, 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 get_kernel_revision(void);
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,
char* filesystemType, long flags, char* string_flags);
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_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern);
extern long getNum (const char *cp);
extern pid_t* findPidByName( char* pidName);
extern long atoi_w_units (const char *cp);
extern pid_t* find_pid_by_name( char* pidName);
extern int find_real_root_device_name(char* name);
extern char *get_line_from_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:
/* Parse the specified modes */
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)
return (TRUE);
@ -111,7 +111,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
}
if (argc == 0 || *argv == NULL) {
errorMsg(too_few_args);
error_msg(too_few_args);
}
if (whichApp == CHMOD_APP) {
@ -149,24 +149,24 @@ int chmod_chown_chgrp_main(int argc, char **argv)
if (*argv == p)
uid = my_getpwnam(*argv);
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 */
if (argc < 1) {
fatalError(too_few_args);
error_msg_and_die(too_few_args);
}
while (argc-- > 1) {
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE)
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
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++;
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--;
@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv)
return EXIT_SUCCESS;
#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_scroll = w / 3;
} 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++) {
num = atoi(argv[i]);
if (num == 0)
errorMsg("0: illegal VT number\n");
error_msg("0: illegal VT number\n");
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)) {
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");

View File

@ -50,7 +50,7 @@ int dumpkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR);
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;
}
@ -78,7 +78,7 @@ int dumpkmap_main(int argc, char **argv)
ke.kb_table = i;
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 {
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);
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;
}
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;
}
@ -72,7 +72,7 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
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);
else
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);
#if 0
else
errorMsg("Input screen-map is binary.\n");
error_msg("Input screen-map is binary.\n");
#endif
}
@ -100,7 +100,7 @@ int screen_map_load(int fd, FILE * fp)
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
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);
else
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 (errno == ESPIPE)
/* should not - it succedeed above */
errorMsg("fseek() returned ESPIPE !\n"),
error_msg("fseek() returned ESPIPE !\n"),
exit(1);
else
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);
#if 0
else
errorMsg("Input screen-map is binary.\n");
error_msg("Input screen-map is binary.\n");
#endif
}
@ -132,7 +132,7 @@ int screen_map_load(int fd, FILE * fp)
else
return 0;
}
errorMsg("Error parsing symbolic map\n");
error_msg("Error parsing symbolic map\n");
return(1);
}

View File

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

View File

@ -52,14 +52,14 @@ int loadkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR);
if (fd < 0)
fatalPerror("Error opening /dev/tty0");
perror_msg_and_die("Error opening /dev/tty0");
read(0, buff, 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))
fatalPerror("Error reading keymap flags");
perror_msg_and_die("Error reading keymap flags");
ibuff = (u_short *) xmalloc(ibuffsz);
@ -68,7 +68,7 @@ int loadkmap_main(int argc, char **argv)
pos = 0;
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
fatalPerror("Error reading keymap");
perror_msg_and_die("Error reading keymap");
pos += readsz;
}
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.scancode = sc = strtol(argv[1], &ep, 16);
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) {
a.scancode -= 0xe000;
a.scancode += 128;
}
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)) {
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;
argv += 2;

View File

@ -38,7 +38,7 @@ int chroot_main(int argc, char **argv)
argv++;
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--;
@ -57,7 +57,7 @@ int chroot_main(int argc, char **argv)
return EXIT_SUCCESS;
#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 */
for (ptr = (char *)list; *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 == '-') {
nminus++;
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) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
fatalError("missing list of fields\n");
error_msg_and_die("missing list of fields\n");
}
endpos = startpos;
}
@ -188,14 +188,14 @@ extern int cut_main(int argc, char **argv)
case 'f':
/* make sure they didn't ask for two types of lists */
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;
decompose_list(optarg);
break;
case 'd':
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];
break;
@ -209,16 +209,16 @@ extern int cut_main(int argc, char **argv)
}
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') {
fatalError("suppressing non-delimited lines makes sense
error_msg_and_die("suppressing non-delimited lines makes sense
only when operating on fields\n");
}
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
@ -233,7 +233,7 @@ extern int cut_main(int argc, char **argv)
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
errorMsg("%s: %s\n", argv[i], strerror(errno));
error_msg("%s: %s\n", argv[i], strerror(errno));
} else {
cut_file(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));
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? */
@ -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 */
} else {
fatalError(invalid_date, t_string);
error_msg_and_die(invalid_date, t_string);
}
*tm_time = t;
return (tm_time);
@ -156,7 +156,7 @@ int date_main(int argc, char **argv)
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted);
error_msg_and_die(memory_exhausted);
break;
case 'd':
use_arg = 1;
@ -176,7 +176,7 @@ int date_main(int argc, char **argv)
}
#if 0
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);
}
#endif
@ -205,16 +205,16 @@ int date_main(int argc, char **argv)
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0)
fatalError(invalid_date, date_str);
error_msg_and_die(invalid_date, date_str);
if ( utc ) {
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted);
error_msg_and_die(memory_exhausted);
}
/* if setting time, set it */
if (set_time) {
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))
outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) {
count = getNum((strchr(*argv, '=')) + 1);
count = atoi_w_units((strchr(*argv, '=')) + 1);
if (count < 0) {
errorMsg("Bad count value %s\n", *argv);
error_msg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = getNum((strchr(*argv, '=')) + 1);
blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
errorMsg("Bad block size value %s\n", *argv);
error_msg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = getNum((strchr(*argv, '=')) + 1);
skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
errorMsg("Bad skip value %s\n", *argv);
error_msg("Bad skip value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = getNum((strchr(*argv, '=')) + 1);
seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
errorMsg("Bad seek value %s\n", *argv);
error_msg("Bad seek value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "conv", 4) == 0) {
@ -119,7 +119,7 @@ extern int dd_main(int argc, char **argv)
* here anyways... */
/* free(buf); */
fatalPerror("%s", inFile);
perror_msg_and_die("%s", inFile);
}
if (outFile == NULL)
@ -134,7 +134,7 @@ extern int dd_main(int argc, char **argv)
/* close(inFd);
free(buf); */
fatalPerror("%s", outFile);
perror_msg_and_die("%s", outFile);
}
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
@ -146,13 +146,13 @@ extern int dd_main(int argc, char **argv)
ibs=BUFSIZ;
while (totalSize > outTotal) {
inCc = fullRead(inFd, buf, ibs);
inCc = full_read(inFd, buf, ibs);
inTotal += inCc;
if ( (sync==TRUE) && (inCc>0) )
while (inCc<ibs)
buf[inCc++]='\0';
if ((outCc = fullWrite(outFd, buf, inCc)) < 1){
if ((outCc = full_write(outFd, buf, inCc)) < 1){
if (outCc < 0 ){
perror("Error during write");
}

View File

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

View File

@ -97,7 +97,7 @@ static long du(char *filename)
}
if (len + strlen(name) + 1 > BUFSIZ) {
errorMsg(name_too_long);
error_msg(name_too_long);
du_depth--;
return 0;
}
@ -156,7 +156,7 @@ int du_main(int argc, char **argv)
for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE;
if (sum && isDirectory(argv[i], FALSE, NULL)) {
if (sum && is_directory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]);
}
reset_ino_dev_hashtable();
@ -166,7 +166,7 @@ int du_main(int argc, char **argv)
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:
c-file-style: "linux"

View File

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

View File

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

View File

@ -78,7 +78,7 @@ extern int id_main(int argc, char **argv)
pwnam=my_getpwnam(user);
grnam=my_getgrnam(group);
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)
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);
if (flag&LN_NODEREFERENCE)
srcIsDir = isDirectory(srcName, TRUE, NULL);
srcIsDir = is_directory(srcName, TRUE, NULL);
else
srcIsDir = isDirectory(srcName, FALSE, NULL);
srcIsDir = is_directory(srcName, FALSE, NULL);
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
strcat(srcName, "/");

View File

@ -35,5 +35,5 @@ extern int logname_main(int argc, char **argv)
puts(user);
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
if (follow_links == TRUE) {
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;
free(cur->fullname);
free(cur);
@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur)
} else
#endif
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;
free(cur->fullname);
free(cur);
@ -511,7 +511,7 @@ struct dnode **list_dir(char *path)
nfiles= 0;
dir = opendir(path);
if (dir == NULL) {
errorMsg("%s: %s\n", path, strerror(errno));
error_msg("%s: %s\n", path, strerror(errno));
status = EXIT_FAILURE;
return(NULL); /* could not open the dir */
}
@ -591,7 +591,7 @@ int list_single(struct dnode *dn)
column += 5;
break;
case LIST_MODEBITS:
fprintf(stdout, "%10s", (char *)modeString(dn->dstat.st_mode));
fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:

View File

@ -651,13 +651,13 @@ static int md5_file(const char *filename,
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
errorMsg("%s: %s\n", filename, strerror(errno));
error_msg("%s: %s\n", filename, strerror(errno));
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
errorMsg("%s: %s\n", filename, strerror(errno));
error_msg("%s: %s\n", filename, strerror(errno));
if (fp != stdin)
fclose(fp);
@ -665,7 +665,7 @@ static int md5_file(const char *filename,
}
if (fp != stdin && fclose(fp) == EOF) {
errorMsg("%s: %s\n", filename, strerror(errno));
error_msg("%s: %s\n", filename, strerror(errno));
return FALSE;
}
@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name)
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
errorMsg("%s: %s\n", checkfile_name, strerror(errno));
error_msg("%s: %s\n", checkfile_name, strerror(errno));
return FALSE;
}
}
@ -722,7 +722,7 @@ static int md5_check(const char *checkfile_name)
if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) {
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);
}
} else {
@ -770,18 +770,18 @@ static int md5_check(const char *checkfile_name)
free(line);
if (ferror(checkfile_stream)) {
errorMsg("%s: read error\n", checkfile_name); /* */
error_msg("%s: read error\n", checkfile_name); /* */
return FALSE;
}
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;
}
if (n_properly_formated_lines == 0) {
/* 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);
return FALSE;
} else {
@ -790,13 +790,13 @@ static int md5_check(const char *checkfile_name)
- n_open_or_read_failures);
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);
return FALSE;
}
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);
return FALSE;
}
@ -861,22 +861,22 @@ int md5sum_main(int argc,
}
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;
}
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;
}
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;
}
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;
}
@ -884,7 +884,7 @@ int md5sum_main(int argc,
size_t i;
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;
}
for (i = 0; i < n_strings; ++i) {
@ -898,7 +898,7 @@ int md5sum_main(int argc,
}
} else if (do_check) {
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]);
@ -951,12 +951,12 @@ int md5sum_main(int argc,
}
if (fclose (stdout) == EOF) {
errorMsg("write error\n");
error_msg("write error\n");
return EXIT_FAILURE;
}
if (have_read_stdin && fclose (stdin) == EOF) {
errorMsg("standard input\n");
error_msg("standard input\n");
return EXIT_FAILURE;
}

View File

@ -50,7 +50,7 @@ extern int mkdir_main(int argc, char **argv)
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
errorMsg("Unknown mode: %s\n", *argv);
error_msg("Unknown mode: %s\n", *argv);
return EXIT_FAILURE;
}
/* 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];
if (strlen(*argv) > BUFSIZ - 1) {
errorMsg(name_too_long);
error_msg(name_too_long);
return EXIT_FAILURE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
errorMsg("%s: File exists\n", buf);
error_msg("%s: File exists\n", buf);
return EXIT_FAILURE;
}
if (parentFlag == TRUE) {
strcat(buf, "/");
createPath(buf, mode);
create_path(buf, mode);
} else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror(buf);

View File

@ -84,7 +84,7 @@ int mknod_main(int argc, char **argv)
mode |= perm;
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;
}

View File

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

View File

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

View File

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

View File

@ -247,7 +247,7 @@ int sort_main(int argc, char **argv)
break;
#endif
default:
errorMsg("invalid option -- %c\n", opt);
error_msg("invalid option -- %c\n", opt);
usage(sort_usage);
}
} else {
@ -286,4 +286,4 @@ int sort_main(int argc, char **argv)
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);
break;
default:
errorMsg("\nUnknown arg: %c.\n\n",optopt);
error_msg("\nUnknown arg: %c.\n\n",optopt);
usage(tail_usage);
}
}
@ -263,7 +263,7 @@ int tail_main(int argc, char **argv)
else
fd[test] = open(files[test], O_RDONLY);
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]);
bs=BUFSIZ;

View File

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

View File

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

View File

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

View File

@ -173,7 +173,7 @@ extern int tr_main(int argc, char **argv)
input_length = complement(input, input_length);
if (argv[index] != NULL) {
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);
map(input, input_length, output, output_length);
}

View File

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

View File

@ -142,7 +142,7 @@ static void encode()
}
if (ferror (stdin))
errorMsg("Read error\n");
error_msg("Read error\n");
if (trans_ptr == uu_std) {
putchar (ENC ('\0'));
@ -178,7 +178,7 @@ int uuencode_main (int argc,
case 2:
/* Optional first argument is input file. */
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;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
@ -199,7 +199,7 @@ int uuencode_main (int argc,
encode();
printf(trans_ptr == uu_std ? "end\n" : "====\n");
if (ferror (stdout)) {
errorMsg("Write error\n");
error_msg("Write error\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;

View File

@ -37,5 +37,5 @@ extern int whoami_main(int argc, char **argv)
puts(user);
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
void name_too_long__exit (void)
{
fatalError(name_too_long);
error_msg_and_die(name_too_long);
}
static void
@ -109,14 +109,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (srcDirFlag == TRUE) {
if (recursiveFlag == FALSE) {
errorMsg(omitting_directory, baseSrcName);
error_msg(omitting_directory, baseSrcName);
return TRUE;
}
srcBasename = (strstr(fileName, baseSrcName)
+ strlen(baseSrcName));
if (destLen + strlen(srcBasename) > BUFSIZ) {
errorMsg(name_too_long);
error_msg(name_too_long);
return FALSE;
}
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)) {
mv_Action_first_time = errno = 0;
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));
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 (is_in_ino_dev_hashtable(statbuf, &name)) {
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 TRUE;
@ -152,7 +152,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
add_to_ino_dev_hashtable(statbuf, destName);
}
}
return copyFile(fileName, destName, preserveFlag, followLinks, forceFlag);
return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag);
}
static int
@ -162,11 +162,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
if (S_ISDIR(statbuf->st_mode)) {
if (rmdir(fileName) < 0) {
errorMsg("rmdir(%s): %s\n", fileName, strerror(errno));
error_msg("rmdir(%s): %s\n", fileName, strerror(errno));
status = FALSE;
}
} else if (unlink(fileName) < 0) {
errorMsg("unlink(%s): %s\n", fileName, strerror(errno));
error_msg("unlink(%s): %s\n", fileName, strerror(errno));
status = FALSE;
}
return status;
@ -224,7 +224,7 @@ extern int cp_mv_main(int argc, char **argv)
if (strlen(argv[argc - 1]) > BUFSIZ) {
errorMsg(name_too_long);
error_msg(name_too_long);
goto exit_false;
}
strcpy(baseDestName, argv[argc - 1]);
@ -232,9 +232,9 @@ extern int cp_mv_main(int argc, char **argv)
if (baseDestLen == 0)
goto exit_false;
destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf);
destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf);
if (argc - optind > 2 && destDirFlag == FALSE) {
errorMsg(not_a_directory, baseDestName);
error_msg(not_a_directory, baseDestName);
goto exit_false;
}
@ -250,7 +250,7 @@ extern int cp_mv_main(int argc, char **argv)
if (srcLen == 0) continue; /* "" */
srcDirFlag = isDirectory(baseSrcName, followLinks, &srcStatBuf);
srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf);
if ((flags_memo = (recursiveFlag == TRUE &&
srcDirFlag == TRUE && destDirFlag == TRUE))) {
@ -260,26 +260,26 @@ extern int cp_mv_main(int argc, char **argv)
char *pushd, *d, *p;
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
errorMsg("getcwd(): %s\n", strerror(errno));
error_msg("getcwd(): %s\n", strerror(errno));
continue;
}
if (chdir(baseDestName) < 0) {
errorMsg("chdir(%s): %s\n", baseSrcName, strerror(errno));
error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno));
continue;
}
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
errorMsg("getcwd(): %s\n", strerror(errno));
error_msg("getcwd(): %s\n", strerror(errno));
continue;
}
while (!state && *d != '\0') {
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;
continue;
}
if ((sb.st_ino == srcStatBuf.st_ino) &&
(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,
baseDestName, baseSrcName);
state = -1;
@ -290,7 +290,7 @@ extern int cp_mv_main(int argc, char **argv)
}
}
if (chdir(pushd) < 0) {
errorMsg("chdir(%s): %s\n", pushd, strerror(errno));
error_msg("chdir(%s): %s\n", pushd, strerror(errno));
free(pushd);
free(d);
continue;
@ -305,11 +305,11 @@ extern int cp_mv_main(int argc, char **argv)
status = setjmp(catch);
if (status == 0) {
mv_Action_first_time = 1;
if (recursiveAction(baseSrcName,
if (recursive_action(baseSrcName,
recursiveFlag, followLinks, FALSE,
cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false;
if (dz_i == is_mv &&
recursiveAction(baseSrcName,
recursive_action(baseSrcName,
recursiveFlag, followLinks, TRUE,
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 */
for (ptr = (char *)list; *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 == '-') {
nminus++;
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) {
startpos = strtol(list, &ptr, 10);
if (startpos == 0) {
fatalError("missing list of fields\n");
error_msg_and_die("missing list of fields\n");
}
endpos = startpos;
}
@ -188,14 +188,14 @@ extern int cut_main(int argc, char **argv)
case 'f':
/* make sure they didn't ask for two types of lists */
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;
decompose_list(optarg);
break;
case 'd':
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];
break;
@ -209,16 +209,16 @@ extern int cut_main(int argc, char **argv)
}
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') {
fatalError("suppressing non-delimited lines makes sense
error_msg_and_die("suppressing non-delimited lines makes sense
only when operating on fields\n");
}
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
@ -233,7 +233,7 @@ extern int cut_main(int argc, char **argv)
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
errorMsg("%s: %s\n", argv[i], strerror(errno));
error_msg("%s: %s\n", argv[i], strerror(errno));
} else {
cut_file(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));
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? */
@ -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 */
} else {
fatalError(invalid_date, t_string);
error_msg_and_die(invalid_date, t_string);
}
*tm_time = t;
return (tm_time);
@ -156,7 +156,7 @@ int date_main(int argc, char **argv)
case 'u':
utc = 1;
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted);
error_msg_and_die(memory_exhausted);
break;
case 'd':
use_arg = 1;
@ -176,7 +176,7 @@ int date_main(int argc, char **argv)
}
#if 0
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);
}
#endif
@ -205,16 +205,16 @@ int date_main(int argc, char **argv)
/* Correct any day of week and day of year etc fields */
tm = mktime(&tm_time);
if (tm < 0)
fatalError(invalid_date, date_str);
error_msg_and_die(invalid_date, date_str);
if ( utc ) {
if (putenv("TZ=UTC0") != 0)
fatalError(memory_exhausted);
error_msg_and_die(memory_exhausted);
}
/* if setting time, set it */
if (set_time) {
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)
{
if (pointer >= (sizeof(stack) / sizeof(*stack)))
fatalError("stack overflow\n");
error_msg_and_die("stack overflow\n");
stack[pointer++] = a;
}
static double pop()
{
if (pointer == 0)
fatalError("stack underflow\n");
error_msg_and_die("stack underflow\n");
return stack[--pointer];
}
@ -120,7 +120,7 @@ static void stack_machine(const char *argument)
}
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

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

View File

@ -35,12 +35,12 @@ printf("erik: B\n");
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
errorMsg("0: illegal VT number\n");
error_msg("0: illegal VT number\n");
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)) {
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");

8
df.c
View File

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

6
du.c
View File

@ -97,7 +97,7 @@ static long du(char *filename)
}
if (len + strlen(name) + 1 > BUFSIZ) {
errorMsg(name_too_long);
error_msg(name_too_long);
du_depth--;
return 0;
}
@ -156,7 +156,7 @@ int du_main(int argc, char **argv)
for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE;
if (sum && isDirectory(argv[i], FALSE, NULL)) {
if (sum && is_directory(argv[i], FALSE, NULL)) {
print_normal(sum, argv[i]);
}
reset_ino_dev_hashtable();
@ -166,7 +166,7 @@ int du_main(int argc, char **argv)
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:
c-file-style: "linux"

View File

@ -50,7 +50,7 @@ int dumpkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR);
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;
}
@ -78,7 +78,7 @@ int dumpkmap_main(int argc, char **argv)
ke.kb_table = i;
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 {
write(1,(void*)&ke.kb_value,2);

View File

@ -35,7 +35,7 @@ extern int dutmp_main(int argc, char **argv)
} else {
file = open(argv[1], O_RDONLY);
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] == '/') {
idx = index_of_next_unescaped_slash(my_str, ++idx);
if (idx == -1)
fatalError("unterminated match expression\n");
error_msg_and_die("unterminated match expression\n");
my_str[idx] = '\0';
*regex = (regex_t *)xmalloc(sizeof(regex_t));
xregcomp(*regex, my_str+1, 0);
idx++; /* so it points to the next character after the last '/' */
}
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");
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' */
if (substr[++idx] != '/')
fatalError("bad format in substitution expression\n");
error_msg_and_die("bad format in substitution expression\n");
/* save the match string */
oldidx = idx+1;
idx = index_of_next_unescaped_slash(substr, ++idx);
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);
/* 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;
idx = index_of_next_unescaped_slash(substr, ++idx);
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);
/* 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]))
goto out;
/* 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'))
fatalError("bad format in edit expression\n");
error_msg_and_die("bad format in edit expression\n");
/* store the edit line text */
/* 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 */
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 */
fatalError("invalid command\n");
error_msg_and_die("invalid command\n");
sed_cmd->cmd = cmdstr[idx];
/* 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 */
else if (strchr("aic", cmdstr[idx])) {
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]);
}
/* 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++) {
file = fopen(argv[i], "r");
if (file == NULL) {
errorMsg("%s: %s\n", argv[i], strerror(errno));
error_msg("%s: %s\n", argv[i], strerror(errno));
} else {
process_file(file);
fclose(file);

20
expr.c
View File

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

View File

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

2
find.c
View File

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

View File

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

View File

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

View File

@ -43,10 +43,10 @@ freeramdisk_main(int argc, char **argv)
}
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) {
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
* 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)
{
errorMsg("%s\n", str);
error_msg("%s\n", str);
leave(8);
}

View File

@ -37,7 +37,7 @@
* <misiek@misiek.eu.org>)
* Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org>
* 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
*
*/
@ -258,7 +258,7 @@ void add_long_options(char *options)
arg_opt=required_argument;
}
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);
}
@ -277,7 +277,7 @@ void set_shell(const char *new_shell)
else if (!strcmp(new_shell,"csh"))
shell=TCSH;
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");
exit(0);
} else
fatalError("missing optstring argument\n");
error_msg_and_die("missing optstring argument\n");
}
if (argv[1][0] != '-' || compatible) {
@ -377,7 +377,7 @@ int getopt_main(int argc, char *argv[])
if (!optstr) {
if (optind >= argc)
fatalError("missing optstring argument\n");
error_msg_and_die("missing optstring argument\n");
else {
optstr=xmalloc(strlen(argv[optind])+1);
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");
if (file == NULL) {
if (!suppress_err_msgs)
errorMsg("%s: %s\n", cur_file, strerror(errno));
error_msg("%s: %s\n", cur_file, strerror(errno));
}
else {
grep_file(file);

View File

@ -113,7 +113,7 @@ static char *license_msg[] = {
/* Diagnostic functions */
#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 Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
@ -297,7 +297,7 @@ int in; /* input file descriptor */
method = (int) get_byte();
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;
return -1;
}
@ -1114,13 +1114,13 @@ int in, out; /* input and output file descriptors */
int res = inflate();
if (res == 3) {
errorMsg(memory_exhausted);
error_msg(memory_exhausted);
} else if (res != 0) {
errorMsg("invalid compressed data--format violated\n");
error_msg("invalid compressed data--format violated\n");
}
} else {
errorMsg("internal error, invalid method\n");
error_msg("internal error, invalid method\n");
}
/* Get the crc and original length */
@ -1149,10 +1149,10 @@ int in, out; /* input and output file descriptors */
/* Validate decompression */
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) {
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 */
@ -1225,9 +1225,9 @@ int gunzip_main(int argc, char **argv)
}
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)
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;
@ -1265,7 +1265,7 @@ int gunzip_main(int argc, char **argv)
if (argc <= 0)
usage(gunzip_usage);
if (strlen(*argv) > MAX_PATH_LEN) {
errorMsg(name_too_long);
error_msg(name_too_long);
exit(WARNING);
}
strcpy(ifname, *argv);
@ -1304,7 +1304,7 @@ int gunzip_main(int argc, char **argv)
/* And get to work */
if (strlen(ifname) > MAX_PATH_LEN - 4) {
errorMsg(name_too_long);
error_msg(name_too_long);
exit(WARNING);
}
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 ALLOC(type, array, size) { \
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;}
#else
@ -251,7 +251,7 @@ extern int save_orig_name; /* set if original name must be saved */
/* Diagnostic functions */
#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 Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
@ -1381,7 +1381,7 @@ int length;
(char *) window + start, length) != EQUAL) {
fprintf(stderr,
" start %d, match %d, length %d\n", start, match, length);
errorMsg("invalid match\n");
error_msg("invalid match\n");
}
if (verbose > 1) {
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)
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)
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;
if (foreground) {
@ -2900,7 +2900,7 @@ int eof; /* true if this is the last block for a file */
#endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0)
errorMsg("block vanished\n");
error_msg("block vanished\n");
copy_block(buf, (unsigned) stored_len, 0); /* without header */
compressed_len = stored_len << 3;
@ -3083,7 +3083,7 @@ local void set_file_type()
bin_freq += dyn_ltree[n++].Freq;
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
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 *));
if (nargv == NULL)
errorMsg(memory_exhausted);
error_msg(memory_exhausted);
oargv = *argvp;
*argvp = nargv;
/* Copy the program name first */
if (oargc-- < 0)
errorMsg("argc<=0\n");
error_msg("argc<=0\n");
*(nargv++) = *(oargv++);
/* 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
/* don't assume init's pid == 1 */
return(kill(*(findPidByName("init")), SIGUSR1));
return(kill(*(find_pid_by_name("init")), SIGUSR1));
#else
return(kill(1, SIGUSR1));
#endif

2
head.c
View File

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

View File

@ -1,6 +1,6 @@
/* 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
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@ -40,7 +40,7 @@ void do_sethostname(char *s, int isfile)
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
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
perror("sethostname");
exit(1);

2
id.c
View File

@ -78,7 +78,7 @@ extern int id_main(int argc, char **argv)
pwnam=my_getpwnam(user);
grnam=my_getgrnam(group);
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)
printf("%ld\n", pwnam);

View File

@ -55,8 +55,8 @@
#define BUF_SIZE 8192
#define EXPAND_ALLOC 1024
static inline int isDecimal(ch) { return ((ch >= '0') && (ch <= '9')); }
static inline int isOctal(ch) { return ((ch >= '0') && (ch <= '7')); }
static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
/* Macros for min/max. */
#ifndef MIN
@ -119,14 +119,14 @@ extern const char *applet_name;
extern int applet_name_compare(const void *x, const void *y);
extern void usage(const char *usage) __attribute__ ((noreturn));
extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void perrorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void fatalPerror(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
extern void perror_msg(const char *s, ...) __attribute__ ((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 *timeString(time_t timeVal);
int isDirectory(const char *name, const int followLinks, struct stat *statBuf);
const char *mode_string(int mode);
const char *time_string(time_t timeVal);
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
int isDevice(const char *name);
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 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 copy_file_chunk(int srcFd, int dstFd, size_t remaining);
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 *chunkstrdup(const char *str);
void freeChunks(void);
int fullWrite(int fd, const char *buf, int len);
int fullRead(int fd, char *buf, int len);
int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
int full_write(int fd, const char *buf, int len);
int full_read(int fd, char *buf, int len);
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, 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 get_kernel_revision(void);
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,
char* filesystemType, long flags, char* string_flags);
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_getinfo(const char *match, const char which);
extern int check_wildcard_match(const char* text, const char* pattern);
extern long getNum (const char *cp);
extern pid_t* findPidByName( char* pidName);
extern long atoi_w_units (const char *cp);
extern pid_t* find_pid_by_name( char* pidName);
extern int find_real_root_device_name(char* name);
extern char *get_line_from_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;
if (sysinfo(&info) != 0) {
perrorMsg("Error checking free memory: ");
perror_msg("Error checking free memory: ");
return -1;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -78,7 +78,7 @@
#ifndef MODUTILS_MODULE_H
#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.
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
#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. */
@ -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
the kernel or some external module. */
if (secidx <= SHN_HIRESERVE)
errorMsg("%s multiply defined\n", name);
error_msg("%s multiply defined\n", name);
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. */
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;
}
@ -1433,7 +1433,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
errorMsg("improperly terminated string argument for %s\n", p);
error_msg("improperly terminated string argument for %s\n", p);
return 0;
} else if (*q == '\\')
switch (*++q) {
@ -1562,7 +1562,7 @@ static int old_get_kernel_symbols(const char *m_name)
nks = get_kernel_syms(NULL);
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;
}
@ -1743,7 +1743,7 @@ old_init_module(const char *m_name, struct obj_file *f,
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
: 0), &routines, symtab);
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(symtab);
@ -1786,7 +1786,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
p = get_modinfo_value(f, key);
key += 5;
if (p == NULL) {
errorMsg("invalid parameter %s\n", key);
error_msg("invalid parameter %s\n", key);
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. */
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;
}
@ -1822,7 +1822,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
errorMsg("improperly terminated string argument for %s\n",
error_msg("improperly terminated string argument for %s\n",
key);
return 0;
} 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 */
/* Probably we should do that outside the loop ? */
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);
return 0;
}
@ -1924,7 +1924,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Check length */
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);
return 0;
}
@ -1953,7 +1953,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
break;
default:
errorMsg("unknown parameter type '%c' for %s\n", *p, key);
error_msg("unknown parameter type '%c' for %s\n", *p, key);
return 0;
}
}
@ -1972,21 +1972,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
case ',':
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;
}
++q;
break;
default:
errorMsg("invalid argument syntax for %s\n", key);
error_msg("invalid argument syntax for %s\n", key);
return 0;
}
}
end_of_arg:
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;
}
@ -2055,7 +2055,7 @@ static int new_get_kernel_symbols(void)
module_names = xrealloc(module_names, bufsize = ret);
goto retry_modules_load;
}
errorMsg("QM_MODULES: %s\n", strerror(errno));
error_msg("QM_MODULES: %s\n", strerror(errno));
return 0;
}
@ -2074,7 +2074,7 @@ static int new_get_kernel_symbols(void)
/* The module was removed out from underneath us. */
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;
}
@ -2089,7 +2089,7 @@ static int new_get_kernel_symbols(void)
/* The module was removed out from underneath us. */
continue;
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;
}
}
@ -2114,7 +2114,7 @@ static int new_get_kernel_symbols(void)
syms = xrealloc(syms, bufsize = ret);
goto retry_kern_sym_load;
}
errorMsg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
return 0;
}
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);
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);
@ -2372,7 +2372,7 @@ int obj_check_undefineds(struct obj_file *f)
sym->secidx = SHN_ABS;
sym->value = 0;
} else {
errorMsg("unresolved symbol %s\n", sym->name);
error_msg("unresolved symbol %s\n", sym->name);
ret = 0;
}
}
@ -2599,11 +2599,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base)
errmsg = "Unhandled relocation";
bad_reloc:
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),
strtab + extsym->st_name);
} else {
errorMsg("%s of type %ld\n", errmsg,
error_msg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info));
}
ret = 0;
@ -2680,7 +2680,7 @@ struct obj_file *obj_load(FILE * fp)
fseek(fp, 0, SEEK_SET);
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;
}
@ -2688,25 +2688,25 @@ struct obj_file *obj_load(FILE * fp)
|| f->header.e_ident[EI_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) {
errorMsg("not an ELF file\n");
error_msg("not an ELF file\n");
return NULL;
}
if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) {
errorMsg("ELF file not for this architecture\n");
error_msg("ELF file not for this architecture\n");
return NULL;
}
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;
}
/* Read the section headers. */
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) sizeof(ElfW(Shdr)));
return NULL;
@ -2719,7 +2719,7 @@ struct obj_file *obj_load(FILE * fp)
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
fseek(fp, f->header.e_shoff, SEEK_SET);
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;
}
@ -2749,7 +2749,7 @@ struct obj_file *obj_load(FILE * fp)
sec->contents = xmalloc(sec->header.sh_size);
fseek(fp, sec->header.sh_offset, SEEK_SET);
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;
}
} else {
@ -2759,11 +2759,11 @@ struct obj_file *obj_load(FILE * fp)
#if SHT_RELM == SHT_REL
case SHT_RELA:
errorMsg("RELA relocations not supported on this architecture\n");
error_msg("RELA relocations not supported on this architecture\n");
return NULL;
#else
case SHT_REL:
errorMsg("REL relocations not supported on this architecture\n");
error_msg("REL relocations not supported on this architecture\n");
return NULL;
#endif
@ -2776,7 +2776,7 @@ struct obj_file *obj_load(FILE * fp)
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);
return NULL;
}
@ -2805,7 +2805,7 @@ struct obj_file *obj_load(FILE * fp)
ElfW(Sym) * 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) sizeof(ElfW(Sym)));
return NULL;
@ -2837,7 +2837,7 @@ struct obj_file *obj_load(FILE * fp)
case SHT_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) sizeof(ElfW(RelM)));
return NULL;
@ -2937,17 +2937,17 @@ extern int insmod_main( int argc, char **argv)
/* Get a filedesc for the module */
if ((fp = fopen(*argv, "r")) == NULL) {
/* 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)
{
if (m_filename[0] == '\0'
|| ((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;
}
} 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
memcpy(m_filename, *argv, strlen(*argv));
@ -2971,7 +2971,7 @@ extern int insmod_main( int argc, char **argv)
} else {
m_version = old_get_module_version(f, m_strversion);
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");
goto out;
}
@ -2979,12 +2979,12 @@ extern int insmod_main( int argc, char **argv)
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
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"
"\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion);
} else {
errorMsg("kernel-module version mismatch\n"
error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion);
@ -3002,7 +3002,7 @@ extern int insmod_main( int argc, char **argv)
goto out;
k_crcs = new_is_kernel_checksummed();
#else
errorMsg("Not configured to support new kernels\n");
error_msg("Not configured to support new kernels\n");
goto out;
#endif
} else {
@ -3011,7 +3011,7 @@ extern int insmod_main( int argc, char **argv)
goto out;
k_crcs = old_is_kernel_checksummed();
#else
errorMsg("Not configured to support old kernels\n");
error_msg("Not configured to support old kernels\n");
goto out;
#endif
}
@ -3068,14 +3068,14 @@ extern int insmod_main( int argc, char **argv)
case 0:
break;
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;
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);
goto out;
default:
errorMsg("create_module: %s: %s\n", m_name, strerror(errno));
error_msg("create_module: %s: %s\n", m_name, strerror(errno));
goto out;
}

14
kill.c
View File

@ -204,10 +204,10 @@ extern int kill_main(int argc, char **argv)
int pid;
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);
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++;
}
}
@ -219,20 +219,20 @@ extern int kill_main(int argc, char **argv)
while (--argc >= 0) {
pid_t* pidList;
pidList = findPidByName( *argv);
pidList = find_pid_by_name( *argv);
if (!pidList) {
all_found = FALSE;
errorMsg( "%s: no process killed\n", *argv);
error_msg( "%s: no process killed\n", *argv);
}
for(; pidList && *pidList!=0; pidList++) {
if (*pidList==myPid)
continue;
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
* 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 */
argv++;
}
@ -245,5 +245,5 @@ extern int kill_main(int argc, char **argv)
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++;
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));
}
return EXIT_SUCCESS;
@ -273,12 +273,12 @@ static int builtin_fg_bg(struct job *cmd, struct jobSet *jobList)
if (!jobList->head) {
if (!cmd->progs[0].argv[1] || cmd->progs[0].argv[2]) {
errorMsg("%s: exactly one argument is expected\n",
error_msg("%s: exactly one argument is expected\n",
cmd->progs[0].argv[0]);
return EXIT_FAILURE;
}
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]);
return EXIT_FAILURE;
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) {
errorMsg("%s: unknown job %d\n",
error_msg("%s: unknown job %d\n",
cmd->progs[0].argv[0], jobNum);
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 ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
errorMsg("unexpected token `then'\n");
error_msg("unexpected token `then'\n");
return EXIT_FAILURE;
}
/* 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 ' */
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
errorMsg("unexpected token `else'\n");
error_msg("unexpected token `else'\n");
return EXIT_FAILURE;
}
/* 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)
{
if (! (cmd->jobContext & (IF_TRUE_CONTEXT|IF_FALSE_CONTEXT))) {
errorMsg("unexpected token `fi'\n");
error_msg("unexpected token `fi'\n");
return EXIT_FAILURE;
}
/* Clear out the if and then context bits */
@ -646,7 +646,7 @@ static int setupRedirections(struct childProgram *prog)
if (openfd < 0) {
/* this could get lost if stderr has been redirected, but
bash and ash both lose it as well (though zsh doesn't!) */
errorMsg("error opening %s: %s\n", redir->filename,
error_msg("error opening %s: %s\n", redir->filename,
strerror(errno));
return 1;
}
@ -820,7 +820,7 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
if (strpbrk(prog->argv[argc_l - 1],"*[]?")!= NULL){
rc = glob(prog->argv[argc_l - 1], flags, NULL, &prog->globResult);
if (rc == GLOB_NOSPACE) {
errorMsg("out of space during glob operation\n");
error_msg("out of space during glob operation\n");
return;
} else if (rc == GLOB_NOMATCH ||
(!rc && (prog->globResult.gl_pathc - i) == 1 &&
@ -927,7 +927,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*src == '\\') {
src++;
if (!*src) {
errorMsg("character expected after \\\n");
error_msg("character expected after \\\n");
freeJob(job);
return 1;
}
@ -1009,7 +1009,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
chptr++;
if (!*chptr) {
errorMsg("file name expected after %c\n", *src);
error_msg("file name expected after %c\n", *src);
freeJob(job);
job->numProgs=0;
return 1;
@ -1028,7 +1028,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
if (*prog->argv[argc_l])
argc_l++;
if (!argc_l) {
errorMsg("empty command in pipe\n");
error_msg("empty command in pipe\n");
freeJob(job);
job->numProgs=0;
return 1;
@ -1055,7 +1055,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
src++;
if (!*src) {
errorMsg("empty command in pipe\n");
error_msg("empty command in pipe\n");
freeJob(job);
job->numProgs=0;
return 1;
@ -1114,7 +1114,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
* command line, making extra room as needed */
--src;
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);
if (newSize > BUFSIZ) {
*commandPtr=xrealloc(*commandPtr, src - *commandPtr +
@ -1145,7 +1145,7 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
case '\\':
src++;
if (!*src) {
errorMsg("character expected after \\\n");
error_msg("character expected after \\\n");
freeJob(job);
return 1;
}
@ -1291,7 +1291,7 @@ static int runCommand(struct job *newJob, struct jobSet *jobList, int inBg, int
#endif
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));
}
if (outPipe[1]!=-1) {
@ -1495,7 +1495,7 @@ int shell_main(int argc_l, char **argv_l)
case 'c':
input = NULL;
if (local_pending_command != 0)
fatalError("multiple -c arguments\n");
error_msg_and_die("multiple -c arguments\n");
local_pending_command = xstrdup(argv[optind]);
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);
if (flag&LN_NODEREFERENCE)
srcIsDir = isDirectory(srcName, TRUE, NULL);
srcIsDir = is_directory(srcName, TRUE, NULL);
else
srcIsDir = isDirectory(srcName, FALSE, NULL);
srcIsDir = is_directory(srcName, FALSE, NULL);
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
strcat(srcName, "/");

View File

@ -39,12 +39,12 @@ int loadacm_main(int argc, char **argv)
fd = open("/dev/tty", O_RDWR);
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;
}
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;
}
@ -72,7 +72,7 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
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);
else
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);
#if 0
else
errorMsg("Input screen-map is binary.\n");
error_msg("Input screen-map is binary.\n");
#endif
}
@ -100,7 +100,7 @@ int screen_map_load(int fd, FILE * fp)
/* rewind... */
if (-1 == fseek(fp, 0, SEEK_SET)) {
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);
else
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 (errno == ESPIPE)
/* should not - it succedeed above */
errorMsg("fseek() returned ESPIPE !\n"),
error_msg("fseek() returned ESPIPE !\n"),
exit(1);
else
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);
#if 0
else
errorMsg("Input screen-map is binary.\n");
error_msg("Input screen-map is binary.\n");
#endif
}
@ -132,7 +132,7 @@ int screen_map_load(int fd, FILE * fp)
else
return 0;
}
errorMsg("Error parsing symbolic map\n");
error_msg("Error parsing symbolic map\n");
return(1);
}

View File

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

View File

@ -52,14 +52,14 @@ int loadkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR);
if (fd < 0)
fatalPerror("Error opening /dev/tty0");
perror_msg_and_die("Error opening /dev/tty0");
read(0, buff, 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))
fatalPerror("Error reading keymap flags");
perror_msg_and_die("Error reading keymap flags");
ibuff = (u_short *) xmalloc(ibuffsz);
@ -68,7 +68,7 @@ int loadkmap_main(int argc, char **argv)
pos = 0;
while (pos < ibuffsz) {
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
fatalPerror("Error reading keymap");
perror_msg_and_die("Error reading keymap");
pos += readsz;
}
for (j = 0; j < NR_KEYS; j++) {

View File

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

View File

@ -35,5 +35,5 @@ extern int logname_main(int argc, char **argv)
puts(user);
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
if (follow_links == TRUE) {
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;
free(cur->fullname);
free(cur);
@ -190,7 +190,7 @@ static int my_stat(struct dnode *cur)
} else
#endif
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;
free(cur->fullname);
free(cur);
@ -511,7 +511,7 @@ struct dnode **list_dir(char *path)
nfiles= 0;
dir = opendir(path);
if (dir == NULL) {
errorMsg("%s: %s\n", path, strerror(errno));
error_msg("%s: %s\n", path, strerror(errno));
status = EXIT_FAILURE;
return(NULL); /* could not open the dir */
}
@ -591,7 +591,7 @@ int list_single(struct dnode *dn)
column += 5;
break;
case LIST_MODEBITS:
fprintf(stdout, "%10s", (char *)modeString(dn->dstat.st_mode));
fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:

View File

@ -83,7 +83,7 @@ extern int lsmod_main(int argc, char **argv)
module_names = xmalloc(bufsize = 256);
deps = xmalloc(bufsize);
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");
@ -94,7 +94,7 @@ extern int lsmod_main(int argc, char **argv)
continue;
}
/* 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)) {
if (errno == ENOENT) {
@ -102,7 +102,7 @@ extern int lsmod_main(int argc, char **argv)
continue;
}
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);
}
@ -153,7 +153,7 @@ extern int lsmod_main(int argc, char **argv)
close(fd);
return 0;
}
fatalError("/proc/modules: %s\n", strerror(errno));
error_msg_and_die("/proc/modules: %s\n", strerror(errno));
return 1;
}

View File

@ -651,13 +651,13 @@ static int md5_file(const char *filename,
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
errorMsg("%s: %s\n", filename, strerror(errno));
error_msg("%s: %s\n", filename, strerror(errno));
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
errorMsg("%s: %s\n", filename, strerror(errno));
error_msg("%s: %s\n", filename, strerror(errno));
if (fp != stdin)
fclose(fp);
@ -665,7 +665,7 @@ static int md5_file(const char *filename,
}
if (fp != stdin && fclose(fp) == EOF) {
errorMsg("%s: %s\n", filename, strerror(errno));
error_msg("%s: %s\n", filename, strerror(errno));
return FALSE;
}
@ -689,7 +689,7 @@ static int md5_check(const char *checkfile_name)
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
errorMsg("%s: %s\n", checkfile_name, strerror(errno));
error_msg("%s: %s\n", checkfile_name, strerror(errno));
return FALSE;
}
}
@ -722,7 +722,7 @@ static int md5_check(const char *checkfile_name)
if (split_3(line, line_length, &md5num, &binary, &filename)
|| !hex_digits(md5num)) {
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);
}
} else {
@ -770,18 +770,18 @@ static int md5_check(const char *checkfile_name)
free(line);
if (ferror(checkfile_stream)) {
errorMsg("%s: read error\n", checkfile_name); /* */
error_msg("%s: read error\n", checkfile_name); /* */
return FALSE;
}
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;
}
if (n_properly_formated_lines == 0) {
/* 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);
return FALSE;
} else {
@ -790,13 +790,13 @@ static int md5_check(const char *checkfile_name)
- n_open_or_read_failures);
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);
return FALSE;
}
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);
return FALSE;
}
@ -861,22 +861,22 @@ int md5sum_main(int argc,
}
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;
}
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;
}
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;
}
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;
}
@ -884,7 +884,7 @@ int md5sum_main(int argc,
size_t i;
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;
}
for (i = 0; i < n_strings; ++i) {
@ -898,7 +898,7 @@ int md5sum_main(int argc,
}
} else if (do_check) {
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]);
@ -951,12 +951,12 @@ int md5sum_main(int argc,
}
if (fclose (stdout) == EOF) {
errorMsg("write error\n");
error_msg("write error\n");
return EXIT_FAILURE;
}
if (have_read_stdin && fclose (stdin) == EOF) {
errorMsg("standard input\n");
error_msg("standard input\n");
return EXIT_FAILURE;
}

View File

@ -14,14 +14,14 @@ static unsigned int pointer;
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack)))
fatalError("stack overflow\n");
error_msg_and_die("stack overflow\n");
stack[pointer++] = a;
}
static double pop()
{
if (pointer == 0)
fatalError("stack underflow\n");
error_msg_and_die("stack underflow\n");
return stack[--pointer];
}
@ -120,7 +120,7 @@ static void stack_machine(const char *argument)
}
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

View File

@ -35,7 +35,7 @@ extern int dutmp_main(int argc, char **argv)
} else {
file = open(argv[1], O_RDONLY);
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) {
errorMsg("unrecognized opcode %s.\n", argv[1]);
error_msg("unrecognized opcode %s.\n", argv[1]);
return EXIT_FAILURE;
}

View File

@ -39,7 +39,7 @@ int readlink_main(int argc, char **argv)
buf = xrealloc(buf, bufsize);
size = readlink(argv[1], buf, bufsize);
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';

View File

@ -50,7 +50,7 @@ extern int mkdir_main(int argc, char **argv)
/* Find the specified modes */
mode = 0;
if (parse_mode(*(++argv), &mode) == FALSE) {
errorMsg("Unknown mode: %s\n", *argv);
error_msg("Unknown mode: %s\n", *argv);
return EXIT_FAILURE;
}
/* 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];
if (strlen(*argv) > BUFSIZ - 1) {
errorMsg(name_too_long);
error_msg(name_too_long);
return EXIT_FAILURE;
}
strcpy(buf, *argv);
status = stat(buf, &statBuf);
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
errorMsg("%s: File exists\n", buf);
error_msg("%s: File exists\n", buf);
return EXIT_FAILURE;
}
if (parentFlag == TRUE) {
strcat(buf, "/");
createPath(buf, mode);
create_path(buf, mode);
} else {
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
perror(buf);

View File

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

View File

@ -84,7 +84,7 @@ int mknod_main(int argc, char **argv)
mode |= perm;
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;
}

View File

@ -87,7 +87,7 @@ static void init_signature_page()
#ifdef PAGE_SIZE
if (pagesize != PAGE_SIZE)
errorMsg("Assuming pages of size %d\n", pagesize);
error_msg("Assuming pages of size %d\n", pagesize);
#endif
signature_page = (int *) xmalloc(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)
{
errorMsg("%s\n", str);
error_msg("%s\n", str);
exit(EXIT_FAILURE);
}
@ -316,14 +316,14 @@ int mkswap_main(int argc, char **argv)
}
}
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);
}
sz = get_size(device_name);
if (!PAGES) {
PAGES = sz;
} 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));
return EXIT_FAILURE;
}
@ -339,11 +339,11 @@ int mkswap_main(int argc, char **argv)
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);
}
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));
usage(mkswap_usage);
}
@ -362,7 +362,7 @@ int mkswap_main(int argc, char **argv)
#endif
if (PAGES > maxpages) {
PAGES = maxpages;
errorMsg("warning: truncating swap area to %ldkB\n",
error_msg("warning: truncating swap area to %ldkB\n",
PAGES * pagesize / 1024);
}
@ -389,7 +389,7 @@ int mkswap_main(int argc, char **argv)
for (sum = 0; q >= (unsigned short *) buffer;)
sum ^= *q--;
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"
"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);

View File

@ -78,7 +78,7 @@
#ifndef MODUTILS_MODULE_H
#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.
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
#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. */
@ -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
the kernel or some external module. */
if (secidx <= SHN_HIRESERVE)
errorMsg("%s multiply defined\n", name);
error_msg("%s multiply defined\n", name);
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. */
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;
}
@ -1433,7 +1433,7 @@ old_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
errorMsg("improperly terminated string argument for %s\n", p);
error_msg("improperly terminated string argument for %s\n", p);
return 0;
} else if (*q == '\\')
switch (*++q) {
@ -1562,7 +1562,7 @@ static int old_get_kernel_symbols(const char *m_name)
nks = get_kernel_syms(NULL);
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;
}
@ -1743,7 +1743,7 @@ old_init_module(const char *m_name, struct obj_file *f,
m_size | (flag_autoclean ? OLD_MOD_AUTOCLEAN
: 0), &routines, symtab);
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(symtab);
@ -1786,7 +1786,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
p = get_modinfo_value(f, key);
key += 5;
if (p == NULL) {
errorMsg("invalid parameter %s\n", key);
error_msg("invalid parameter %s\n", key);
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. */
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;
}
@ -1822,7 +1822,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
str = alloca(strlen(q));
for (r = str, q++; *q != '"'; ++q, ++r) {
if (*q == '\0') {
errorMsg("improperly terminated string argument for %s\n",
error_msg("improperly terminated string argument for %s\n",
key);
return 0;
} 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 */
/* Probably we should do that outside the loop ? */
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);
return 0;
}
@ -1924,7 +1924,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
/* Check length */
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);
return 0;
}
@ -1953,7 +1953,7 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
break;
default:
errorMsg("unknown parameter type '%c' for %s\n", *p, key);
error_msg("unknown parameter type '%c' for %s\n", *p, key);
return 0;
}
}
@ -1972,21 +1972,21 @@ new_process_module_arguments(struct obj_file *f, int argc, char **argv)
case ',':
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;
}
++q;
break;
default:
errorMsg("invalid argument syntax for %s\n", key);
error_msg("invalid argument syntax for %s\n", key);
return 0;
}
}
end_of_arg:
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;
}
@ -2055,7 +2055,7 @@ static int new_get_kernel_symbols(void)
module_names = xrealloc(module_names, bufsize = ret);
goto retry_modules_load;
}
errorMsg("QM_MODULES: %s\n", strerror(errno));
error_msg("QM_MODULES: %s\n", strerror(errno));
return 0;
}
@ -2074,7 +2074,7 @@ static int new_get_kernel_symbols(void)
/* The module was removed out from underneath us. */
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;
}
@ -2089,7 +2089,7 @@ static int new_get_kernel_symbols(void)
/* The module was removed out from underneath us. */
continue;
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;
}
}
@ -2114,7 +2114,7 @@ static int new_get_kernel_symbols(void)
syms = xrealloc(syms, bufsize = ret);
goto retry_kern_sym_load;
}
errorMsg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
error_msg("kernel: QM_SYMBOLS: %s\n", strerror(errno));
return 0;
}
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);
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);
@ -2372,7 +2372,7 @@ int obj_check_undefineds(struct obj_file *f)
sym->secidx = SHN_ABS;
sym->value = 0;
} else {
errorMsg("unresolved symbol %s\n", sym->name);
error_msg("unresolved symbol %s\n", sym->name);
ret = 0;
}
}
@ -2599,11 +2599,11 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base)
errmsg = "Unhandled relocation";
bad_reloc:
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),
strtab + extsym->st_name);
} else {
errorMsg("%s of type %ld\n", errmsg,
error_msg("%s of type %ld\n", errmsg,
(long) ELFW(R_TYPE) (rel->r_info));
}
ret = 0;
@ -2680,7 +2680,7 @@ struct obj_file *obj_load(FILE * fp)
fseek(fp, 0, SEEK_SET);
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;
}
@ -2688,25 +2688,25 @@ struct obj_file *obj_load(FILE * fp)
|| f->header.e_ident[EI_MAG1] != ELFMAG1
|| f->header.e_ident[EI_MAG2] != ELFMAG2
|| f->header.e_ident[EI_MAG3] != ELFMAG3) {
errorMsg("not an ELF file\n");
error_msg("not an ELF file\n");
return NULL;
}
if (f->header.e_ident[EI_CLASS] != ELFCLASSM
|| f->header.e_ident[EI_DATA] != ELFDATAM
|| f->header.e_ident[EI_VERSION] != EV_CURRENT
|| !MATCH_MACHINE(f->header.e_machine)) {
errorMsg("ELF file not for this architecture\n");
error_msg("ELF file not for this architecture\n");
return NULL;
}
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;
}
/* Read the section headers. */
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) sizeof(ElfW(Shdr)));
return NULL;
@ -2719,7 +2719,7 @@ struct obj_file *obj_load(FILE * fp)
section_headers = alloca(sizeof(ElfW(Shdr)) * shnum);
fseek(fp, f->header.e_shoff, SEEK_SET);
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;
}
@ -2749,7 +2749,7 @@ struct obj_file *obj_load(FILE * fp)
sec->contents = xmalloc(sec->header.sh_size);
fseek(fp, sec->header.sh_offset, SEEK_SET);
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;
}
} else {
@ -2759,11 +2759,11 @@ struct obj_file *obj_load(FILE * fp)
#if SHT_RELM == SHT_REL
case SHT_RELA:
errorMsg("RELA relocations not supported on this architecture\n");
error_msg("RELA relocations not supported on this architecture\n");
return NULL;
#else
case SHT_REL:
errorMsg("REL relocations not supported on this architecture\n");
error_msg("REL relocations not supported on this architecture\n");
return NULL;
#endif
@ -2776,7 +2776,7 @@ struct obj_file *obj_load(FILE * fp)
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);
return NULL;
}
@ -2805,7 +2805,7 @@ struct obj_file *obj_load(FILE * fp)
ElfW(Sym) * 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) sizeof(ElfW(Sym)));
return NULL;
@ -2837,7 +2837,7 @@ struct obj_file *obj_load(FILE * fp)
case SHT_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) sizeof(ElfW(RelM)));
return NULL;
@ -2937,17 +2937,17 @@ extern int insmod_main( int argc, char **argv)
/* Get a filedesc for the module */
if ((fp = fopen(*argv, "r")) == NULL) {
/* 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)
{
if (m_filename[0] == '\0'
|| ((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;
}
} 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
memcpy(m_filename, *argv, strlen(*argv));
@ -2971,7 +2971,7 @@ extern int insmod_main( int argc, char **argv)
} else {
m_version = old_get_module_version(f, m_strversion);
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");
goto out;
}
@ -2979,12 +2979,12 @@ extern int insmod_main( int argc, char **argv)
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
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"
"\twhile this kernel is version %s\n",
m_filename, m_strversion, k_strversion);
} else {
errorMsg("kernel-module version mismatch\n"
error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.\n",
m_filename, m_strversion, k_strversion);
@ -3002,7 +3002,7 @@ extern int insmod_main( int argc, char **argv)
goto out;
k_crcs = new_is_kernel_checksummed();
#else
errorMsg("Not configured to support new kernels\n");
error_msg("Not configured to support new kernels\n");
goto out;
#endif
} else {
@ -3011,7 +3011,7 @@ extern int insmod_main( int argc, char **argv)
goto out;
k_crcs = old_is_kernel_checksummed();
#else
errorMsg("Not configured to support old kernels\n");
error_msg("Not configured to support old kernels\n");
goto out;
#endif
}
@ -3068,14 +3068,14 @@ extern int insmod_main( int argc, char **argv)
case 0:
break;
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;
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);
goto out;
default:
errorMsg("create_module: %s: %s\n", m_name, strerror(errno));
error_msg("create_module: %s: %s\n", m_name, strerror(errno));
goto out;
}

View File

@ -83,7 +83,7 @@ extern int lsmod_main(int argc, char **argv)
module_names = xmalloc(bufsize = 256);
deps = xmalloc(bufsize);
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");
@ -94,7 +94,7 @@ extern int lsmod_main(int argc, char **argv)
continue;
}
/* 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)) {
if (errno == ENOENT) {
@ -102,7 +102,7 @@ extern int lsmod_main(int argc, char **argv)
continue;
}
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);
}
@ -153,7 +153,7 @@ extern int lsmod_main(int argc, char **argv)
close(fd);
return 0;
}
fatalError("/proc/modules: %s\n", strerror(errno));
error_msg_and_die("/proc/modules: %s\n", strerror(errno));
return 1;
}

28
mount.c
View File

@ -132,22 +132,22 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
specialfile = find_unused_loop_device();
if (specialfile == NULL) {
errorMsg("Could not find a spare loop device\n");
error_msg("Could not find a spare loop device\n");
return (FALSE);
}
if (set_loop(specialfile, lofile, 0, &loro)) {
errorMsg("Could not setup loop device\n");
error_msg("Could not setup loop device\n");
return (FALSE);
}
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;
}
}
#endif
status = mount(specialfile, dir, filesystemtype, flags, string_flags);
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);
}
}
@ -173,7 +173,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
#endif
if (errno == EPERM) {
fatalError("permission denied. Are you root?\n");
error_msg_and_die("permission denied. Are you root?\n");
}
return (FALSE);
@ -273,18 +273,18 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
/* open device */
fd = open(device, O_RDONLY);
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 */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS);
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));
/* Grab the list of available filesystems */
status = ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist);
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
* that do not claim to be nodev filesystems */
@ -309,7 +309,7 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
if (status == FALSE) {
if (whineOnErrors == TRUE) {
errorMsg("Mounting %s on %s failed: %s\n",
error_msg("Mounting %s on %s failed: %s\n",
blockDevice, directory, strerror(errno));
}
return (FALSE);
@ -342,18 +342,18 @@ extern int mount_main(int argc, char **argv)
/* open device */
fd = open(device, O_RDONLY);
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
* allocate enough space for later... */
numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
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));
/* Grab the list of mounted filesystems */
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++) {
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;
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) {
if (all == FALSE && directory == NULL && (
@ -488,7 +488,7 @@ singlemount:
rc = nfsmount (device, directory, &flags,
&extra_opts, &string_flags, 1);
if ( rc != 0) {
fatalError("nfsmount failed: %s\n", strerror(errno));
error_msg_and_die("nfsmount failed: %s\n", strerror(errno));
rc = EXIT_FAILURE;
}
}

2
mt.c
View File

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

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