Commit ac5bd7bf authored by Philip Carns's avatar Philip Carns

updated darshan-util to give better error messages if the user attempts to

process a bz2 file without compiling in bz2 support


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@494 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 2794e65d
...@@ -41,7 +41,7 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p ...@@ -41,7 +41,7 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
zfile = darshan_log_open(fname, "r"); zfile = darshan_log_open(fname, "r");
if (zfile == NULL) if (zfile == NULL)
{ {
perror("darshan_log_open"); fprintf(stderr, "darshan_log_open() failed to open %s\n.", fname);
return -1; return -1;
} }
......
...@@ -157,9 +157,7 @@ int main(int argc, char **argv) ...@@ -157,9 +157,7 @@ int main(int argc, char **argv)
infile = darshan_log_open(infile_name, "r"); infile = darshan_log_open(infile_name, "r");
if(!infile) if(!infile)
{ {
char errmsg[256]; fprintf(stderr, "darshan_log_open() failed to open %s\n.", infile_name);
sprintf(errmsg, "darshan_log_open: %s", infile_name);
perror(errmsg);
return(-1); return(-1);
} }
...@@ -169,9 +167,7 @@ int main(int argc, char **argv) ...@@ -169,9 +167,7 @@ int main(int argc, char **argv)
outfile = darshan_log_open(outfile_name, "w"); outfile = darshan_log_open(outfile_name, "w");
if(!outfile) if(!outfile)
{ {
char errmsg[256]; fprintf(stderr, "darshan_log_open() failed to open %s\n.", outfile_name);
sprintf(errmsg, "darshan_log_open: %s", outfile_name);
perror(errmsg);
return(-1); return(-1);
} }
......
...@@ -45,12 +45,12 @@ int main(int argc, char ** argv) ...@@ -45,12 +45,12 @@ int main(int argc, char ** argv)
file1 = darshan_log_open(argv[1], "r"); file1 = darshan_log_open(argv[1], "r");
if(!file1) { if(!file1) {
perror("darshan_log_open"); fprintf(stderr, "darshan_log_open() failed to open %s\n.", argv[1]);
return(-1); return(-1);
} }
file2 = darshan_log_open(argv[2], "r"); file2 = darshan_log_open(argv[2], "r");
if(!file2) { if(!file2) {
perror("darshan_log_open"); fprintf(stderr, "darshan_log_open() failed to open %s\n.", argv[2]);
return(-1); return(-1);
} }
......
...@@ -97,7 +97,7 @@ int tree_walk (const char *fpath, const struct stat *sb, int typeflag) ...@@ -97,7 +97,7 @@ int tree_walk (const char *fpath, const struct stat *sb, int typeflag)
dfile = darshan_log_open(fpath, "r"); dfile = darshan_log_open(fpath, "r");
if (dfile == NULL) if (dfile == NULL)
{ {
perror("darshan_log_open"); fprintf(stderr, "darshan_log_open() failed to open %s\n.", fpath);
rc = CONTWALK; rc = CONTWALK;
goto exit; goto exit;
} }
......
...@@ -251,7 +251,6 @@ darshan_fd darshan_log_open(const char *name, const char* mode) ...@@ -251,7 +251,6 @@ darshan_fd darshan_log_open(const char *name, const char* mode)
return(NULL); return(NULL);
} }
#ifdef HAVE_LIBBZ2
if(strcmp(mode, "r") == 0) if(strcmp(mode, "r") == 0)
{ {
/* Try to detect if existing file is a bzip2 file or not. Both /* Try to detect if existing file is a bzip2 file or not. Both
...@@ -284,6 +283,7 @@ darshan_fd darshan_log_open(const char *name, const char* mode) ...@@ -284,6 +283,7 @@ darshan_fd darshan_log_open(const char *name, const char* mode)
} }
close(test_fd); close(test_fd);
} }
if(strcmp(mode, "w") == 0) if(strcmp(mode, "w") == 0)
{ {
/* TODO: is this the behavior that we want? */ /* TODO: is this the behavior that we want? */
...@@ -296,6 +296,7 @@ darshan_fd darshan_log_open(const char *name, const char* mode) ...@@ -296,6 +296,7 @@ darshan_fd darshan_log_open(const char *name, const char* mode)
try_bz2 = 0; try_bz2 = 0;
} }
#ifdef HAVE_LIBBZ2
if(try_bz2) if(try_bz2)
{ {
tmp_fd->bzf = BZ2_bzopen(name, mode); tmp_fd->bzf = BZ2_bzopen(name, mode);
...@@ -307,6 +308,13 @@ darshan_fd darshan_log_open(const char *name, const char* mode) ...@@ -307,6 +308,13 @@ darshan_fd darshan_log_open(const char *name, const char* mode)
} }
return(tmp_fd); return(tmp_fd);
} }
#else
if(try_bz2)
{
fprintf(stderr, "Error: this Darshan build does not support bz2 files.\n");
fprintf(stderr, "Error: please install libbz2-dev and reconfigure.\n");
return(NULL);
}
#endif #endif
tmp_fd->gzf = gzopen(name, mode); tmp_fd->gzf = gzopen(name, mode);
......
...@@ -207,7 +207,7 @@ int main(int argc, char **argv) ...@@ -207,7 +207,7 @@ int main(int argc, char **argv)
file = darshan_log_open(filename, "r"); file = darshan_log_open(filename, "r");
if(!file) if(!file)
{ {
perror("darshan_log_open"); fprintf(stderr, "darshan_log_open() failed to open %s\n.", filename);
return(-1); return(-1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment