Commit c76c48ca authored by Philip Carns's avatar Philip Carns

add magic number, hack up the logutils to handle 2.00 file format


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@244 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 0ddc4ea7
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
/* update this on file format changes */ /* update this on file format changes */
#define CP_VERSION "2.00" #define CP_VERSION "2.00"
/* magic number for validating output files and checking byte order */
#define CP_MAGIC_NR 6567223
/* size (in bytes) of job record */ /* size (in bytes) of job record */
#define CP_JOB_RECORD_SIZE 1024 #define CP_JOB_RECORD_SIZE 1024
...@@ -217,6 +220,7 @@ struct darshan_file ...@@ -217,6 +220,7 @@ struct darshan_file
struct darshan_job struct darshan_job
{ {
char version_string[8]; char version_string[8];
int64_t magic_nr;
int64_t uid; int64_t uid;
int64_t start_time; int64_t start_time;
int64_t end_time; int64_t end_time;
......
...@@ -254,6 +254,16 @@ int darshan_log_getjob(darshan_fd file, struct darshan_job *job) ...@@ -254,6 +254,16 @@ int darshan_log_getjob(darshan_fd file, struct darshan_job *job)
perror("darshan_job_init"); perror("darshan_job_init");
return(-1); return(-1);
} }
/* TODO: error out on anything except 2.00 in trunk for now, build
* backwards compatibility later
*/
if(strcmp(job->version_string, "2.00") == 0)
return(0);
fprintf(stderr, "Error: incompatible darshan file.\n");
fprintf(stderr, "Error: expected version %s, but got %s\n",
CP_VERSION, job->version_string);
return(-1);
if(strcmp(job->version_string, "1.21") == 0) if(strcmp(job->version_string, "1.21") == 0)
return(0); return(0);
if(strcmp(job->version_string, "1.22") == 0) if(strcmp(job->version_string, "1.22") == 0)
...@@ -337,9 +347,18 @@ int darshan_log_getfile(darshan_fd fd, struct darshan_job *job, struct darshan_f ...@@ -337,9 +347,18 @@ int darshan_log_getfile(darshan_fd fd, struct darshan_job *job, struct darshan_f
} }
} }
else if(strcmp(job->version_string, "1.24") == 0) else if(strcmp(job->version_string, "1.24") == 0)
{
ret = gzread(fd, file, sizeof(*file));
if(ret == sizeof(*file))
{
/* got exactly one, correct size record */
return(1);
}
}
else if(strcmp(job->version_string, "2.00") == 0)
{ {
/* make sure this is the current version */ /* make sure this is the current version */
assert(strcmp("1.24", CP_VERSION) == 0); assert(strcmp("2.00", CP_VERSION) == 0);
ret = gzread(fd, file, sizeof(*file)); ret = gzread(fd, file, sizeof(*file));
if(ret == sizeof(*file)) if(ret == sizeof(*file))
...@@ -490,9 +509,14 @@ void darshan_log_close(darshan_fd file) ...@@ -490,9 +509,14 @@ void darshan_log_close(darshan_fd file)
*/ */
void darshan_log_print_version_warnings(struct darshan_job *job) void darshan_log_print_version_warnings(struct darshan_job *job)
{ {
if(strcmp(job->version_string, "2.00") == 0)
{
/* current version */
return;
}
if(strcmp(job->version_string, "1.24") == 0) if(strcmp(job->version_string, "1.24") == 0)
{ {
/* nothing to do, this is the current version */
return; return;
} }
......
...@@ -1028,6 +1028,7 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank) ...@@ -1028,6 +1028,7 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank)
} }
strcpy(darshan_global_job->log_job.version_string, CP_VERSION); strcpy(darshan_global_job->log_job.version_string, CP_VERSION);
darshan_global_job->log_job.magic_nr = CP_MAGIC_NR;
darshan_global_job->log_job.uid = getuid(); darshan_global_job->log_job.uid = getuid();
darshan_global_job->log_job.start_time = time(NULL); darshan_global_job->log_job.start_time = time(NULL);
darshan_global_job->log_job.nprocs = nprocs; darshan_global_job->log_job.nprocs = nprocs;
......
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