[Darshan-commits] [Git][darshan/darshan][dev-stdio] 3 commits: modify darshan-logutils to sort mount info

Philip Carns xgitlab at cels.anl.gov
Fri Apr 29 14:20:53 CDT 2016


Philip Carns pushed to branch dev-stdio at darshan / darshan


Commits:
1eb2a5e4 by Shane Snyder at 2016-04-26T23:02:21-05:00
modify darshan-logutils to sort mount info

mount information is now sorted in order of descending mount
point lengths to fix a bug in matching file names to mount
points. the longest mount point string which matches the file
name is the corresponding mount. this change requires slight
changes to the darshan-logutils API, but does not modify the
log file format

- - - - -
85698250 by Shane Snyder at 2016-04-27T16:29:51+00:00
bug fix in bzip2 configure check

- - - - -
db5a2150 by Phil Carns at 2016-04-29T15:20:39-04:00
Merge remote-tracking branch 'origin/master' into dev-stdio

- - - - -


6 changed files:

- darshan-util/configure
- darshan-util/darshan-convert.c
- darshan-util/darshan-logutils.c
- darshan-util/darshan-logutils.h
- darshan-util/darshan-parser.c
- maint/config/check_bzlib.m4


Changes:

=====================================
darshan-util/configure
=====================================
--- a/darshan-util/configure
+++ b/darshan-util/configure
@@ -3538,7 +3538,7 @@ then
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
         BZLIB_OLD_LDFLAGS=$LDFLAGS
-        BZLIB_OLD_CPPFLAGS=$LDFLAGS
+        BZLIB_OLD_CPPFLAGS=$CPPFLAGS
         LDFLAGS="$LDFLAGS -L${BZLIB_HOME}/lib"
         CPPFLAGS="$CPPFLAGS -I${BZLIB_HOME}/include"
 


=====================================
darshan-util/darshan-convert.c
=====================================
--- a/darshan-util/darshan-convert.c
+++ b/darshan-util/darshan-convert.c
@@ -230,8 +230,7 @@ int main(int argc, char **argv)
     darshan_fd outfile;
     int i;
     int mount_count;
-    char** mnt_pts;
-    char** fs_types;
+    struct darshan_mnt_info *mnt_data_array;
     struct darshan_record_ref *rec_hash = NULL;
     struct darshan_record_ref *ref, *tmp;
     char mod_buf[DEF_MOD_BUF_SIZE];
@@ -299,7 +298,7 @@ int main(int argc, char **argv)
         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)
     {
         darshan_log_close(infile);
@@ -308,7 +307,7 @@ int main(int argc, char **argv)
         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)
     {
         darshan_log_close(infile);
@@ -389,16 +388,8 @@ int main(int argc, char **argv)
     darshan_log_close(infile);
     darshan_log_close(outfile);
 
-    for(i=0; i<mount_count; i++)
-    {
-        free(mnt_pts[i]);
-        free(fs_types[i]);
-    }
     if(mount_count > 0)
-    {
-        free(mnt_pts);
-        free(fs_types);
-    }
+        free(mnt_data_array);
 
     HASH_ITER(hlink, rec_hash, ref, tmp)
     {


=====================================
darshan-util/darshan-logutils.c
=====================================
--- a/darshan-util/darshan-logutils.c
+++ b/darshan-util/darshan-logutils.c
@@ -66,6 +66,7 @@ struct darshan_fd_int_state
     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_putheader(darshan_fd fd);
 static int darshan_log_seek(darshan_fd fd, off_t offset);
@@ -374,14 +375,14 @@ int darshan_log_putexe(darshan_fd fd, char *buf)
 
 /* darshan_log_getmounts()
  * 
- * retrieves mount table information from the log. Note that mnt_pts and
- * fs_types are arrays that will be allocated by the function and must be
- * freed by the caller. count will indicate the size of the arrays
+ * retrieves mount table information from the log. Note that mnt_data_array
+ * is an array that will be allocated by the function and must be
+ * freed by the caller. count will indicate the size of the array
  *
  * returns 0 on success, -1 on failure
  */
-int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts,
-    char*** fs_types, int* count)
+int darshan_log_getmounts(darshan_fd fd, struct darshan_mnt_info **mnt_data_array,
+    int* count)
 {
     struct darshan_fd_int_state *state = fd->state;
     char *pos;
@@ -416,34 +417,27 @@ int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts,
     }
 
     /* allocate output arrays */
-    *mnt_pts = malloc((*count)*sizeof(char*));
-    assert(*mnt_pts);
-    *fs_types = malloc((*count)*sizeof(char*));
-    assert(*fs_types);
+    *mnt_data_array = malloc((*count)*sizeof(**mnt_data_array));
+    assert(*mnt_data_array);
 
-    /* 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)
      */
-    while((pos = strrchr(state->exe_mnt_data, '\n')) != NULL)
+    pos = state->exe_mnt_data;
+    while((pos = strchr(pos, '\n')) != NULL)
     {
-        /* overestimate string lengths */
-        (*mnt_pts)[array_index] = malloc(DARSHAN_EXE_LEN);
-        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]);
+        ret = sscanf(++pos, "%s\t%s", (*mnt_data_array)[array_index].mnt_type,
+            (*mnt_data_array)[array_index].mnt_path);
         if(ret != 2)
         {
             fprintf(stderr, "Error: poorly formatted mount table in darshan log file.\n");
             return(-1);
         }
-        pos--;
-        *pos = '\0';
         array_index++;
     }
 
+    qsort(*mnt_data_array, *count, sizeof(**mnt_data_array), darshan_mnt_info_cmp);
+
     return(0);
 }
 
@@ -456,7 +450,8 @@ int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts,
  *
  * 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;
     int i;
@@ -472,7 +467,7 @@ int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, char** fs_types, int co
     tmp = mnt_dat;
     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));
         tmp += strlen(line);
@@ -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
  * NOTE: this is the only portion of the darshan log that is uncompressed
  *


=====================================
darshan-util/darshan-logutils.h
=====================================
--- a/darshan-util/darshan-logutils.h
+++ b/darshan-util/darshan-logutils.h
@@ -47,6 +47,12 @@ struct darshan_record_ref
     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
  * darshan log file utilities (e.g., parser & convert tools)
  */
@@ -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_getexe(darshan_fd fd, char *buf);
 int darshan_log_putexe(darshan_fd fd, char *buf);
-int darshan_log_getmounts(darshan_fd fd, char*** mnt_pts,
-    char*** fs_types, int* count);
-int darshan_log_putmounts(darshan_fd fd, char** mnt_pts,
-    char** fs_types, int count);
+int darshan_log_getmounts(darshan_fd fd, struct darshan_mnt_info **mnt_data_array,
+    int* count);
+int darshan_log_putmounts(darshan_fd fd, struct darshan_mnt_info *mnt_data_array,
+    int count);
 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_getmod(darshan_fd fd, darshan_module_id mod_id,


=====================================
darshan-util/darshan-parser.c
=====================================
--- a/darshan-util/darshan-parser.c
+++ b/darshan-util/darshan-parser.c
@@ -205,8 +205,7 @@ int main(int argc, char **argv)
     struct darshan_record_ref *rec_hash = NULL;
     struct darshan_record_ref *ref, *tmp_ref;
     int mount_count;
-    char** mnt_pts;
-    char** fs_types;
+    struct darshan_mnt_info *mnt_data_array;
     time_t tmp_time = 0;
     char *token;
     char *save;
@@ -248,7 +247,7 @@ int main(int argc, char **argv)
     }
 
     /* 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)
     {
         darshan_log_close(fd);
@@ -318,7 +317,8 @@ int main(int argc, char **argv)
     printf("# -------------------------------------------------------\n");
     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)
@@ -417,10 +417,11 @@ int main(int argc, char **argv)
             /* get mount point and fs type associated with this record */
             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];
-                    fs_type = fs_types[j];
+                    mnt_pt = mnt_data_array[j].mnt_path;
+                    fs_type = mnt_data_array[j].mnt_type;
                     break;
                 }
             }
@@ -633,15 +634,9 @@ cleanup:
     }
 
     /* free mount info */
-    for(i=0; i<mount_count; i++)
-    {
-        free(mnt_pts[i]);
-        free(fs_types[i]);
-    }
     if(mount_count > 0)
     {
-        free(mnt_pts);
-        free(fs_types);
+        free(mnt_data_array);
     }
 
     return(ret);


=====================================
maint/config/check_bzlib.m4
=====================================
--- a/maint/config/check_bzlib.m4
+++ b/maint/config/check_bzlib.m4
@@ -57,7 +57,7 @@ if test -z "${DISABLE_BZLIB}"
 then
         AC_MSG_RESULT(yes)
         BZLIB_OLD_LDFLAGS=$LDFLAGS
-        BZLIB_OLD_CPPFLAGS=$LDFLAGS
+        BZLIB_OLD_CPPFLAGS=$CPPFLAGS
         LDFLAGS="$LDFLAGS -L${BZLIB_HOME}/lib"
         CPPFLAGS="$CPPFLAGS -I${BZLIB_HOME}/include"
         AC_LANG_SAVE



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/ebbe6421a698b49e7157f28977655adecb6c3b7f...db5a2150cece193643205e59b16b9d5827767bae
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160429/dee2dbc6/attachment-0001.html>


More information about the Darshan-commits mailing list