Commit a2d4d607 authored by Shane Snyder's avatar Shane Snyder

update darshan-util to error with invalid versions

darshan-logutils now returns an error when encountering a log file
with a module version number greater than what the library was
built with. all utilities were also updated to account for this
modification
parent 297778b8
......@@ -360,6 +360,7 @@ int main(int argc, char **argv)
{
darshan_log_close(infile);
darshan_log_close(outfile);
unlink(outfile_name);
return(-1);
}
......@@ -368,6 +369,7 @@ int main(int argc, char **argv)
{
darshan_log_close(infile);
darshan_log_close(outfile);
unlink(outfile_name);
return(-1);
}
......@@ -389,19 +391,8 @@ int main(int argc, char **argv)
/* we have module data to convert */
memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
ret = mod_logutils[i]->log_get_record(infile, (void **)&mod_buf);
if(ret != 1)
{
fprintf(stderr, "Error: failed to parse the first %s module record.\n",
darshan_module_names[i]);
darshan_log_close(infile);
darshan_log_close(outfile);
unlink(outfile_name);
return(-1);
}
/* loop over each of the module's records and convert */
do
while((ret = mod_logutils[i]->log_get_record(infile, (void **)&mod_buf)) == 1)
{
base_rec = (struct darshan_base_record *)mod_buf;
......@@ -412,12 +403,22 @@ int main(int argc, char **argv)
{
darshan_log_close(infile);
darshan_log_close(outfile);
unlink(outfile_name);
return(-1);
}
memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
}
} while((ret = mod_logutils[i]->log_get_record(infile, (void **)&mod_buf)) == 1);
}
if(ret < 0)
{
fprintf(stderr, "Error: failed to parse %s module record.\n",
darshan_module_names[i]);
darshan_log_close(infile);
darshan_log_close(outfile);
unlink(outfile_name);
return(-1);
}
}
darshan_log_close(infile);
......
......@@ -384,13 +384,11 @@ static int darshan_build_global_record_hash(
{
fprintf(stderr, "Error: unable to read module %s data from log file.\n",
darshan_module_names[i]);
free(mod_rec->mod_dat);
free(mod_rec);
return(-1);
}
else if(ret == 0)
{
free(mod_rec->mod_dat);
free(mod_rec);
break;
}
......
......@@ -643,6 +643,17 @@ int darshan_log_get_mod(darshan_fd fd, darshan_module_id mod_id,
if(fd->mod_map[mod_id].len == 0)
return(0); /* no data corresponding to this mod_id */
/* assume module will support backwards compatibility, but we obviously
* can't provide any sort of "forwards" compatibility
*/
if(fd->mod_ver[mod_id] > darshan_module_versions[mod_id])
{
fprintf(stderr, "Error: invalid %s module log format version "
"(expected %d, got %d)\n", darshan_module_names[mod_id],
darshan_module_versions[mod_id], fd->mod_ver[mod_id]);
return(-1);
}
/* read this module's data from the log file */
ret = darshan_log_dzread(fd, mod_id, mod_buf, mod_buf_sz);
if(ret < 0)
......
......@@ -398,7 +398,8 @@ int main(int argc, char **argv)
/* currently only POSIX, MPIIO, and STDIO modules support non-base
* parsing
*/
else if((i != DARSHAN_POSIX_MOD) && (i != DARSHAN_MPIIO_MOD) && (i != DARSHAN_STDIO_MOD) && !(mask & OPTION_BASE))
else if((i != DARSHAN_POSIX_MOD) && (i != DARSHAN_MPIIO_MOD) &&
(i != DARSHAN_STDIO_MOD) && !(mask & OPTION_BASE))
continue;
/* this module has data to be parsed and printed */
......@@ -425,22 +426,24 @@ int main(int argc, char **argv)
}
}
ret = mod_logutils[i]->log_get_record(fd, (void **)&mod_buf);
if(ret != 1)
{
fprintf(stderr, "Error: failed to parse the first %s module record.\n",
darshan_module_names[i]);
ret = -1;
goto cleanup;
}
/* loop over each of this module's records and print them */
do
while(1)
{
char *mnt_pt = NULL;
char *fs_type = NULL;
char *rec_name = NULL;
hash_entry_t *hfile = NULL;
ret = mod_logutils[i]->log_get_record(fd, (void **)&mod_buf);
if(ret < 1)
{
if(ret == -1)
{
fprintf(stderr, "Error: failed to parse %s module record.\n",
darshan_module_names[i]);
}
break;
}
base_rec = (struct darshan_base_record *)mod_buf;
/* get the pathname for this record */
......@@ -528,13 +531,9 @@ int main(int argc, char **argv)
}
memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
} while((ret = mod_logutils[i]->log_get_record(fd, (void **)&mod_buf)) == 1);
if (ret < 0)
{
ret = -1;
goto cleanup;
}
if(ret == -1)
continue; /* move on to the next module if there was an error with this one */
/* we calculate more detailed stats for POSIX and MPI-IO modules,
* if the parser is executed with more than the base option
......
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