Commit db5a2150 authored by Philip Carns's avatar Philip Carns

Merge remote-tracking branch 'origin/master' into dev-stdio

parents ebbe6421 85698250
...@@ -3538,7 +3538,7 @@ then ...@@ -3538,7 +3538,7 @@ then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; } $as_echo "yes" >&6; }
BZLIB_OLD_LDFLAGS=$LDFLAGS BZLIB_OLD_LDFLAGS=$LDFLAGS
BZLIB_OLD_CPPFLAGS=$LDFLAGS BZLIB_OLD_CPPFLAGS=$CPPFLAGS
LDFLAGS="$LDFLAGS -L${BZLIB_HOME}/lib" LDFLAGS="$LDFLAGS -L${BZLIB_HOME}/lib"
CPPFLAGS="$CPPFLAGS -I${BZLIB_HOME}/include" CPPFLAGS="$CPPFLAGS -I${BZLIB_HOME}/include"
......
...@@ -230,8 +230,7 @@ int main(int argc, char **argv) ...@@ -230,8 +230,7 @@ int main(int argc, char **argv)
darshan_fd outfile; darshan_fd outfile;
int i; int i;
int mount_count; int mount_count;
char** mnt_pts; struct darshan_mnt_info *mnt_data_array;
char** fs_types;
struct darshan_record_ref *rec_hash = NULL; struct darshan_record_ref *rec_hash = NULL;
struct darshan_record_ref *ref, *tmp; struct darshan_record_ref *ref, *tmp;
char mod_buf[DEF_MOD_BUF_SIZE]; char mod_buf[DEF_MOD_BUF_SIZE];
...@@ -299,7 +298,7 @@ int main(int argc, char **argv) ...@@ -299,7 +298,7 @@ int main(int argc, char **argv)
return(-1); return(-1);
} }
ret = darshan_log_getmounts(infile, &mnt_pts, &fs_types, &mount_count); ret = darshan_log_getmounts(infile, &mnt_data_array, &mount_count);
if(ret < 0) if(ret < 0)
{ {
darshan_log_close(infile); darshan_log_close(infile);
...@@ -308,7 +307,7 @@ int main(int argc, char **argv) ...@@ -308,7 +307,7 @@ int main(int argc, char **argv)
return(-1); return(-1);
} }
ret = darshan_log_putmounts(outfile, mnt_pts, fs_types, mount_count); ret = darshan_log_putmounts(outfile, mnt_data_array, mount_count);
if(ret < 0) if(ret < 0)
{ {
darshan_log_close(infile); darshan_log_close(infile);
...@@ -389,16 +388,8 @@ int main(int argc, char **argv) ...@@ -389,16 +388,8 @@ int main(int argc, char **argv)
darshan_log_close(infile); darshan_log_close(infile);
darshan_log_close(outfile); darshan_log_close(outfile);
for(i=0; i<mount_count; i++)
{
free(mnt_pts[i]);
free(fs_types[i]);
}
if(mount_count > 0) if(mount_count > 0)
{ free(mnt_data_array);
free(mnt_pts);
free(fs_types);
}
HASH_ITER(hlink, rec_hash, ref, tmp) HASH_ITER(hlink, rec_hash, ref, tmp)
{ {
......
...@@ -66,6 +66,7 @@ struct darshan_fd_int_state ...@@ -66,6 +66,7 @@ struct darshan_fd_int_state
struct darshan_dz_state dz; struct darshan_dz_state dz;
}; };
static int darshan_mnt_info_cmp(const void *a, const void *b);
static int darshan_log_getheader(darshan_fd fd); static int darshan_log_getheader(darshan_fd fd);
static int darshan_log_putheader(darshan_fd fd); static int darshan_log_putheader(darshan_fd fd);
static int darshan_log_seek(darshan_fd fd, off_t offset); static int darshan_log_seek(darshan_fd fd, off_t offset);
...@@ -374,14 +375,14 @@ int darshan_log_putexe(darshan_fd fd, char *buf) ...@@ -374,14 +375,14 @@ int darshan_log_putexe(darshan_fd fd, char *buf)
/* darshan_log_getmounts() /* darshan_log_getmounts()
* *
* retrieves mount table information from the log. Note that mnt_pts and * retrieves mount table information from the log. Note that mnt_data_array
* fs_types are arrays that will be allocated by the function and must be * is an array that will be allocated by the function and must be
* freed by the caller. count will indicate the size of the arrays * freed by the caller. count will indicate the size of the array
* *
* returns 0 on success, -1 on failure * returns 0 on success, -1 on failure
*/ */
int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts, int darshan_log_getmounts(darshan_fd fd, struct darshan_mnt_info **mnt_data_array,
char*** fs_types, int* count) int* count)
{ {
struct darshan_fd_int_state *state = fd->state; struct darshan_fd_int_state *state = fd->state;
char *pos; char *pos;
...@@ -416,34 +417,27 @@ int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts, ...@@ -416,34 +417,27 @@ int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts,
} }
/* allocate output arrays */ /* allocate output arrays */
*mnt_pts = malloc((*count)*sizeof(char*)); *mnt_data_array = malloc((*count)*sizeof(**mnt_data_array));
assert(*mnt_pts); assert(*mnt_data_array);
*fs_types = malloc((*count)*sizeof(char*));
assert(*fs_types);
/* work backwards through the table and parse each line (except for /* work through the table and parse each line (except for
* first, which holds command line information) * first, which holds command line information)
*/ */
while((pos = strrchr(state->exe_mnt_data, '\n')) != NULL) pos = state->exe_mnt_data;
while((pos = strchr(pos, '\n')) != NULL)
{ {
/* overestimate string lengths */ ret = sscanf(++pos, "%s\t%s", (*mnt_data_array)[array_index].mnt_type,
(*mnt_pts)[array_index] = malloc(DARSHAN_EXE_LEN); (*mnt_data_array)[array_index].mnt_path);
assert((*mnt_pts)[array_index]);
(*fs_types)[array_index] = malloc(DARSHAN_EXE_LEN);
assert((*fs_types)[array_index]);
ret = sscanf(++pos, "%s\t%s", (*fs_types)[array_index],
(*mnt_pts)[array_index]);
if(ret != 2) if(ret != 2)
{ {
fprintf(stderr, "Error: poorly formatted mount table in darshan log file.\n"); fprintf(stderr, "Error: poorly formatted mount table in darshan log file.\n");
return(-1); return(-1);
} }
pos--;
*pos = '\0';
array_index++; array_index++;
} }
qsort(*mnt_data_array, *count, sizeof(**mnt_data_array), darshan_mnt_info_cmp);
return(0); return(0);
} }
...@@ -456,7 +450,8 @@ int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts, ...@@ -456,7 +450,8 @@ int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts,
* *
* returns 0 on success, -1 on failure * returns 0 on success, -1 on failure
*/ */
int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, char** fs_types, int count) int darshan_log_putmounts(darshan_fd fd, struct darshan_mnt_info *mnt_data_array,
int count)
{ {
struct darshan_fd_int_state *state = fd->state; struct darshan_fd_int_state *state = fd->state;
int i; int i;
...@@ -472,7 +467,7 @@ int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, char** fs_types, int co ...@@ -472,7 +467,7 @@ int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, char** fs_types, int co
tmp = mnt_dat; tmp = mnt_dat;
for(i=count-1; i>=0; i--) for(i=count-1; i>=0; i--)
{ {
sprintf(line, "\n%s\t%s", fs_types[i], mnt_pts[i]); sprintf(line, "\n%s\t%s", mnt_data_array[i].mnt_type, mnt_data_array[i].mnt_path);
memcpy(tmp, line, strlen(line)); memcpy(tmp, line, strlen(line));
tmp += strlen(line); tmp += strlen(line);
...@@ -827,6 +822,19 @@ void darshan_log_close(darshan_fd fd) ...@@ -827,6 +822,19 @@ void darshan_log_close(darshan_fd fd)
/* **************************************************** */ /* **************************************************** */
static int darshan_mnt_info_cmp(const void *a, const void *b)
{
struct darshan_mnt_info *m_a = (struct darshan_mnt_info *)a;
struct darshan_mnt_info *m_b = (struct darshan_mnt_info *)b;
if(strlen(m_a->mnt_path) > strlen(m_b->mnt_path))
return(-1);
else if(strlen(m_a->mnt_path) < strlen(m_b->mnt_path))
return(1);
else
return(0);
}
/* read the header of the darshan log and set internal fd data structures /* read the header of the darshan log and set internal fd data structures
* NOTE: this is the only portion of the darshan log that is uncompressed * NOTE: this is the only portion of the darshan log that is uncompressed
* *
......
...@@ -47,6 +47,12 @@ struct darshan_record_ref ...@@ -47,6 +47,12 @@ struct darshan_record_ref
UT_hash_handle hlink; UT_hash_handle hlink;
}; };
struct darshan_mnt_info
{
char mnt_type[DARSHAN_EXE_LEN];
char mnt_path[DARSHAN_EXE_LEN];
};
/* functions to be implemented by each module for integration with /* functions to be implemented by each module for integration with
* darshan log file utilities (e.g., parser & convert tools) * darshan log file utilities (e.g., parser & convert tools)
*/ */
...@@ -116,10 +122,10 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job); ...@@ -116,10 +122,10 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job);
int darshan_log_putjob(darshan_fd fd, struct darshan_job *job); int darshan_log_putjob(darshan_fd fd, struct darshan_job *job);
int darshan_log_getexe(darshan_fd fd, char *buf); int darshan_log_getexe(darshan_fd fd, char *buf);
int darshan_log_putexe(darshan_fd fd, char *buf); int darshan_log_putexe(darshan_fd fd, char *buf);
int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts, int darshan_log_getmounts(darshan_fd fd, struct darshan_mnt_info **mnt_data_array,
char*** fs_types, int* count); int* count);
int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, int darshan_log_putmounts(darshan_fd fd, struct darshan_mnt_info *mnt_data_array,
char** fs_types, int count); int count);
int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash); int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash);
int darshan_log_puthash(darshan_fd fd, struct darshan_record_ref *hash); int darshan_log_puthash(darshan_fd fd, struct darshan_record_ref *hash);
int darshan_log_getmod(darshan_fd fd, darshan_module_id mod_id, int darshan_log_getmod(darshan_fd fd, darshan_module_id mod_id,
......
...@@ -205,8 +205,7 @@ int main(int argc, char **argv) ...@@ -205,8 +205,7 @@ int main(int argc, char **argv)
struct darshan_record_ref *rec_hash = NULL; struct darshan_record_ref *rec_hash = NULL;
struct darshan_record_ref *ref, *tmp_ref; struct darshan_record_ref *ref, *tmp_ref;
int mount_count; int mount_count;
char** mnt_pts; struct darshan_mnt_info *mnt_data_array;
char** fs_types;
time_t tmp_time = 0; time_t tmp_time = 0;
char *token; char *token;
char *save; char *save;
...@@ -248,7 +247,7 @@ int main(int argc, char **argv) ...@@ -248,7 +247,7 @@ int main(int argc, char **argv)
} }
/* get the mount information for this log */ /* get the mount information for this log */
ret = darshan_log_getmounts(fd, &mnt_pts, &fs_types, &mount_count); ret = darshan_log_getmounts(fd, &mnt_data_array, &mount_count);
if(ret < 0) if(ret < 0)
{ {
darshan_log_close(fd); darshan_log_close(fd);
...@@ -318,7 +317,8 @@ int main(int argc, char **argv) ...@@ -318,7 +317,8 @@ int main(int argc, char **argv)
printf("# -------------------------------------------------------\n"); printf("# -------------------------------------------------------\n");
for(i=0; i<mount_count; i++) for(i=0; i<mount_count; i++)
{ {
printf("# mount entry:\t%s\t%s\n", mnt_pts[i], fs_types[i]); printf("# mount entry:\t%s\t%s\n", mnt_data_array[i].mnt_path,
mnt_data_array[i].mnt_type);
} }
if(mask & OPTION_BASE) if(mask & OPTION_BASE)
...@@ -417,10 +417,11 @@ int main(int argc, char **argv) ...@@ -417,10 +417,11 @@ int main(int argc, char **argv)
/* get mount point and fs type associated with this record */ /* get mount point and fs type associated with this record */
for(j=0; j<mount_count; j++) for(j=0; j<mount_count; j++)
{ {
if(strncmp(mnt_pts[j], ref->rec.name, strlen(mnt_pts[j])) == 0) if(strncmp(mnt_data_array[j].mnt_path, ref->rec.name,
strlen(mnt_data_array[j].mnt_path)) == 0)
{ {
mnt_pt = mnt_pts[j]; mnt_pt = mnt_data_array[j].mnt_path;
fs_type = fs_types[j]; fs_type = mnt_data_array[j].mnt_type;
break; break;
} }
} }
...@@ -633,15 +634,9 @@ cleanup: ...@@ -633,15 +634,9 @@ cleanup:
} }
/* free mount info */ /* free mount info */
for(i=0; i<mount_count; i++)
{
free(mnt_pts[i]);
free(fs_types[i]);
}
if(mount_count > 0) if(mount_count > 0)
{ {
free(mnt_pts); free(mnt_data_array);
free(fs_types);
} }
return(ret); return(ret);
......
...@@ -57,7 +57,7 @@ if test -z "${DISABLE_BZLIB}" ...@@ -57,7 +57,7 @@ if test -z "${DISABLE_BZLIB}"
then then
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
BZLIB_OLD_LDFLAGS=$LDFLAGS BZLIB_OLD_LDFLAGS=$LDFLAGS
BZLIB_OLD_CPPFLAGS=$LDFLAGS BZLIB_OLD_CPPFLAGS=$CPPFLAGS
LDFLAGS="$LDFLAGS -L${BZLIB_HOME}/lib" LDFLAGS="$LDFLAGS -L${BZLIB_HOME}/lib"
CPPFLAGS="$CPPFLAGS -I${BZLIB_HOME}/include" CPPFLAGS="$CPPFLAGS -I${BZLIB_HOME}/include"
AC_LANG_SAVE AC_LANG_SAVE
......
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