[Darshan-commits] [Darshan] branch, dev-modular, updated. darshan-2.3.1-177-g8659e6a

Service Account git at mcs.anl.gov
Fri Sep 18 15:36:40 CDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".

The branch, dev-modular has been updated
       via  8659e6a33068878916580d5f69bb1d19101d72c9 (commit)
      from  86d174406f55abe938044a28eca0ce5c52b33e04 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8659e6a33068878916580d5f69bb1d19101d72c9
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date:   Fri Sep 18 15:36:02 2015 -0500

    new implementation of darshan-logutils

-----------------------------------------------------------------------

Summary of changes:
 darshan-util/darshan-analyzer.c         |   60 +--
 darshan-util/darshan-bgq-logutils.c     |   67 ++-
 darshan-util/darshan-convert.c          |  134 +---
 darshan-util/darshan-hdf5-logutils.c    |   59 +-
 darshan-util/darshan-logutils.c         | 1190 ++++++++++++++++++-------------
 darshan-util/darshan-logutils.h         |   29 +-
 darshan-util/darshan-mpiio-logutils.c   |   59 +-
 darshan-util/darshan-parser.c           |  119 ++--
 darshan-util/darshan-pnetcdf-logutils.c |   59 +-
 darshan-util/darshan-posix-logutils.c   |   59 +-
 10 files changed, 983 insertions(+), 852 deletions(-)


Diff of changes:
diff --git a/darshan-util/darshan-analyzer.c b/darshan-util/darshan-analyzer.c
index a9be4b2..55bfe24 100644
--- a/darshan-util/darshan-analyzer.c
+++ b/darshan-util/darshan-analyzer.c
@@ -35,18 +35,16 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
 {
     int ret;
     darshan_fd file;
-    struct darshan_header header;
     struct darshan_job job;
     struct darshan_mod_logutil_funcs *psx_mod = mod_logutils[DARSHAN_POSIX_MOD];
-    struct darshan_posix_file *psx_buf, *psx_buf_p;
-    int psx_buf_sz, psx_buf_bytes_left;
-    struct darshan_posix_file *psx_rec;
+    struct darshan_posix_file psx_rec;
     darshan_record_id rec_id;
     int f_count;
     double total_io_time;
     double total_job_time;
 
     assert(psx_mod);
+    memset(&psx_rec, 0, sizeof(struct darshan_posix_file));
 
     file = darshan_log_open(fname);
     if (file == NULL)
@@ -55,14 +53,6 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
         return -1;
     }
 
-    ret = darshan_log_getheader(file, &header);
-    if (ret < 0)
-    {
-        fprintf(stderr, "darshan_log_getheader() failed on file %s.\n", fname);
-        darshan_log_close(file);
-        return -1;
-    }
-
     ret = darshan_log_getjob(file, &job);
     if (ret < 0)
     {
@@ -71,49 +61,36 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
         return -1;
     }
 
-    psx_buf_sz = DARSHAN_DEF_COMP_BUF_SZ;
-    psx_buf = malloc(psx_buf_sz);
-    if (!psx_buf)
-    {
-        darshan_log_close(file);
-        return -1;
-    }
-
-    ret = darshan_log_getmod(file, DARSHAN_POSIX_MOD, (void *)psx_buf, &psx_buf_sz);
-    if (ret < 0)
-    {
-        fprintf(stderr, "darshan_log_getmod() failed on file %s.\n", fname);
-        darshan_log_close(file);
-        return -1;
-    }
-
     f_count = 0;
     total_io_time = 0.0;
 
-    psx_buf_bytes_left = psx_buf_sz;
-    psx_buf_p = psx_buf;
-    while(psx_buf_bytes_left)
+    while((ret = psx_mod->log_get_record(file, &psx_rec, &rec_id)) == 1)
     {
-        ret = psx_mod->log_get_record((void **)&psx_buf_p, &psx_buf_bytes_left,
-            (void **)&psx_rec, &rec_id, file->swap_flag);
-
         f_count   += 1;
 
-        if (psx_rec->rank == -1)
+        if (psx_rec.rank == -1)
             *used_shared = 1;
         else
             *used_fpp = 1;
 
-        total_io_time += (psx_rec->fcounters[POSIX_F_READ_TIME] +
-                         psx_rec->fcounters[POSIX_F_WRITE_TIME] +
-                         psx_rec->fcounters[POSIX_F_META_TIME]);
+        total_io_time += (psx_rec.fcounters[POSIX_F_READ_TIME] +
+                         psx_rec.fcounters[POSIX_F_WRITE_TIME] +
+                         psx_rec.fcounters[POSIX_F_META_TIME]);
+
+        memset(&psx_rec, 0, sizeof(struct darshan_posix_file));
+    }
+    if (ret < 0)
+    {
+        fprintf(stderr, "Error: unable to read posix file record in log file %s.\n", fname);
+        darshan_log_close(file);
+        return -1;
     }
 
-    if (header.mod_map[DARSHAN_MPIIO_MOD].len > 0)
+    if (file->mod_map[DARSHAN_MPIIO_MOD].len > 0)
         *used_mpio += 1;
-    if (header.mod_map[DARSHAN_HDF5_MOD].len > 0)
+    if (file->mod_map[DARSHAN_HDF5_MOD].len > 0)
         *used_hdf5 += 1;
-    if (header.mod_map[DARSHAN_PNETCDF_MOD].len > 0)
+    if (file->mod_map[DARSHAN_PNETCDF_MOD].len > 0)
         *used_pnet += 1;
 
     total_job_time = (double)job.end_time - (double)job.start_time;
@@ -131,7 +108,6 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
         *io_ratio = 0.0;
     }
 
-    free(psx_buf);
     darshan_log_close(file);
 
     return 0;
diff --git a/darshan-util/darshan-bgq-logutils.c b/darshan-util/darshan-bgq-logutils.c
index c538e20..3b4af4b 100644
--- a/darshan-util/darshan-bgq-logutils.c
+++ b/darshan-util/darshan-bgq-logutils.c
@@ -30,48 +30,65 @@ char *bgq_f_counter_names[] = {
 };
 #undef X
 
-static int darshan_log_get_bgq_file(void** psx_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag);
-static void darshan_log_print_bgq_file(void *file_rec,
+static int darshan_log_get_bgq_rec(darshan_fd fd, void* bgq_buf,
+    darshan_record_id* rec_id);
+static int darshan_log_put_bgq_rec(darshan_fd fd, void* bgq_buf);
+static void darshan_log_print_bgq_rec(void *file_rec,
     char *file_name, char *mnt_pt, char *fs_type);
 
 struct darshan_mod_logutil_funcs bgq_logutils =
 {
-    .log_get_record = &darshan_log_get_bgq_file,
-    .log_print_record = &darshan_log_print_bgq_file,
+    .log_get_record = &darshan_log_get_bgq_rec,
+    .log_put_record = &darshan_log_put_bgq_rec,
+    .log_print_record = &darshan_log_print_bgq_rec,
 };
 
-static int darshan_log_get_bgq_file(void** psx_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag)
+static int darshan_log_get_bgq_rec(darshan_fd fd, void* bgq_buf,
+    darshan_record_id* rec_id)
 {
+    struct darshan_bgq_record *rec;
     int i;
-    struct darshan_bgq_record *file = (struct darshan_bgq_record *)
-        (*psx_buf_p);
+    int ret;
 
-    if(*bytes_left < sizeof(struct darshan_bgq_record))
+    ret = darshan_log_getmod(fd, DARSHAN_BGQ_MOD, bgq_buf,
+        sizeof(struct darshan_bgq_record));
+    if(ret < 0)
         return(-1);
-
-    if(byte_swap_flag)
+    else if(ret < sizeof(struct darshan_bgq_record))
+        return(0);
+    else
     {
-        /* swap bytes if necessary */
-        DARSHAN_BSWAP64(&file->f_id);
-        DARSHAN_BSWAP64(&file->rank);
-        for(i=0; i<BGQ_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->counters[i]);
-        for(i=0; i<BGQ_F_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->fcounters[i]);
+        rec = (struct darshan_bgq_record *)bgq_buf;
+        if(fd->swap_flag)
+        {
+            /* swap bytes if necessary */
+            DARSHAN_BSWAP64(&rec->f_id);
+            DARSHAN_BSWAP64(&rec->rank);
+            for(i=0; i<BGQ_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&rec->counters[i]);
+            for(i=0; i<BGQ_F_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&rec->fcounters[i]);
+        }
+
+        *rec_id = rec->f_id;
+        return(1);
     }
+}
 
-    /* update/set output variables */
-    *file_rec = (void *)file;
-    *rec_id = file->f_id;
-    *psx_buf_p = (file + 1); /* increment input buf by size of file record */
-    *bytes_left -= sizeof(struct darshan_bgq_record);
+static int darshan_log_put_bgq_rec(darshan_fd fd, void* bgq_buf)
+{
+    struct darshan_bgq_record *rec = (struct darshan_bgq_record *)bgq_buf;
+    int ret;
+
+    ret = darshan_log_putmod(fd, DARSHAN_BGQ_MOD, rec,
+        sizeof(struct darshan_bgq_record));
+    if(ret < 0)
+        return(-1);
 
     return(0);
 }
 
-static void darshan_log_print_bgq_file(void *file_rec, char *file_name,
+static void darshan_log_print_bgq_rec(void *file_rec, char *file_name,
     char *mnt_pt, char *fs_type)
 {
     int i;
diff --git a/darshan-util/darshan-convert.c b/darshan-util/darshan-convert.c
index df5cd53..5095ba4 100644
--- a/darshan-util/darshan-convert.c
+++ b/darshan-util/darshan-convert.c
@@ -19,6 +19,8 @@
 
 #include "darshan-logutils.h"
 
+#define DEF_MOD_BUF_SIZE 1024 /* 1 KiB is enough for all current mod records ... */
+
 extern uint32_t darshan_hashlittle(const void *key, size_t length, uint32_t initval);
 
 int usage (char *exename)
@@ -221,7 +223,6 @@ int main(int argc, char **argv)
     int ret;
     char *infile_name;
     char *outfile_name;
-    struct darshan_header header;
     struct darshan_job job;
     char tmp_string[4096] = {0};
     darshan_fd infile;
@@ -232,8 +233,7 @@ int main(int argc, char **argv)
     char** fs_types;
     struct darshan_record_ref *rec_hash = NULL;
     struct darshan_record_ref *ref, *tmp;
-    char *mod_buf;
-    int mod_buf_sz;
+    char mod_buf[DEF_MOD_BUF_SIZE];
     enum darshan_comp_type comp_type;
     int bzip2;
     int obfuscate;
@@ -247,42 +247,23 @@ int main(int argc, char **argv)
 
     infile = darshan_log_open(infile_name);
     if(!infile)
-    {
-        fprintf(stderr, "darshan_log_open() failed to open %s\n.", infile_name);
         return(-1);
-    }
  
     comp_type = bzip2 ? comp_type = DARSHAN_BZIP2_COMP : DARSHAN_ZLIB_COMP;
     outfile = darshan_log_create(outfile_name, comp_type);
     if(!outfile)
     {
-        fprintf(stderr, "darshan_log_create() failed to create %s\n.", outfile_name);
         darshan_log_close(infile);
         return(-1);
     }
 
-    /* read header from input file */
-    ret = darshan_log_getheader(infile, &header);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to read header from input log file %s.\n", infile_name);
-        darshan_log_close(infile);
-        darshan_log_close(outfile);
-        return(-1);
-    }
-
-    /* NOTE: we do not write the header to the output file until the end, as
-     * the mapping data stored in this structure may change in the conversion
-     * process (particularly, if we are converting between libz/bz2 compression)
-     */
-
     /* read job info */
     ret = darshan_log_getjob(infile, &job);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to read job information from log file.\n");
         darshan_log_close(infile);
         darshan_log_close(outfile);
+        unlink(outfile_name);
         return(-1);
     }
 
@@ -293,7 +274,6 @@ int main(int argc, char **argv)
     ret = darshan_log_putjob(outfile, &job);
     if (ret < 0)
     {
-        fprintf(stderr, "Error: unable to write job information to log file.\n");
         darshan_log_close(infile);
         darshan_log_close(outfile);
         return(-1);
@@ -302,9 +282,9 @@ int main(int argc, char **argv)
     ret = darshan_log_getexe(infile, tmp_string);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to read trailing job information.\n");
         darshan_log_close(infile);
         darshan_log_close(outfile);
+        unlink(outfile_name);
         return(-1);
     }
 
@@ -313,7 +293,6 @@ int main(int argc, char **argv)
     ret = darshan_log_putexe(outfile, tmp_string);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to write trailing job information.\n");
         darshan_log_close(infile);
         darshan_log_close(outfile);
         return(-1);
@@ -322,16 +301,15 @@ int main(int argc, char **argv)
     ret = darshan_log_getmounts(infile, &mnt_pts, &fs_types, &mount_count);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to read trailing job information.\n");
         darshan_log_close(infile);
         darshan_log_close(outfile);
+        unlink(outfile_name);
         return(-1);
     }
 
     ret = darshan_log_putmounts(outfile, mnt_pts, fs_types, mount_count);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to write mount information.\n");
         darshan_log_close(infile);
         darshan_log_close(outfile);
         return(-1);
@@ -340,9 +318,9 @@ int main(int argc, char **argv)
     ret = darshan_log_gethash(infile, &rec_hash);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to read darshan record hash.\n");
         darshan_log_close(infile);
         darshan_log_close(outfile);
+        unlink(outfile_name);
         return(-1);
     }
 
@@ -355,104 +333,56 @@ int main(int argc, char **argv)
     ret = darshan_log_puthash(outfile, rec_hash);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to write darshan record hash.\n");
         darshan_log_close(infile);
         darshan_log_close(outfile);
         return(-1);
     }
 
-    mod_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
-    if(!mod_buf)
-        return(-1);
-
+    /* loop over each module and convert it's data to the new format */
     for(i=0; i<DARSHAN_MAX_MODS; i++)
     {
-        int mod_bytes_left;
-        int mod_bytes_left_save;
-        void *mod_buf_p;
-        void *rec_p = NULL;
         darshan_record_id rec_id;
 
-        memset(mod_buf, 0, DARSHAN_DEF_COMP_BUF_SZ);
-        mod_buf_sz = DARSHAN_DEF_COMP_BUF_SZ;
-
         /* check each module for any data */
-        ret = darshan_log_getmod(infile, i, mod_buf, &mod_buf_sz);
-        if(ret < 0)
-        {
-            fprintf(stderr, "Error: failed to get module %s data.\n",
-                darshan_module_names[i]);
-            darshan_log_close(infile);
-            darshan_log_close(outfile);
-            return(-1);
-        }
-        else if(ret == 0)
-        {
-            /* skip modules not present in log file */
+        if(infile->mod_map[i].len == 0)
             continue;
-        }
-
-        /* skip modules with no defined logutil handlers */
-        if(!mod_logutils[i])
+        else if(!mod_logutils[i])
         {
             fprintf(stderr, "Warning: no log utility handlers defined "
-                "for module %s, SKIPPING\n", darshan_module_names[i]);
+                "for module %s, SKIPPING.\n", darshan_module_names[i]);
             continue;
         }
 
         /* we have module data to convert */
-        /* NOTE: it is necessary to iterate through each module's
-         * records to correct any endianness issues before writing
-         * this data back to file
-         */
-        mod_bytes_left = mod_buf_sz;
-        mod_buf_p = mod_buf;
-        while(mod_bytes_left > 0)
-        {
-            mod_bytes_left_save = mod_bytes_left;
-            ret = mod_logutils[i]->log_get_record(&mod_buf_p, &mod_bytes_left,
-                &rec_p, &rec_id, infile->swap_flag);
-            if(ret < 0)
-            {
-                fprintf(stderr, "Error: failed to parse module %s data record\n",
-                    darshan_module_names[i]);
-                darshan_log_close(infile);
-                darshan_log_close(outfile);
-                return(-1);
-            }
+        memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
 
-            if(hash == rec_id)
-            {
-                mod_buf_p = rec_p;
-                mod_buf_sz = mod_bytes_left_save - mod_bytes_left;
-                break;
-            }
-            else if(mod_bytes_left == 0)
-            {
-                mod_buf_p = mod_buf;
-            }
-        }
-
-        ret = darshan_log_putmod(outfile, i, mod_buf_p, mod_buf_sz);
-        if(ret < 0)
+        ret = mod_logutils[i]->log_get_record(infile, mod_buf, &rec_id);
+        if(ret != 1)
         {
-            fprintf(stderr, "Error: failed to put module %s data.\n",
+            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);
         }
-    }
-    free(mod_buf);
 
-    /* write header to output file */
-    ret = darshan_log_putheader(outfile);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to write header to output log file %s.\n", outfile_name);
-        darshan_log_close(infile);
-        darshan_log_close(outfile);
-        return(-1);
+        /* loop over each of the module's records and convert */
+        do
+        {
+            if(!hash || hash == rec_id)
+            {
+                ret = mod_logutils[i]->log_put_record(outfile, mod_buf);
+                if(ret < 0)
+                {
+                    darshan_log_close(infile);
+                    darshan_log_close(outfile);
+                    return(-1);
+                }
+
+                memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
+            }
+        } while((ret = mod_logutils[i]->log_get_record(infile, mod_buf, &rec_id)) == 1);
     }
 
     darshan_log_close(infile);
diff --git a/darshan-util/darshan-hdf5-logutils.c b/darshan-util/darshan-hdf5-logutils.c
index e4d6368..2c9631a 100644
--- a/darshan-util/darshan-hdf5-logutils.c
+++ b/darshan-util/darshan-hdf5-logutils.c
@@ -30,43 +30,60 @@ char *hdf5_f_counter_names[] = {
 };
 #undef X
 
-static int darshan_log_get_hdf5_file(void** hdf5_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag);
+static int darshan_log_get_hdf5_file(darshan_fd fd, void* hdf5_buf,
+    darshan_record_id* rec_id);
+static int darshan_log_put_hdf5_file(darshan_fd fd, void* hdf5_buf);
 static void darshan_log_print_hdf5_file(void *file_rec,
     char *file_name, char *mnt_pt, char *fs_type);
 
 struct darshan_mod_logutil_funcs hdf5_logutils =
 {
     .log_get_record = &darshan_log_get_hdf5_file,
+    .log_put_record = &darshan_log_put_hdf5_file,
     .log_print_record = &darshan_log_print_hdf5_file,
 };
 
-static int darshan_log_get_hdf5_file(void** hdf5_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag)
+static int darshan_log_get_hdf5_file(darshan_fd fd, void* hdf5_buf,
+    darshan_record_id* rec_id)
 {
+    struct darshan_hdf5_file *file;
     int i;
-    struct darshan_hdf5_file *file = (struct darshan_hdf5_file *)
-        (*hdf5_buf_p);
+    int ret;
 
-    if(*bytes_left < sizeof(struct darshan_hdf5_file))
+    ret = darshan_log_getmod(fd, DARSHAN_HDF5_MOD, hdf5_buf,
+        sizeof(struct darshan_hdf5_file));
+    if(ret < 0)
         return(-1);
-
-    if(byte_swap_flag)
+    else if(ret < sizeof(struct darshan_hdf5_file))
+        return(0);
+    else
     {
-        /* swap bytes if necessary */
-        DARSHAN_BSWAP64(&file->f_id);
-        DARSHAN_BSWAP64(&file->rank);
-        for(i=0; i<HDF5_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->counters[i]);
-        for(i=0; i<HDF5_F_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->fcounters[i]);
+        file = (struct darshan_hdf5_file *)hdf5_buf;
+        if(fd->swap_flag)
+        {
+            /* swap bytes if necessary */
+            DARSHAN_BSWAP64(&file->f_id);
+            DARSHAN_BSWAP64(&file->rank);
+            for(i=0; i<HDF5_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&file->counters[i]);
+            for(i=0; i<HDF5_F_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&file->fcounters[i]);
+        }
+
+        *rec_id = file->f_id;
+        return(1);
     }
+}
 
-    /* update/set output variables */
-    *file_rec = (void *)file;
-    *rec_id = file->f_id;
-    *hdf5_buf_p = (file + 1); /* increment input buf by size of file record */
-    *bytes_left -= sizeof(struct darshan_hdf5_file);
+static int darshan_log_put_hdf5_file(darshan_fd fd, void* hdf5_buf)
+{
+    struct darshan_hdf5_file *file = (struct darshan_hdf5_file *)hdf5_buf;
+    int ret;
+
+    ret = darshan_log_putmod(fd, DARSHAN_HDF5_MOD, file,
+        sizeof(struct darshan_hdf5_file));
+    if(ret < 0)
+        return(-1);
 
     return(0);
 }
diff --git a/darshan-util/darshan-logutils.c b/darshan-util/darshan-logutils.c
index b4a9ed8..e3560c3 100644
--- a/darshan-util/darshan-logutils.c
+++ b/darshan-util/darshan-logutils.c
@@ -19,28 +19,35 @@
 
 #include "darshan-logutils.h"
 
+/* default input buffer size for decompression algorithm */
+#define DARSHAN_DEF_COMP_BUF_SZ (1024*1024) /* 1 MiB */
+
+/* special identifers for referring to header, job,  and
+ * record map regions of the darshan log file
+ */
+#define DARSHAN_HEADER_REGION_ID    (-3)
+#define DARSHAN_JOB_REGION_ID       (-2)
+#define DARSHAN_REC_MAP_REGION_ID   (-1)
+
+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);
 static int darshan_log_read(darshan_fd fd, void *buf, int len);
 static int darshan_log_write(darshan_fd fd, void *buf, int len);
-static int darshan_decompress_buf(char* comp_buf, int comp_buf_sz,
-    char* decomp_buf, int* inout_decomp_buf_sz,
-    enum darshan_comp_type comp_type);
-static int darshan_compress_buf(char* decomp_buf, int decomp_buf_sz,
-    char* comp_buf, int* inout_comp_buf_sz,
-    enum darshan_comp_type comp_type);
-static int darshan_zlib_decomp(char* comp_buf, int comp_buf_sz,
-    char* decomp_buf, int* inout_decomp_buf_sz);
-static int darshan_zlib_comp(char* decomp_buf, int decomp_buf_sz,
-    char* comp_buf, int* inout_comp_buf_sz);
-#ifdef HAVE_LIBBZ2
-static int darshan_bzip2_decomp(char* comp_buf, int comp_buf_sz,
-    char* decomp_buf, int* inout_decomp_buf_sz);
-static int darshan_bzip2_comp(char* decomp_buf, int decomp_buf_sz,
-    char* comp_buf, int* inout_comp_buf_sz);
-#endif
-
+static int darshan_log_dzinit(darshan_fd fd);
+static void darshan_log_dzdestroy(darshan_fd fd);
+static int darshan_log_dzread(darshan_fd fd, int region_id, void *buf, int len);
+static int darshan_log_dzwrite(darshan_fd fd, int region_id, void *buf, int len);
+static int darshan_log_libz_read(darshan_fd fd, int region_id, void *buf, int len);
+static int darshan_log_libz_write(darshan_fd fd, int region_id, void *buf, int len);
+static int darshan_log_libz_flush(darshan_fd fd, int region_id);
+static int darshan_log_dzload(darshan_fd fd, struct darshan_log_map map);
+static int darshan_log_dzunload(darshan_fd fd, struct darshan_log_map *map_p);
+
+/* TODO: check comments on functions to make sure they are right /cleanup */
 
 /* TODO: can we make this s.t. we don't care about ordering (i.e., X macro it ) */
+/* see gzip interface for ideas */
 struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS] =
 {
     NULL,               /* NULL */
@@ -65,23 +72,47 @@ struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS] =
  *
  * open an existing darshan log file for reading only
  *
- * returns 0 on success, -1 on failure
+ * returns file descriptor on success, NULL on failure
  */
 darshan_fd darshan_log_open(const char *name)
 {
     darshan_fd tmp_fd;
+    int o_flags = O_RDONLY;
+    int ret;
 
     tmp_fd = malloc(sizeof(*tmp_fd));
     if(!tmp_fd)
         return(NULL);
     memset(tmp_fd, 0, sizeof(*tmp_fd));
 
-    tmp_fd->fildes = open(name, O_RDONLY);
+    /* open the log file in read mode */
+    tmp_fd->fildes = open(name, o_flags);
     if(tmp_fd->fildes < 0)
     {
-        perror("darshan_log_open: ");
+        fprintf(stderr, "Error: failed to open darshan log file %s.\n", name);
+        free(tmp_fd);
+        return(NULL);
+    }
+    tmp_fd->o_flags = o_flags;
+    strncpy(tmp_fd->logfile_path, name, PATH_MAX);
+
+    /* read the header from the log file to init fd data structures */
+    ret = darshan_log_getheader(tmp_fd);
+    if(ret < 0)
+    {
+        close(tmp_fd->fildes);
         free(tmp_fd);
-        tmp_fd = NULL;
+        return(NULL);
+    }
+
+    /* initialize compression data structures */
+    ret = darshan_log_dzinit(tmp_fd);
+    if(ret < 0)
+    {
+        fprintf(stderr, "Error: failed to initialize decompression data structures.\n");
+        close(tmp_fd->fildes);
+        free(tmp_fd);
+        return(NULL);
     }
 
     return(tmp_fd);
@@ -91,143 +122,58 @@ darshan_fd darshan_log_open(const char *name)
  *
  * create a darshan log file for writing with the given compression method
  *
- * returns 0 on success, -1 on failure
+ * returns file descriptor on success, NULL on failure
  */
 darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type)
 {
     darshan_fd tmp_fd;
+    int o_flags = O_WRONLY | O_CREAT | O_EXCL;
+    int ret;
 
     tmp_fd = malloc(sizeof(*tmp_fd));
     if(!tmp_fd)
         return(NULL);
     memset(tmp_fd, 0, sizeof(*tmp_fd));
 
+    /* open the log for writing, making sure to not overwrite existing log */
     /* TODO: permissions when creating?  umask */
-    /* when writing, we create the log file making sure not to overwrite
-     * an existing log
-     */
-    tmp_fd->comp_type = comp_type;
-    tmp_fd->fildes = open(name, O_WRONLY | O_CREAT | O_EXCL, 0400);
+    tmp_fd->fildes = open(name, o_flags, 0400);
     if(tmp_fd->fildes < 0)
     {
-        perror("darshan_log_create: ");
+        fprintf(stderr, "Error: failed to open darshan log file %s.\n", name);
         free(tmp_fd);
-        tmp_fd = NULL;
+        return(NULL);
     }
+    tmp_fd->o_flags = o_flags;
+    tmp_fd->comp_type = comp_type;
+    strncpy(tmp_fd->logfile_path, name, PATH_MAX);
 
-    return(tmp_fd);
-}
-
-/* darshan_log_getheader()
- *
- * read the header of the darshan log and set internal data structures
- * NOTE: this function must be called before reading other portions of the log
- * NOTE: this is the only portion of the darshan log which is uncompressed
- *
- * returns 0 on success, -1 on failure
- */
-int darshan_log_getheader(darshan_fd fd, struct darshan_header *header)
-{
-    int i;
-    int ret;
-
-    ret = darshan_log_seek(fd, 0);
+    /* position file pointer to prealloc space for the log file header
+     * NOTE: the header is written at close time, after all internal data
+     * structures have been properly set
+     */
+    ret = darshan_log_seek(tmp_fd, sizeof(struct darshan_header));
     if(ret < 0)
     {
         fprintf(stderr, "Error: unable to seek in darshan log file.\n");
-        return(-1);
-    }
-
-    /* read uncompressed header from log file */
-    ret = darshan_log_read(fd, header, sizeof(*header));
-    if(ret != sizeof(*header))
-    {
-        fprintf(stderr, "Error: failed to read darshan log file header.\n");
-        return(-1);
-    }
-
-    /* save the version string */
-    strncpy(fd->version, header->version_string, 8);
-
-    if(header->magic_nr == DARSHAN_MAGIC_NR)
-    {
-        /* no byte swapping needed, this file is in host format already */
-        fd->swap_flag = 0;
-    }
-    else
-    {
-        /* try byte swapping */
-        DARSHAN_BSWAP64(&header->magic_nr);
-        if(header->magic_nr == DARSHAN_MAGIC_NR)
-        {
-            fd->swap_flag = 1;
-
-            /* swap the log map variables in the header */
-            DARSHAN_BSWAP64(&header->rec_map.off);
-            DARSHAN_BSWAP64(&header->rec_map.len);
-            for(i = 0; i < DARSHAN_MAX_MODS; i++)
-            {
-                DARSHAN_BSWAP64(&header->mod_map[i].off);
-                DARSHAN_BSWAP64(&header->mod_map[i].len);
-            }
-        }
-        else
-        {
-            /* otherwise this file is just broken */
-            fprintf(stderr, "Error: bad magic number in darshan log file.\n");
-            return(-1);
-        }
+        close(tmp_fd->fildes);
+        free(tmp_fd);
+        unlink(name);
+        return(NULL);
     }
 
-    fd->comp_type = header->comp_type;
-
-    /* save the mapping of data within log file to this file descriptor */
-    fd->job_map.off = sizeof(struct darshan_header);
-    fd->job_map.len = header->rec_map.off - fd->job_map.off;
-    memcpy(&fd->rec_map, &header->rec_map, sizeof(struct darshan_log_map));
-    memcpy(&fd->mod_map, &header->mod_map, DARSHAN_MAX_MODS * sizeof(struct darshan_log_map));
-
-    return(0);
-}
-
-/* darshan_log_putheader()
- *
- * write a darshan header to log file
- * NOTE: the header is not passed in, and is instead built using
- * contents of the given file descriptor
- *
- * returns 0 on success, -1 on failure
- */
-int darshan_log_putheader(darshan_fd fd)
-{
-    struct darshan_header header;
-    int ret;
-
-    ret = darshan_log_seek(fd, 0);
+    /* initialize compression data structures */
+    ret = darshan_log_dzinit(tmp_fd);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
-        return(-1);
-    }
-
-    memset(&header, 0, sizeof(header));
-    strcpy(header.version_string, DARSHAN_LOG_VERSION);
-    header.magic_nr = DARSHAN_MAGIC_NR;
-    header.comp_type = fd->comp_type;
-
-    /* copy the mapping information to the header */
-    memcpy(&header.rec_map, &fd->rec_map, sizeof(struct darshan_log_map));
-    memcpy(&header.mod_map, &fd->mod_map, DARSHAN_MAX_MODS * sizeof(struct darshan_log_map));
-
-    /* write header to file */
-    ret = darshan_log_write(fd, &header, sizeof(header));
-    if(ret != sizeof(header))
-    {
-        fprintf(stderr, "Error: failed to write Darshan log file header.\n");
-        return(-1);
+        fprintf(stderr, "Error: failed to initialize compression data structures.\n");
+        close(tmp_fd->fildes);
+        free(tmp_fd);
+        unlink(name);
+        return(NULL);
     }
 
-    return(0);
+    return(tmp_fd);
 }
 
 /* darshan_log_getjob()
@@ -238,45 +184,19 @@ int darshan_log_putheader(darshan_fd fd)
  */
 int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
 {
-    char *comp_buf;
     char job_buf[DARSHAN_JOB_RECORD_SIZE] = {0};
     int job_buf_sz = DARSHAN_JOB_RECORD_SIZE;
     int ret;
 
     assert(fd->job_map.len > 0 && fd->job_map.off > 0);
 
-    /* allocate buffer to store compressed job info */
-    comp_buf = malloc(fd->job_map.len);
-    if(!comp_buf)
-        return(-1);
-
-    ret = darshan_log_seek(fd, fd->job_map.off);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
-        free(comp_buf);
-        return(-1);
-    }
-
     /* read the compressed job data from the log file */
-    ret = darshan_log_read(fd, comp_buf, fd->job_map.len);
-    if(ret != fd->job_map.len)
+    ret = darshan_log_dzread(fd, DARSHAN_JOB_REGION_ID, job_buf, job_buf_sz);
+    if(ret <= sizeof(*job))
     {
         fprintf(stderr, "Error: failed to read darshan log file job data.\n");
-        free(comp_buf);
-        return(-1);
-    }
-
-    /* decompress the job data */
-    ret = darshan_decompress_buf(comp_buf, fd->job_map.len,
-        job_buf, &job_buf_sz, fd->comp_type);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: failed to decompress darshan job data.\n");
-        free(comp_buf);
         return(-1);
     }
-    free(comp_buf);
 
     memcpy(job, job_buf, sizeof(*job));
 
@@ -302,25 +222,16 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
 
 /* darshan_log_putjob()
  *
- * write job level metadat to darshan log file
+ * write job level metadata to darshan log file
  *
  * returns 0 on success, -1 on failure
  */
 int darshan_log_putjob(darshan_fd fd, struct darshan_job *job)
 {
     struct darshan_job job_copy;
-    char *comp_buf;
-    int comp_buf_sz;
     int len;
     int ret;
 
-    ret = darshan_log_seek(fd, sizeof(struct darshan_header));
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
-        return(-1);
-    }
-
     memset(&job_copy, 0, sizeof(*job));
     memcpy(&job_copy, job, sizeof(*job));
 
@@ -335,31 +246,15 @@ int darshan_log_putjob(darshan_fd fd, struct darshan_job *job)
         }
     }
 
-    comp_buf = malloc(sizeof(*job));
-    if(!comp_buf)
-        return(-1);
-    comp_buf_sz = sizeof(*job);
-
-    /* compress the job data */
-    ret = darshan_compress_buf((char*)&job_copy, sizeof(*job),
-        comp_buf, &comp_buf_sz, fd->comp_type);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: failed to decompress darshan job data.\n");
-        free(comp_buf);
-        return(-1);
-    }    
-
-    /* write job data to file */
-    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
-    if(ret != comp_buf_sz)
+    /* write the compressed job data to log file */
+    ret = darshan_log_dzwrite(fd, DARSHAN_JOB_REGION_ID, &job_copy, sizeof(*job));
+    if(ret != sizeof(*job))
     {
+        fd->err = -1;
         fprintf(stderr, "Error: failed to write darshan log file job data.\n");
-        free(comp_buf);
         return(-1);
     }
 
-    free(comp_buf);
     return(0);
 }
 
@@ -398,7 +293,7 @@ int darshan_log_getexe(darshan_fd fd, char *buf)
  *
  * wrties the application exe name to darshan log file
  * NOTE: this needs to be called immediately following put_job as it
- * expects the final pointer to be positioned immediately following
+ * expects the file pointer to be positioned immediately following
  * the darshan job information
  *
  * returns 0 on success, -1 on failure 
@@ -407,22 +302,13 @@ int darshan_log_putexe(darshan_fd fd, char *buf)
 {
     int len;
     int ret;
-    char comp_buf[DARSHAN_EXE_LEN] = {0};
-    int comp_buf_sz = DARSHAN_EXE_LEN;
 
     len = strlen(buf);
 
-    /* compress the input exe string */
-    ret = darshan_compress_buf(buf, len, comp_buf, &comp_buf_sz, fd->comp_type);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to compress exe string.\n");
-        return(-1);
-    }
-
-    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
-    if(ret != comp_buf_sz)
+    ret = darshan_log_dzwrite(fd, DARSHAN_JOB_REGION_ID, buf, len);
+    if(ret != len)
     {
+        fd->err = -1;
         fprintf(stderr, "Error: failed to write exe string to darshan log file.\n");
         return(-1);
     }
@@ -517,8 +403,6 @@ int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, char** fs_types, int co
     char line[1024];
     char mnt_dat[DARSHAN_EXE_LEN] = {0};
     int mnt_dat_sz = 0;
-    char comp_buf[DARSHAN_EXE_LEN] = {0};
-    int comp_buf_sz = DARSHAN_EXE_LEN;
     char *tmp;
     int ret;
 
@@ -533,16 +417,10 @@ int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, char** fs_types, int co
         mnt_dat_sz += strlen(line);
     }
 
-    ret = darshan_compress_buf(mnt_dat, mnt_dat_sz, comp_buf, &comp_buf_sz, fd->comp_type);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to compress mount data.\n");
-        return(-1);
-    }
-
-    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
-    if (ret != comp_buf_sz)
+    ret = darshan_log_dzwrite(fd, DARSHAN_JOB_REGION_ID, mnt_dat, mnt_dat_sz);
+    if (ret != mnt_dat_sz)
     {
+        fd->err = -1;
         fprintf(stderr, "Error: failed to write darshan log mount data.\n");
         return(-1);
     }
@@ -558,105 +436,114 @@ int darshan_log_putmounts(darshan_fd fd, char** mnt_pts, char** fs_types, int co
  */
 int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
 {
-    char *comp_buf;
     char *hash_buf;
     int hash_buf_sz;
     char *buf_ptr;
     darshan_record_id *rec_id_ptr;
-    uint32_t *path_len_ptr;
+    uint32_t *path_len_ptr, tmp_path_len;
     char *path_ptr;
     struct darshan_record_ref *ref;
-    int ret;
-
-    /* allocate buffers to store compressed and decompressed record
-     * hash data
-     */
-    comp_buf = malloc(fd->rec_map.len);
-    hash_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
-    if(!comp_buf || !hash_buf)
-        return(-1);
-    hash_buf_sz = DARSHAN_DEF_COMP_BUF_SZ;
-    memset(hash_buf, 0, DARSHAN_DEF_COMP_BUF_SZ);
+    int read;
+    int read_req_sz;
+    int buf_remaining = 0;
 
-    ret = darshan_log_seek(fd, fd->rec_map.off);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
-        free(comp_buf);
-        free(hash_buf);
-        return(-1);
-    }
-
-    /* read the record hash from the log file */
-    ret = darshan_log_read(fd, comp_buf, fd->rec_map.len);
-    if(ret != fd->rec_map.len)
-    {
-        fprintf(stderr, "Error: failed to read record hash from darshan log file.\n");
-        free(comp_buf);
-        free(hash_buf);
-        return(-1);
-    }
-
-    /* decompress the record hash buffer */
-    ret = darshan_decompress_buf(comp_buf, fd->rec_map.len,
-        hash_buf, &hash_buf_sz, fd->comp_type);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to decompress darshan record map data.\n");
-        free(comp_buf);
-        free(hash_buf);
+    /* default to hash buffer twice as big as default compression buf */
+    hash_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ * 2);
+    if(!hash_buf)
         return(-1);
-    }
-    free(comp_buf);
+    memset(hash_buf, 0, DARSHAN_DEF_COMP_BUF_SZ * 2);
+    hash_buf_sz = DARSHAN_DEF_COMP_BUF_SZ * 2;
 
-    buf_ptr = hash_buf;
-    while(buf_ptr < (hash_buf + hash_buf_sz))
+    do
     {
-        /* get pointers for each field of this darshan record */
-        /* NOTE: darshan record hash serialization method: 
-         *          ... darshan_record_id | (uint32_t) path_len | path ...
+        /* read chunks of the darshan record id -> file name mapping from log file,
+         * constructing a hash table in the process
          */
-        rec_id_ptr = (darshan_record_id *)buf_ptr;
-        buf_ptr += sizeof(darshan_record_id);
-        path_len_ptr = (uint32_t *)buf_ptr;
-        buf_ptr += sizeof(uint32_t);
-        path_ptr = (char *)buf_ptr;
-
-        if(fd->swap_flag)
+        read_req_sz = hash_buf_sz - buf_remaining;
+        read = darshan_log_dzread(fd, DARSHAN_REC_MAP_REGION_ID,
+            hash_buf + buf_remaining, read_req_sz);
+        if(read < 0)
         {
-            /* we need to sort out endianness issues before deserializing */
-            DARSHAN_BSWAP64(rec_id_ptr);
-            DARSHAN_BSWAP32(path_len_ptr);
+            fprintf(stderr, "Error: failed to read record hash from darshan log file.\n");
+            free(hash_buf);
+            return(-1);
         }
 
-        HASH_FIND(hlink, *hash, rec_id_ptr, sizeof(darshan_record_id), ref);
-        if(!ref)
+        /* work through the hash buffer -- deserialize the mapping data and
+         * add to the output hash table
+         * NOTE: these mapping pairs are variable in length, so we have to be able
+         * to handle incomplete mappings temporarily here
+         */
+        buf_ptr = hash_buf;
+        buf_remaining += read;
+        while(buf_remaining > (sizeof(darshan_record_id) + sizeof(uint32_t)))
         {
-            ref = malloc(sizeof(*ref));
-            if(!ref)
+            /* see if we have enough buf space to read in the next full record */
+            tmp_path_len = *(uint32_t *)(buf_ptr + sizeof(darshan_record_id));
+            if(fd->swap_flag)
+                DARSHAN_BSWAP32(&tmp_path_len);
+
+            /* we need to read more before we continue deserializing */
+            if(buf_remaining <
+                (sizeof(darshan_record_id) + sizeof(uint32_t) + tmp_path_len))
+                break;
+
+            /* get pointers for each field of this darshan record */
+            /* NOTE: darshan record hash serialization method: 
+             *          ... darshan_record_id | (uint32_t) path_len | path ...
+             */
+            rec_id_ptr = (darshan_record_id *)buf_ptr;
+            buf_ptr += sizeof(darshan_record_id);
+            path_len_ptr = (uint32_t *)buf_ptr;
+            buf_ptr += sizeof(uint32_t);
+            path_ptr = (char *)buf_ptr;
+
+            if(fd->swap_flag)
             {
-                free(hash_buf);
-                return(-1);
+                /* we need to sort out endianness issues before deserializing */
+                DARSHAN_BSWAP64(rec_id_ptr);
+                DARSHAN_BSWAP32(path_len_ptr);
             }
-            ref->rec.name = malloc(*path_len_ptr + 1);
-            if(!ref->rec.name)
+
+            HASH_FIND(hlink, *hash, rec_id_ptr, sizeof(darshan_record_id), ref);
+            if(!ref)
             {
-                free(ref);
-                free(hash_buf);
-                return(-1);
+                ref = malloc(sizeof(*ref));
+                if(!ref)
+                {
+                    free(hash_buf);
+                    return(-1);
+                }
+                ref->rec.name = malloc(*path_len_ptr + 1);
+                if(!ref->rec.name)
+                {
+                    free(ref);
+                    free(hash_buf);
+                    return(-1);
+                }
+
+                /* set the fields for this record */
+                ref->rec.id = *rec_id_ptr;
+                memcpy(ref->rec.name, path_ptr, *path_len_ptr);
+                ref->rec.name[*path_len_ptr] = '\0';
+
+                /* add this record to the hash */
+                HASH_ADD(hlink, *hash, rec.id, sizeof(darshan_record_id), ref);
             }
 
-            /* set the fields for this record */
-            ref->rec.id = *rec_id_ptr;
-            memcpy(ref->rec.name, path_ptr, *path_len_ptr);
-            ref->rec.name[*path_len_ptr] = '\0';
-
-            /* add this record to the hash */
-            HASH_ADD(hlink, *hash, rec.id, sizeof(darshan_record_id), ref);
+            buf_ptr += *path_len_ptr;
+            buf_remaining -=
+                (sizeof(darshan_record_id) + sizeof(uint32_t) + *path_len_ptr);
         }
 
-        buf_ptr += *path_len_ptr;
-    }
+        /* copy any leftover data to beginning of buffer to parse next */
+        memcpy(hash_buf, buf_ptr, buf_remaining);
+
+        /* we keep reading until we get a short read informing us we have
+         * read all of the record hash
+         */
+    } while(read == read_req_sz);
+    assert(buf_remaining == 0);
 
     free(hash_buf);
     return(0);
@@ -673,110 +560,62 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
  */
 int darshan_log_puthash(darshan_fd fd, struct darshan_record_ref *hash)
 {
-    size_t hash_buf_sz;
     char *hash_buf;
-    char *hash_buf_off;
+    int hash_buf_sz;
     struct darshan_record_ref *ref, *tmp;
-    uint32_t name_len;
-    size_t record_sz;
-    char *comp_buf;
-    int comp_buf_sz;
-    int ret;
+    char *buf_ptr;
+    int path_len;
+    int wrote;
 
-    /* allocate a buffer to store 2 MiB worth of record data */
-    /* NOTE: this buffer may be reallocated if estimate is too small */
-    hash_buf_sz = 2 * 1024 * 1024;
+    /* allocate memory for largest possible hash record */
+    hash_buf_sz = sizeof(darshan_record_id) + sizeof(uint32_t) + PATH_MAX;
     hash_buf = malloc(hash_buf_sz);
     if(!hash_buf)
-    {
         return(-1);
-    }
+    memset(hash_buf, 0, hash_buf_sz);
 
-    /* serialize the record hash into a buffer for writing */
-    hash_buf_off = hash_buf;
+    /* individually serialize each hash record and write to log file */
     HASH_ITER(hlink, hash, ref, tmp)
     {
-        name_len = strlen(ref->rec.name);
-        record_sz = sizeof(darshan_record_id) + sizeof(uint32_t) + name_len;
-        /* make sure there is room in the buffer for this record */
-        if((hash_buf_off + record_sz) > (hash_buf + hash_buf_sz))
-        {
-            char *tmp_buf;
-            size_t old_buf_sz;
-
-            /* if no room, reallocate the hash buffer at twice the current size */
-            old_buf_sz = hash_buf_off - hash_buf;
-            hash_buf_sz *= 2;
-            tmp_buf = malloc(hash_buf_sz);
-            if(!tmp_buf)
-            {
-                free(hash_buf);
-                return(-1);
-            }
+        buf_ptr = hash_buf;
+        path_len = strlen(ref->rec.name);
 
-            memcpy(tmp_buf, hash_buf, old_buf_sz);
-            free(hash_buf);
-            hash_buf = tmp_buf;
-            hash_buf_off = hash_buf + old_buf_sz;
-        }
-
-        /* now serialize the record into the hash buffer.
+        /* the hash buffer has space to serialize this record
          * NOTE: darshan record hash serialization method: 
          *          ... darshan_record_id | (uint32_t) path_len | path ...
          */
-        *((darshan_record_id *)hash_buf_off) = ref->rec.id;
-        hash_buf_off += sizeof(darshan_record_id);
-        *((uint32_t *)hash_buf_off) = name_len;
-        hash_buf_off += sizeof(uint32_t);
-        memcpy(hash_buf_off, ref->rec.name, name_len);
-        hash_buf_off += name_len;
-    }
-    hash_buf_sz = hash_buf_off - hash_buf;
-
-    comp_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
-    if(!comp_buf)
-        return(-1);
-    comp_buf_sz = DARSHAN_DEF_COMP_BUF_SZ;
-
-    /* compress the record hash */
-    ret = darshan_compress_buf(hash_buf, hash_buf_sz,
-        comp_buf, &comp_buf_sz, fd->comp_type);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to compress darshan record hash.\n");
-        free(comp_buf);
-        free(hash_buf);
-        return(-1);
-    }
-
-    /* set the appropriate mapping info for the record hash in the file descriptor */
-    fd->rec_map.off = fd->pos;
-    fd->rec_map.len = comp_buf_sz;
+        *((darshan_record_id *)buf_ptr) = ref->rec.id;
+        buf_ptr += sizeof(darshan_record_id);
+        *((uint32_t *)buf_ptr) = path_len;
+        buf_ptr += sizeof(uint32_t);
+        memcpy(buf_ptr, ref->rec.name, path_len);
+        buf_ptr += path_len;
 
-    /* write the record hash to file */
-    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
-    if(ret != comp_buf_sz)
-    {
-        fprintf(stderr, "Error: failed to write record hash to darshan log file.\n");
-        free(comp_buf);
-        free(hash_buf);
-        return(-1);
+        /* write this hash entry to log file */
+        wrote = darshan_log_dzwrite(fd, DARSHAN_REC_MAP_REGION_ID,
+            hash_buf, (buf_ptr - hash_buf));
+        if(wrote != (buf_ptr - hash_buf))
+        {
+            fd->err = -1;
+            fprintf(stderr, "Error: failed to write record hash to darshan log file.\n");
+            free(hash_buf);
+            return(-1);
+        }
     }
 
-    free(comp_buf);
     free(hash_buf);
-
     return(0);
 }
 
 /* darshan_log_getmod()
  *
- * returns 1 on successful read of module data, 0 on no data, -1 on failure
+ * get a chunk of module data from the darshan log file
+ *
+ * returns 0 on success, -1 on failure
  */
 int darshan_log_getmod(darshan_fd fd, darshan_module_id mod_id,
-    void *mod_buf, int *mod_buf_sz)
+    void *buf, int len)
 {
-    char *comp_buf;
     int ret;
 
     if(mod_id < 0 || mod_id >= DARSHAN_MAX_MODS)
@@ -788,42 +627,17 @@ int darshan_log_getmod(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 */
 
-    comp_buf = malloc(fd->mod_map[mod_id].len);
-    if(!comp_buf)
-        return(-1);
-
-    ret = darshan_log_seek(fd, fd->mod_map[mod_id].off);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
-        free(comp_buf);
-        return(ret);
-    }
-
     /* read this module's data from the log file */
-    ret = darshan_log_read(fd, comp_buf, fd->mod_map[mod_id].len);
-    if(ret != fd->mod_map[mod_id].len)
+    ret = darshan_log_dzread(fd, mod_id, buf, len);
+    if(ret < 0)
     {
         fprintf(stderr,
             "Error: failed to read module %s data from darshan log file.\n",
             darshan_module_names[mod_id]);
-        free(comp_buf);
         return(-1);
     }
 
-    /* decompress this module's data */
-    ret = darshan_decompress_buf(comp_buf, fd->mod_map[mod_id].len,
-        mod_buf, mod_buf_sz, fd->comp_type);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to decompress module %s data.\n",
-            darshan_module_names[mod_id]);
-        free(comp_buf);
-        return(-1);
-    }
-    free(comp_buf);
-
-    return(1);
+    return(ret);
 }
 
 /* darshan_log_putmod()
@@ -841,65 +655,77 @@ int darshan_log_getmod(darshan_fd fd, darshan_module_id mod_id,
 int darshan_log_putmod(darshan_fd fd, darshan_module_id mod_id,
     void *mod_buf, int mod_buf_sz)
 {
-    char *comp_buf;
-    int comp_buf_sz;
     int ret;
 
     if(mod_id < 0 || mod_id >= DARSHAN_MAX_MODS)
     {
+        fd->err = -1;
         fprintf(stderr, "Error: invalid Darshan module id.\n");
         return(-1);
     }
 
-    comp_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
-    if(!comp_buf)
-        return(-1);
-    comp_buf_sz = DARSHAN_DEF_COMP_BUF_SZ;
-
-    /* compress the module's data */
-    ret = darshan_compress_buf(mod_buf, mod_buf_sz,
-        comp_buf, &comp_buf_sz, fd->comp_type);
-    if(ret < 0)
-    {
-        fprintf(stderr, "Error: unable to compress module %s data.\n",
-            darshan_module_names[mod_id]);
-        free(comp_buf);
-        return(-1);
-    }
-
-    /* set the appropriate mapping information for this module */
-    fd->mod_map[mod_id].off = fd->pos;
-    fd->mod_map[mod_id].len = comp_buf_sz;
-
     /* write the module chunk to the log file */
-    ret = darshan_log_write(fd, comp_buf, comp_buf_sz);
-    if(ret != comp_buf_sz)
+    ret = darshan_log_dzwrite(fd, mod_id, mod_buf, mod_buf_sz);
+    if(ret != mod_buf_sz)
     {
+        fd->err = -1;
         fprintf(stderr,
             "Error: failed to write module %s data to darshan log file.\n",
             darshan_module_names[mod_id]);
-        free(comp_buf);
         return(-1);
     }
 
-    free(comp_buf);
     return(0);
 }
 
 /* darshan_log_close()
  *
- * close an open darshan file descriptor
+ * close an open darshan file descriptor, freeing any resources
  *
  * returns 0 on success, -1 on failure
  */
 void darshan_log_close(darshan_fd fd)
 {
-    if(fd->fildes)
-        close(fd->fildes);
+    int ret;
+
+    if(fd->o_flags & O_WRONLY)
+    {
+        /* flush the last region of the log to file */
+        switch(fd->comp_type)
+        {
+            case DARSHAN_ZLIB_COMP:
+                ret = darshan_log_libz_flush(fd, fd->dz_prev_reg_id);
+                if(ret == 0)
+                    break;
+            default:
+                /* if flush fails, remove the output log file */
+                fd->err = -1;
+                fprintf(stderr, "Error: final flush to log file failed.\n");
+                break;
+        }
+
+        /* if no errors flushing, write the log header before closing */
+        if(fd->err != -1)
+        {
+            ret = darshan_log_putheader(fd);
+            if(ret < 0)
+                fd->err = -1;
+        }
+    }
+
+    close(fd->fildes);
+
+    /* remove output log file if error writing to it */
+    if((fd->o_flags & O_WRONLY ) && (fd->err == -1))
+    {
+        fprintf(stderr, "Unlinking darshan log file %s ...\n",
+            fd->logfile_path);
+        unlink(fd->logfile_path);
+    }
 
+    darshan_log_dzdestroy(fd);
     if(fd->exe_mnt_data)
         free(fd->exe_mnt_data);
-
     free(fd);
 
     return;
@@ -907,6 +733,112 @@ void darshan_log_close(darshan_fd fd)
 
 /* **************************************************** */
 
+/* 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
+ *
+ * returns 0 on success, -1 on failure
+ */
+static int darshan_log_getheader(darshan_fd fd)
+{
+    struct darshan_header header;
+    int i;
+    int ret;
+
+    ret = darshan_log_seek(fd, 0);
+    if(ret < 0)
+    {
+        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
+        return(-1);
+    }
+
+    /* read uncompressed header from log file */
+    ret = darshan_log_read(fd, &header, sizeof(header));
+    if(ret != sizeof(header))
+    {
+        fprintf(stderr, "Error: failed to read darshan log file header.\n");
+        return(-1);
+    }
+
+    /* save the version string */
+    strncpy(fd->version, header.version_string, 8);
+
+    if(header.magic_nr == DARSHAN_MAGIC_NR)
+    {
+        /* no byte swapping needed, this file is in host format already */
+        fd->swap_flag = 0;
+    }
+    else
+    {
+        /* try byte swapping */
+        DARSHAN_BSWAP64(&(header.magic_nr));
+        if(header.magic_nr == DARSHAN_MAGIC_NR)
+        {
+            fd->swap_flag = 1;
+
+            /* swap the log map variables in the header */
+            DARSHAN_BSWAP64(&(header.rec_map.off));
+            DARSHAN_BSWAP64(&(header.rec_map.len));
+            for(i = 0; i < DARSHAN_MAX_MODS; i++)
+            {
+                DARSHAN_BSWAP64(&(header.mod_map[i].off));
+                DARSHAN_BSWAP64(&(header.mod_map[i].len));
+            }
+        }
+        else
+        {
+            /* otherwise this file is just broken */
+            fprintf(stderr, "Error: bad magic number in darshan log file.\n");
+            return(-1);
+        }
+    }
+
+    fd->comp_type = header.comp_type;
+
+    /* save the mapping of data within log file to this file descriptor */
+    fd->job_map.off = sizeof(struct darshan_header);
+    fd->job_map.len = header.rec_map.off - fd->job_map.off;
+    memcpy(&fd->rec_map, &(header.rec_map), sizeof(struct darshan_log_map));
+    memcpy(&fd->mod_map, &(header.mod_map), DARSHAN_MAX_MODS * sizeof(struct darshan_log_map));
+
+    return(0);
+}
+
+/* write a darshan header to log file
+ *
+ * returns 0 on success, -1 on failure
+ */
+static int darshan_log_putheader(darshan_fd fd)
+{
+    struct darshan_header header;
+    int ret;
+
+    ret = darshan_log_seek(fd, 0);
+    if(ret < 0)
+    {
+        fprintf(stderr, "Error: unable to seek in darshan log file.\n");
+        return(-1);
+    }
+
+    memset(&header, 0, sizeof(header));
+    strcpy(header.version_string, DARSHAN_LOG_VERSION);
+    header.magic_nr = DARSHAN_MAGIC_NR;
+    header.comp_type = fd->comp_type;
+
+    /* copy the mapping information to the header */
+    memcpy(&header.rec_map, &fd->rec_map, sizeof(struct darshan_log_map));
+    memcpy(&header.mod_map, &fd->mod_map, DARSHAN_MAX_MODS * sizeof(struct darshan_log_map));
+
+    /* write header to file */
+    ret = darshan_log_write(fd, &header, sizeof(header));
+    if(ret != sizeof(header))
+    {
+        fprintf(stderr, "Error: failed to write Darshan log file header.\n");
+        return(-1);
+    }
+
+    return(0);
+}
+
 /* return 0 on successful seek to offset, -1 on failure.
  */
 static int darshan_log_seek(darshan_fd fd, off_t offset)
@@ -953,151 +885,307 @@ static int darshan_log_write(darshan_fd fd, void* buf, int len)
     return(ret);
 }
 
-/* return 0 on successful decompression, -1 on failure
- */
-static int darshan_decompress_buf(char* comp_buf, int comp_buf_sz,
-    char* decomp_buf, int* inout_decomp_buf_sz,
-    enum darshan_comp_type comp_type)
+static int darshan_log_dzinit(darshan_fd fd)
 {
     int ret;
 
-    switch(comp_type)
+    /* initialize buffers for staging compressed data to/from log file */
+    fd->dz_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
+    if(fd->dz_buf == NULL)
+        return(-1);
+
+    fd->dz_prev_reg_id = DARSHAN_HEADER_REGION_ID;
+
+    switch(fd->comp_type)
     {
         case DARSHAN_ZLIB_COMP:
-            ret = darshan_zlib_decomp(comp_buf, comp_buf_sz,
-                decomp_buf, inout_decomp_buf_sz);
+        {
+            z_stream *tmp_zstrm = malloc(sizeof(*tmp_zstrm));
+            if(!tmp_zstrm)
+            {
+                free(fd->dz_buf);
+                return(-1);
+            }
+            tmp_zstrm->zalloc = Z_NULL;
+            tmp_zstrm->zfree = Z_NULL;
+            tmp_zstrm->opaque = Z_NULL;
+            tmp_zstrm->avail_in = 0;
+            tmp_zstrm->next_in = Z_NULL;
+
+            /* TODO: worth using {inflate/deflate}Init2 ?? */
+            if(fd->o_flags == O_RDONLY)
+            {
+                /* read only file, init inflate algorithm */
+                ret = inflateInit(tmp_zstrm);
+            }
+            else
+            {
+                /* write only file, init deflate algorithm */
+                ret = deflateInit(tmp_zstrm, Z_DEFAULT_COMPRESSION);
+                tmp_zstrm->avail_out = DARSHAN_DEF_COMP_BUF_SZ;
+                tmp_zstrm->next_out = fd->dz_buf;
+            }
+            if(ret != Z_OK)
+            {
+                free(tmp_zstrm);
+                free(fd->dz_buf);
+                return(-1);
+            }
+            fd->dz_strm = tmp_zstrm;
             break;
-#ifdef HAVE_LIBBZ2
-        case DARSHAN_BZIP2_COMP:
-            ret = darshan_bzip2_decomp(comp_buf, comp_buf_sz,
-                decomp_buf, inout_decomp_buf_sz);
+        }
+        default:
+            fprintf(stderr, "Error: invalid compression type.\n");
+            return(-1);
+    }
+
+    return(0);
+}
+
+static void darshan_log_dzdestroy(darshan_fd fd)
+{
+    switch(fd->comp_type)
+    {
+        case DARSHAN_ZLIB_COMP:
+            if(fd->o_flags == O_RDONLY)
+            {
+                inflateEnd(fd->dz_strm);
+            }
+            else
+            {
+                deflateEnd(fd->dz_strm);
+            }
+            free(fd->dz_strm);
+            break;
+        default:
+            fprintf(stderr, "Error: invalid compression type.\n");
+    }
+
+    free(fd->dz_buf);
+    return;
+}
+
+static int darshan_log_dzread(darshan_fd fd, int region_id, void *buf, int len)
+{
+    int ret;
+
+    switch(fd->comp_type)
+    {
+        case DARSHAN_ZLIB_COMP:
+            ret = darshan_log_libz_read(fd, region_id, buf, len);
             break;
-#endif
         default:
-            fprintf(stderr, "Error: invalid decompression method.\n");
+            fprintf(stderr, "Error: invalid compression type.\n");
             return(-1);
     }
 
     return(ret);
 }
 
-static int darshan_compress_buf(char* decomp_buf, int decomp_buf_sz,
-    char* comp_buf, int* inout_comp_buf_sz,
-    enum darshan_comp_type comp_type)
+static int darshan_log_dzwrite(darshan_fd fd, int region_id, void *buf, int len)
 {
     int ret;
 
-    switch(comp_type)
+    switch(fd->comp_type)
     {
         case DARSHAN_ZLIB_COMP:
-            ret = darshan_zlib_comp(decomp_buf, decomp_buf_sz,
-                comp_buf, inout_comp_buf_sz);
-            break;
-#ifdef HAVE_LIBBZ2
-        case DARSHAN_BZIP2_COMP:
-            ret = darshan_bzip2_comp(decomp_buf, decomp_buf_sz,
-                comp_buf, inout_comp_buf_sz);
+            ret = darshan_log_libz_write(fd, region_id, buf, len);
             break;
-#endif
         default:
-            fprintf(stderr, "Error: invalid compression method.\n");
+            fprintf(stderr, "Error: invalid compression type.\n");
             return(-1);
     }
 
     return(ret);
-
 }
 
-static int darshan_zlib_decomp(char* comp_buf, int comp_buf_sz,
-    char* decomp_buf, int* inout_decomp_buf_sz)
+static int darshan_log_libz_read(darshan_fd fd, int region_id, void *buf, int len)
 {
     int ret;
-    int total_out = 0;
-    z_stream tmp_stream;
+    int total_bytes = 0;
+    int tmp_out_bytes;
+    struct darshan_log_map map;
+    z_stream *z_strmp = (z_stream *)fd->dz_strm;
 
-    memset(&tmp_stream, 0, sizeof(tmp_stream));
-    tmp_stream.zalloc = Z_NULL;
-    tmp_stream.zfree = Z_NULL;
-    tmp_stream.opaque = Z_NULL;
-    tmp_stream.next_in = (unsigned char*)comp_buf;
-    tmp_stream.avail_in = comp_buf_sz;
-    tmp_stream.next_out = (unsigned char*)decomp_buf;
-    tmp_stream.avail_out = *inout_decomp_buf_sz;
+    assert(fd->dz_strm);
 
-    /* initialize the zlib decompression parameters */
-    /* TODO: check these parameters? */
-    //ret = inflateInit2(&tmp_stream, 31);
-    ret = inflateInit(&tmp_stream);
-    if(ret != Z_OK)
+    /* if new log region, we reload buffers and clear eor flag */
+    if(region_id != fd->dz_prev_reg_id)
     {
-        return(-1);
+        z_strmp->avail_in = 0;
+        fd->dz_eor = 0;
+        fd->dz_prev_reg_id = region_id;
     }
 
-    /* while we have not finished consuming all of the compressed input data */
-    while(tmp_stream.avail_in)
+    if(region_id == DARSHAN_JOB_REGION_ID)
+        map = fd->job_map;
+    else if(region_id == DARSHAN_REC_MAP_REGION_ID)
+        map = fd->rec_map;
+    else
+        map = fd->mod_map[region_id];
+
+    z_strmp->avail_out = len;
+    z_strmp->next_out = buf;
+
+    /* we just decompress until the output buffer is full, assuming there
+     * is enough compressed data in file to satisfy the request size.
+     */
+    while(z_strmp->avail_out)
     {
-        if(tmp_stream.avail_out == 0)
+        /* check if we need more compressed data */
+        if(z_strmp->avail_in == 0)
         {
-            /* We ran out of buffer space for decompression.  In theory,
-             * we could just alloc more space, but probably just easier
-             * to bump up the default size of the output buffer.
+            /* if the eor flag is set, clear it and return -- future
+             * reads of this log region will restart at the beginning
              */
-            inflateEnd(&tmp_stream);
-            return(-1);
+            if(fd->dz_eor)
+            {
+                fd->dz_eor = 0;
+                break;
+            }
+
+            /* read more data from input file */
+            ret = darshan_log_dzload(fd, map);
+            if(ret < 0)
+                return(-1);
+            assert(fd->dz_size > 0);
+
+            z_strmp->avail_in = fd->dz_size;
+            z_strmp->next_in = fd->dz_buf;
         }
 
-        /* decompress data */
-        ret = inflate(&tmp_stream, Z_FINISH);
-        if(ret != Z_STREAM_END)
+        tmp_out_bytes = z_strmp->total_out;
+        ret = inflate(z_strmp, Z_NO_FLUSH);
+        if(ret != Z_OK && ret != Z_STREAM_END)
         {
-            inflateEnd(&tmp_stream);
+            fprintf(stderr, "Error: unable to inflate darshan log data.\n");
             return(-1);
         }
+        total_bytes += (z_strmp->total_out - tmp_out_bytes);
 
-        total_out += tmp_stream.total_out;
-        if(tmp_stream.avail_in)
-            inflateReset(&tmp_stream);
+        /* reset the decompression if we encountered end of stream */
+        if(ret == Z_STREAM_END)
+            inflateReset(z_strmp);
     }
-    inflateEnd(&tmp_stream);
 
-    *inout_decomp_buf_sz = total_out;
-    return(0);
+    return(total_bytes);
 }
 
-static int darshan_zlib_comp(char* decomp_buf, int decomp_buf_sz,
-    char* comp_buf, int* inout_comp_buf_sz)
+static int darshan_log_libz_write(darshan_fd fd, int region_id, void *buf, int len)
 {
     int ret;
-    z_stream tmp_stream;
+    int total_bytes = 0;
+    int tmp_in_bytes;
+    int tmp_out_bytes;
+    struct darshan_log_map *map_p;
+    z_stream *z_strmp = (z_stream *)fd->dz_strm;
 
-    memset(&tmp_stream, 0, sizeof(tmp_stream));
-    tmp_stream.zalloc = Z_NULL;
-    tmp_stream.zfree = Z_NULL;
-    tmp_stream.opaque = Z_NULL;
-    tmp_stream.next_in = (unsigned char*)decomp_buf;
-    tmp_stream.avail_in = decomp_buf_sz;
-    tmp_stream.next_out = (unsigned char*)comp_buf;
-    tmp_stream.avail_out = *inout_comp_buf_sz;
+    assert(fd->dz_strm);
 
-    ret = deflateInit(&tmp_stream, Z_DEFAULT_COMPRESSION);
-    if(ret != Z_OK)
+    /* if new log region, finish prev region's zstream and flush to log file */
+    if(region_id != fd->dz_prev_reg_id)
     {
-        return(-1);
+        /* error out if the region we are writing to precedes the previous
+         * region we wrote -- we shouldn't be moving backwards in the log
+         */
+        if(region_id < fd->dz_prev_reg_id)
+            return(-1);
+
+        if(fd->dz_prev_reg_id != DARSHAN_HEADER_REGION_ID)
+        {
+            ret = darshan_log_libz_flush(fd, fd->dz_prev_reg_id);
+            if(ret < 0)
+                return(-1);
+        }
+
+        fd->dz_prev_reg_id = region_id;
     }
 
-    /* compress data */
-    ret = deflate(&tmp_stream, Z_FINISH);
-    if(ret != Z_STREAM_END)
+    if(region_id == DARSHAN_JOB_REGION_ID)
+        map_p = &(fd->job_map);
+    else if(region_id == DARSHAN_REC_MAP_REGION_ID)
+        map_p = &(fd->rec_map);
+    else
+        map_p = &(fd->mod_map[region_id]);
+
+    z_strmp->avail_in = len;
+    z_strmp->next_in = buf;
+
+    /* compress input data until none left */
+    while(z_strmp->avail_in)
     {
-        deflateEnd(&tmp_stream);
-        return(-1);
+        /* if we are out of output, flush to log file */
+        if(z_strmp->avail_out == 0)
+        {
+            assert(fd->dz_size == DARSHAN_DEF_COMP_BUF_SZ);
+
+            ret = darshan_log_dzunload(fd, map_p);
+            if(ret < 0)
+                return(-1);
+
+            z_strmp->avail_out = DARSHAN_DEF_COMP_BUF_SZ;
+            z_strmp->next_out = fd->dz_buf;
+        }
+
+        tmp_in_bytes = z_strmp->total_in;
+        tmp_out_bytes = z_strmp->total_out;
+        ret = deflate(z_strmp, Z_NO_FLUSH);
+        if(ret != Z_OK)
+        {
+            fprintf(stderr, "Error: unable to deflate darshan log data.\n");
+            return(-1);
+        }
+        total_bytes += (z_strmp->total_in - tmp_in_bytes);
+        fd->dz_size += (z_strmp->total_out - tmp_out_bytes);
     }
-    deflateEnd(&tmp_stream);
 
-    *inout_comp_buf_sz = tmp_stream.total_out;
+    return(total_bytes);
+}
+
+static int darshan_log_libz_flush(darshan_fd fd, int region_id)
+{
+    int ret;
+    int tmp_out_bytes;
+    struct darshan_log_map *map_p;
+    z_stream *z_strmp = (z_stream *)fd->dz_strm;
+
+    if(region_id == DARSHAN_JOB_REGION_ID)
+        map_p = &(fd->job_map);
+    else if(region_id == DARSHAN_REC_MAP_REGION_ID)
+        map_p = &(fd->rec_map);
+    else
+        map_p = &(fd->mod_map[region_id]);
+
+    /* make sure deflate finishes this stream */
+    z_strmp->avail_in = 0;
+    z_strmp->next_in = NULL;
+    do
+    {
+        tmp_out_bytes = z_strmp->total_out;
+        ret = deflate(z_strmp, Z_FINISH);
+        if(ret < 0)
+        {
+            fprintf(stderr, "Error: unable to deflate darshan log data.\n");
+            return(-1);
+        }
+        fd->dz_size += (z_strmp->total_out - tmp_out_bytes);
+
+        if(fd->dz_size)
+        {
+            /* flush to file */
+            if(darshan_log_dzunload(fd, map_p) < 0)
+                return(-1);
+
+            z_strmp->avail_out = DARSHAN_DEF_COMP_BUF_SZ;
+            z_strmp->next_out = fd->dz_buf;
+        }
+    } while (ret != Z_STREAM_END);
+
+    deflateReset(z_strmp);
     return(0);
 }
 
+#if 0
 #ifdef HAVE_LIBBZ2
 static int darshan_bzip2_decomp(char* comp_buf, int comp_buf_sz,
     char* decomp_buf, int* inout_decomp_buf_sz)
@@ -1201,6 +1289,80 @@ static int darshan_bzip2_comp(char* decomp_buf, int decomp_buf_sz,
     return(0);
 }
 #endif
+#endif
+
+static int darshan_log_dzload(darshan_fd fd, struct darshan_log_map map)
+{
+    int ret;
+    unsigned int remaining;
+    unsigned int read_size;
+    unsigned int read_so_far = 0;
+
+    fd->dz_size = 0;
+
+    /* seek to the appropriate portion of the log file, if out of range */
+    if((fd->pos < map.off) || (fd->pos >= (map.off + map.len)))
+    {
+        ret = darshan_log_seek(fd, map.off);
+        if(ret < 0)
+        {
+            fprintf(stderr, "Error: unable to seek in darshan log file.\n");
+            return(-1);
+        }
+    }
+
+    /* read more compressed data from file to staging buffer */
+    remaining = (map.off + map.len) - fd->pos;
+    read_size = (remaining > DARSHAN_DEF_COMP_BUF_SZ) ?
+        DARSHAN_DEF_COMP_BUF_SZ : remaining;
+    do
+    {
+        ret = darshan_log_read(fd, fd->dz_buf + read_so_far,
+            read_size - read_so_far);
+        if(ret <= 0)
+            break;
+        read_so_far += ret;
+    } while(read_so_far < read_size);
+    if(ret < 0)
+    {
+        fprintf(stderr, "Error: unable to read compressed data from file.\n");
+        return(-1);
+    }
+    if((read_size == remaining) || (ret == 0))
+    {
+        fd->dz_eor = 1;
+    }
+
+    fd->dz_size = read_size;
+    return(0);
+}
+
+static int darshan_log_dzunload(darshan_fd fd, struct darshan_log_map *map_p)
+{
+    int ret;
+    unsigned int write_so_far = 0;
+
+    /* initialize map structure for this log region */
+    if(map_p->off == 0)
+        map_p->off = fd->pos;
+
+    /* write more compressed data from staging buffer to file */
+    do
+    {
+        ret = darshan_log_write(fd, fd->dz_buf + write_so_far,
+            fd->dz_size - write_so_far);
+        if(ret <= 0)
+        {
+            fprintf(stderr, "Error: unable to write compressed data to file.\n");
+            return(-1);
+        }
+        write_so_far += ret;
+    } while(write_so_far < fd->dz_size);
+
+    map_p->len += fd->dz_size;
+    fd->dz_size = 0;
+    return (0);
+}
 
 /*
  * Local variables:
diff --git a/darshan-util/darshan-logutils.h b/darshan-util/darshan-logutils.h
index f188575..daac641 100644
--- a/darshan-util/darshan-logutils.h
+++ b/darshan-util/darshan-logutils.h
@@ -16,9 +16,6 @@
 
 #include "darshan-log-format.h"
 
-/* default to a buffer size of 4 MiB for compression/decompression */
-#define DARSHAN_DEF_COMP_BUF_SZ (4*1024*1024)
-
 /* TODO: can we refactor this def out of header? modules currently poke at swap_flag
  * directly, but other than that there's no reason for another module to know this
  * definition.
@@ -26,14 +23,24 @@
 struct darshan_fd_s
 {
     int fildes;
+    int o_flags;
     int64_t pos;
     enum darshan_comp_type comp_type;
+    char logfile_path[PATH_MAX];
     char version[8];
     int swap_flag;
     char *exe_mnt_data;
     struct darshan_log_map job_map;
     struct darshan_log_map rec_map;
     struct darshan_log_map mod_map[DARSHAN_MAX_MODS];
+    int err;
+
+    /* XXX */
+    void *dz_strm;
+    int dz_size;
+    unsigned char *dz_buf;
+    int dz_eor;
+    int dz_prev_reg_id;
 };
 typedef struct darshan_fd_s* darshan_fd;
 
@@ -46,11 +53,13 @@ struct darshan_record_ref
 struct darshan_mod_logutil_funcs
 {
     int (*log_get_record)(
-        void** mod_buf_p,
-        int* mod_bytes_left,
-        void** file_rec,
-        darshan_record_id* rec_id,
-        int byte_swap_flag
+        darshan_fd fd,
+        void* buf,
+        darshan_record_id* rec_id
+    );
+    int (*log_put_record)(
+        darshan_fd fd,
+        void *buf
     );
     void (*log_print_record)(
         void *file_rec,
@@ -70,8 +79,6 @@ extern struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS];
 
 darshan_fd darshan_log_open(const char *name);
 darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type);
-int darshan_log_getheader(darshan_fd fd, struct darshan_header *header);
-int darshan_log_putheader(darshan_fd fd);
 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);
@@ -83,7 +90,7 @@ int darshan_log_putmounts(darshan_fd fd, char** mnt_pts,
 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,
-    void *mod_buf, int *mod_buf_sz);
+    void *buf, int len);
 int darshan_log_putmod(darshan_fd fd, darshan_module_id mod_id,
     void *mod_buf, int mod_buf_sz);
 void darshan_log_close(darshan_fd file);
diff --git a/darshan-util/darshan-mpiio-logutils.c b/darshan-util/darshan-mpiio-logutils.c
index f6c30e6..d8dc57e 100644
--- a/darshan-util/darshan-mpiio-logutils.c
+++ b/darshan-util/darshan-mpiio-logutils.c
@@ -30,43 +30,60 @@ char *mpiio_f_counter_names[] = {
 };
 #undef X
 
-static int darshan_log_get_mpiio_file(void** mpiio_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag);
+static int darshan_log_get_mpiio_file(darshan_fd fd, void* mpiio_buf,
+    darshan_record_id* rec_id);
+static int darshan_log_put_mpiio_file(darshan_fd fd, void* mpiio_buf);
 static void darshan_log_print_mpiio_file(void *file_rec,
     char *file_name, char *mnt_pt, char *fs_type);
 
 struct darshan_mod_logutil_funcs mpiio_logutils =
 {
     .log_get_record = &darshan_log_get_mpiio_file,
+    .log_put_record = &darshan_log_put_mpiio_file,
     .log_print_record = &darshan_log_print_mpiio_file,
 };
 
-static int darshan_log_get_mpiio_file(void** mpiio_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag)
+static int darshan_log_get_mpiio_file(darshan_fd fd, void* mpiio_buf,
+    darshan_record_id* rec_id)
 {
+    struct darshan_mpiio_file *file;
     int i;
-    struct darshan_mpiio_file *file = (struct darshan_mpiio_file *)
-        (*mpiio_buf_p);
+    int ret;
 
-    if(*bytes_left < sizeof(struct darshan_mpiio_file))
+    ret = darshan_log_getmod(fd, DARSHAN_MPIIO_MOD, mpiio_buf,
+        sizeof(struct darshan_mpiio_file));
+    if(ret < 0)
         return(-1);
-
-    if(byte_swap_flag)
+    else if(ret < sizeof(struct darshan_mpiio_file))
+        return(0);
+    else
     {
-        /* swap bytes if necessary */
-        DARSHAN_BSWAP64(&file->f_id);
-        DARSHAN_BSWAP64(&file->rank);
-        for(i=0; i<MPIIO_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->counters[i]);
-        for(i=0; i<MPIIO_F_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->fcounters[i]);
+        file = (struct darshan_mpiio_file *)mpiio_buf;
+        if(fd->swap_flag)
+        {
+            /* swap bytes if necessary */
+            DARSHAN_BSWAP64(&file->f_id);
+            DARSHAN_BSWAP64(&file->rank);
+            for(i=0; i<MPIIO_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&file->counters[i]);
+            for(i=0; i<MPIIO_F_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&file->fcounters[i]);
+        }
+
+        *rec_id = file->f_id;
+        return(1);
     }
+}
 
-    /* update/set output variables */
-    *file_rec = (void *)file;
-    *rec_id = file->f_id;
-    *mpiio_buf_p = (file + 1); /* increment input buf by size of file record */
-    *bytes_left -= sizeof(struct darshan_mpiio_file);
+static int darshan_log_put_mpiio_file(darshan_fd fd, void* mpiio_buf)
+{
+    struct darshan_mpiio_file *file = (struct darshan_mpiio_file *)mpiio_buf;
+    int ret;
+
+    ret = darshan_log_putmod(fd, DARSHAN_MPIIO_MOD, file,
+        sizeof(struct darshan_mpiio_file));
+    if(ret < 0)
+        return(-1);
 
     return(0);
 }
diff --git a/darshan-util/darshan-parser.c b/darshan-util/darshan-parser.c
index 266033a..bbbc91b 100644
--- a/darshan-util/darshan-parser.c
+++ b/darshan-util/darshan-parser.c
@@ -20,6 +20,8 @@
 
 #include "darshan-logutils.h"
 
+#define DEF_MOD_BUF_SIZE 1024 /* 1 KiB is enough for all current mod records ... */
+
 /*
  * Options
  */
@@ -199,7 +201,6 @@ int main(int argc, char **argv)
     char *filename;
     char tmp_string[4096] = {0};
     darshan_fd fd;
-    struct darshan_header header;
     struct darshan_job job;
     struct darshan_record_ref *rec_hash = NULL;
     struct darshan_record_ref *ref, *tmp_ref;
@@ -211,8 +212,7 @@ int main(int argc, char **argv)
     char *save;
     char buffer[DARSHAN_JOB_METADATA_LEN];
     int empty_mods = 0;
-    char *mod_buf;
-    int mod_buf_sz;
+    char mod_buf[DEF_MOD_BUF_SIZE];
 
     hash_entry_t *file_hash = NULL;
     hash_entry_t *curr = NULL;
@@ -229,25 +229,12 @@ int main(int argc, char **argv)
 
     fd = darshan_log_open(filename);
     if(!fd)
-    {
-        fprintf(stderr, "darshan_log_open() failed to open %s\n.", filename);
-        return(-1);
-    }
-
-    /* read darshan log header */
-    ret = darshan_log_getheader(fd, &header);
-    if(ret < 0)
-    {
-        fprintf(stderr, "darshan_log_getheader() failed to read log header.\n");
-        darshan_log_close(fd);
         return(-1);
-    }
 
     /* read darshan job info */
     ret = darshan_log_getjob(fd, &job);
     if(ret < 0)
     {
-        fprintf(stderr, "darshan_log_getjob() failed to read job data.\n");
         darshan_log_close(fd);
         return(-1);
     }
@@ -256,7 +243,6 @@ int main(int argc, char **argv)
     ret = darshan_log_getexe(fd, tmp_string);
     if(ret < 0)
     {
-        fprintf(stderr, "Error: unable to read trailing job information.\n");
         darshan_log_close(fd);
         return(-1);
     }
@@ -265,7 +251,6 @@ int main(int argc, char **argv)
     ret = darshan_log_getmounts(fd, &mnt_pts, &fs_types, &mount_count);
     if(ret < 0)
     {
-        fprintf(stderr, "darshan_log_getmounts() failed to read mount information.\n");
         darshan_log_close(fd);
         return(-1);
     }
@@ -274,13 +259,12 @@ int main(int argc, char **argv)
     ret = darshan_log_gethash(fd, &rec_hash);
     if(ret < 0)
     {
-        fprintf(stderr, "darshan_log_getmap() failed to read record map.\n");
         darshan_log_close(fd);
         return(-1);
     }
 
     /* print job summary */
-    printf("# darshan log version: %s\n", header.version_string);
+    printf("# darshan log version: %s\n", fd->version);
     printf("# exe: %s\n", tmp_string);
     printf("# uid: %" PRId64 "\n", job.uid);
     printf("# jobid: %" PRId64 "\n", job.jobid);
@@ -318,14 +302,14 @@ int main(int argc, char **argv)
     printf("\n# log file component sizes (compressed)\n");
     printf("# -------------------------------------------------------\n");
     printf("# header: %zu bytes (uncompressed)\n", sizeof(struct darshan_header));
-    printf("# job data: %zu bytes\n", header.rec_map.off - sizeof(struct darshan_header));
-    printf("# record table: %zu bytes\n", header.rec_map.len);
+    printf("# job data: %zu bytes\n", fd->job_map.len);
+    printf("# record table: %zu bytes\n", fd->rec_map.len);
     for(i=0; i<DARSHAN_MAX_MODS; i++)
     {
-        if(header.mod_map[i].len)
+        if(fd->mod_map[i].len)
         {
             printf("# %s module: %zu bytes\n", darshan_module_names[i],
-                header.mod_map[i].len);
+                fd->mod_map[i].len);
         }
     }
 
@@ -337,10 +321,6 @@ int main(int argc, char **argv)
         printf("# mount entry:\t%s\t%s\n", mnt_pts[i], fs_types[i]);
     }
 
-    mod_buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
-    if(!mod_buf)
-        return(-1);
-
     pdata.rank_cumul_io_time = malloc(sizeof(double)*job.nprocs);
     pdata.rank_cumul_md_time = malloc(sizeof(double)*job.nprocs);
     if (!pdata.rank_cumul_io_time || !pdata.rank_cumul_md_time)
@@ -356,40 +336,25 @@ int main(int argc, char **argv)
 
     for(i=0; i<DARSHAN_MAX_MODS; i++)
     {
-        int mod_bytes_left;
-        void *mod_buf_p;
-        void *rec_p = NULL;
         darshan_record_id rec_id;
         void *save_io, *save_md;
 
-        /* reset data structures for each module */
-        mod_buf_sz = DARSHAN_DEF_COMP_BUF_SZ;
-        memset(mod_buf, 0, DARSHAN_DEF_COMP_BUF_SZ);
-
         /* check each module for any data */
-        ret = darshan_log_getmod(fd, i, mod_buf, &mod_buf_sz);
-        if(ret < 0)
+        if(fd->mod_map[i].len == 0)
         {
-            fprintf(stderr, "Error: failed to get module %s data\n",
-                darshan_module_names[i]);
-            darshan_log_close(fd);
-            return(-1);
-        }
-        else if(ret == 0)
-        {
-            /* skip modules not present in log file */
             empty_mods++;
             continue;
         }
-
-        /* skip modules with no defined logutil handlers */
-        if(!mod_logutils[i])
+        else if(!mod_logutils[i])
         {
             fprintf(stderr, "Warning: no log utility handlers defined "
-                "for module %s, SKIPPING\n", darshan_module_names[i]);
+                "for module %s, SKIPPING.\n", darshan_module_names[i]);
             continue;
         }
 
+        /* this module has data to be parsed and printed */
+        memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
+
         printf("\n# *******************************************************\n");
         printf("# %s module data\n", darshan_module_names[i]);
         printf("# *******************************************************\n");
@@ -400,27 +365,22 @@ int main(int argc, char **argv)
             DARSHAN_PRINT_HEADER();
         }
 
-        /* this module has data to be parsed and printed */
-        mod_bytes_left = mod_buf_sz;
-        mod_buf_p = mod_buf;
+        ret = mod_logutils[i]->log_get_record(fd, mod_buf, &rec_id);
+        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 */
-        while (mod_bytes_left > 0)
+        do
         {
             char *mnt_pt = NULL;
             char *fs_type = NULL;
             hash_entry_t *hfile = NULL;
 
-            ret = mod_logutils[i]->log_get_record(&mod_buf_p, &mod_bytes_left,
-                &rec_p, &rec_id, fd->swap_flag);
-            if(ret < 0)
-            {
-                fprintf(stderr, "Error: failed to parse module %s data record\n",
-                    darshan_module_names[i]);
-                darshan_log_close(fd);
-                return(-1);
-            }
-
             /* get the pathname for this record */
             HASH_FIND(hlink, rec_hash, &rec_id, sizeof(darshan_record_id), ref);
             assert(ref);
@@ -443,7 +403,7 @@ int main(int argc, char **argv)
             if(mask & OPTION_BASE)
             {
                 /* print the corresponding module data for this record */
-                mod_logutils[i]->log_print_record(rec_p, ref->rec.name,
+                mod_logutils[i]->log_print_record(mod_buf, ref->rec.name,
                     mnt_pt, fs_type);
             }
 
@@ -458,7 +418,10 @@ int main(int argc, char **argv)
             {
                 hfile = malloc(sizeof(*hfile));
                 if(!hfile)
-                    return(-1);
+                {
+                    ret = -1;
+                    goto cleanup;
+                }
 
                 /* init */
                 memset(hfile, 0, sizeof(*hfile));
@@ -474,16 +437,24 @@ int main(int argc, char **argv)
 
             if(i == DARSHAN_POSIX_MOD)
             {
-                posix_accum_file((struct darshan_posix_file*)rec_p, &total, job.nprocs);
-                posix_accum_file((struct darshan_posix_file*)rec_p, hfile, job.nprocs);
-                posix_accum_perf((struct darshan_posix_file*)rec_p, &pdata);
+                posix_accum_file((struct darshan_posix_file*)mod_buf, &total, job.nprocs);
+                posix_accum_file((struct darshan_posix_file*)mod_buf, hfile, job.nprocs);
+                posix_accum_perf((struct darshan_posix_file*)mod_buf, &pdata);
             }
             else if(i == DARSHAN_MPIIO_MOD)
             {
-                mpiio_accum_file((struct darshan_mpiio_file*)rec_p, &total, job.nprocs);
-                mpiio_accum_file((struct darshan_mpiio_file*)rec_p, hfile, job.nprocs);
-                mpiio_accum_perf((struct darshan_mpiio_file*)rec_p, &pdata);
+                mpiio_accum_file((struct darshan_mpiio_file*)mod_buf, &total, job.nprocs);
+                mpiio_accum_file((struct darshan_mpiio_file*)mod_buf, hfile, job.nprocs);
+                mpiio_accum_perf((struct darshan_mpiio_file*)mod_buf, &pdata);
             }
+
+            memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
+
+        } while((ret = mod_logutils[i]->log_get_record(fd, mod_buf, &rec_id)) == 1);
+        if (ret < 0)
+        {
+            ret = -1;
+            goto cleanup;
         }
 
         /* we calculate more detailed stats for POSIX and MPI-IO modules, 
@@ -617,10 +588,10 @@ int main(int argc, char **argv)
     }
     if(empty_mods == DARSHAN_MAX_MODS)
         printf("\n# no module data available.\n");
+    ret = 0;
 
+cleanup:
     darshan_log_close(fd);
-
-    free(mod_buf);
     free(pdata.rank_cumul_io_time);
     free(pdata.rank_cumul_md_time);
 
@@ -644,7 +615,7 @@ int main(int argc, char **argv)
         free(fs_types);
     }
 
-    return(0);
+    return(ret);
 }
 
 void posix_accum_file(struct darshan_posix_file *pfile,
diff --git a/darshan-util/darshan-pnetcdf-logutils.c b/darshan-util/darshan-pnetcdf-logutils.c
index d37d21f..fb71673 100644
--- a/darshan-util/darshan-pnetcdf-logutils.c
+++ b/darshan-util/darshan-pnetcdf-logutils.c
@@ -30,43 +30,60 @@ char *pnetcdf_f_counter_names[] = {
 };
 #undef X
 
-static int darshan_log_get_pnetcdf_file(void** pnetcdf_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag);
+static int darshan_log_get_pnetcdf_file(darshan_fd fd, void* pnetcdf_buf,
+    darshan_record_id* rec_id);
+static int darshan_log_put_pnetcdf_file(darshan_fd fd, void* pnetcdf_buf);
 static void darshan_log_print_pnetcdf_file(void *file_rec,
     char *file_name, char *mnt_pt, char *fs_type);
 
 struct darshan_mod_logutil_funcs pnetcdf_logutils =
 {
     .log_get_record = &darshan_log_get_pnetcdf_file,
+    .log_put_record = &darshan_log_put_pnetcdf_file,
     .log_print_record = &darshan_log_print_pnetcdf_file,
 };
 
-static int darshan_log_get_pnetcdf_file(void** pnetcdf_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag)
+static int darshan_log_get_pnetcdf_file(darshan_fd fd, void* pnetcdf_buf,
+    darshan_record_id* rec_id)
 {
+    struct darshan_pnetcdf_file *file;
     int i;
-    struct darshan_pnetcdf_file *file = (struct darshan_pnetcdf_file *)
-        (*pnetcdf_buf_p);
+    int ret;
 
-    if(*bytes_left < sizeof(struct darshan_pnetcdf_file))
+    ret = darshan_log_getmod(fd, DARSHAN_PNETCDF_MOD, pnetcdf_buf,
+        sizeof(struct darshan_pnetcdf_file));
+    if(ret < 0)
         return(-1);
-
-    if(byte_swap_flag)
+    else if(ret < sizeof(struct darshan_pnetcdf_file))
+        return(0);
+    else
     {
-        /* swap bytes if necessary */
-        DARSHAN_BSWAP64(&file->f_id);
-        DARSHAN_BSWAP64(&file->rank);
-        for(i=0; i<PNETCDF_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->counters[i]);
-        for(i=0; i<PNETCDF_F_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->fcounters[i]);
+        file = (struct darshan_pnetcdf_file *)pnetcdf_buf;
+        if(fd->swap_flag)
+        {
+            /* swap bytes if necessary */
+            DARSHAN_BSWAP64(&file->f_id);
+            DARSHAN_BSWAP64(&file->rank);
+            for(i=0; i<PNETCDF_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&file->counters[i]);
+            for(i=0; i<PNETCDF_F_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&file->fcounters[i]);
+        }
+
+        *rec_id = file->f_id;
+        return(1);
     }
+}
 
-    /* update/set output variables */
-    *file_rec = (void *)file;
-    *rec_id = file->f_id;
-    *pnetcdf_buf_p = (file + 1); /* increment input buf by size of file record */
-    *bytes_left -= sizeof(struct darshan_pnetcdf_file);
+static int darshan_log_put_pnetcdf_file(darshan_fd fd, void* pnetcdf_buf)
+{
+    struct darshan_pnetcdf_file *file = (struct darshan_pnetcdf_file *)pnetcdf_buf;
+    int ret;
+
+    ret = darshan_log_putmod(fd, DARSHAN_PNETCDF_MOD, file,
+        sizeof(struct darshan_pnetcdf_file));
+    if(ret < 0)
+        return(-1);
 
     return(0);
 }
diff --git a/darshan-util/darshan-posix-logutils.c b/darshan-util/darshan-posix-logutils.c
index 5a02610..e739534 100644
--- a/darshan-util/darshan-posix-logutils.c
+++ b/darshan-util/darshan-posix-logutils.c
@@ -30,43 +30,60 @@ char *posix_f_counter_names[] = {
 };
 #undef X
 
-static int darshan_log_get_posix_file(void** psx_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag);
+static int darshan_log_get_posix_file(darshan_fd fd, void* posix_buf,
+    darshan_record_id* rec_id);
+static int darshan_log_put_posix_file(darshan_fd fd, void* posix_buf);
 static void darshan_log_print_posix_file(void *file_rec,
     char *file_name, char *mnt_pt, char *fs_type);
 
 struct darshan_mod_logutil_funcs posix_logutils =
 {
     .log_get_record = &darshan_log_get_posix_file,
+    .log_put_record = &darshan_log_put_posix_file,
     .log_print_record = &darshan_log_print_posix_file,
 };
 
-static int darshan_log_get_posix_file(void** psx_buf_p, int* bytes_left,
-    void** file_rec, darshan_record_id* rec_id, int byte_swap_flag)
+static int darshan_log_get_posix_file(darshan_fd fd, void* posix_buf, 
+    darshan_record_id* rec_id)
 {
+    struct darshan_posix_file *file;
     int i;
-    struct darshan_posix_file *file = (struct darshan_posix_file *)
-        (*psx_buf_p);
+    int ret;
 
-    if(*bytes_left < sizeof(struct darshan_posix_file))
+    ret = darshan_log_getmod(fd, DARSHAN_POSIX_MOD, posix_buf,
+        sizeof(struct darshan_posix_file));
+    if(ret < 0)
         return(-1);
-
-    if(byte_swap_flag)
+    else if(ret < sizeof(struct darshan_posix_file))
+        return(0);
+    else
     {
-        /* swap bytes if necessary */
-        DARSHAN_BSWAP64(&file->f_id);
-        DARSHAN_BSWAP64(&file->rank);
-        for(i=0; i<POSIX_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->counters[i]);
-        for(i=0; i<POSIX_F_NUM_INDICES; i++)
-            DARSHAN_BSWAP64(&file->fcounters[i]);
+        file = (struct darshan_posix_file *)posix_buf;
+        if(fd->swap_flag)
+        {
+            /* swap bytes if necessary */
+            DARSHAN_BSWAP64(&file->f_id);
+            DARSHAN_BSWAP64(&file->rank);
+            for(i=0; i<POSIX_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&file->counters[i]);
+            for(i=0; i<POSIX_F_NUM_INDICES; i++)
+                DARSHAN_BSWAP64(&file->fcounters[i]);
+        }
+
+        *rec_id = file->f_id;
+        return(1);
     }
+}
 
-    /* update/set output variables */
-    *file_rec = (void *)file;
-    *rec_id = file->f_id;
-    *psx_buf_p = (file + 1); /* increment input buf by size of file record */
-    *bytes_left -= sizeof(struct darshan_posix_file);
+static int darshan_log_put_posix_file(darshan_fd fd, void* posix_buf)
+{
+    struct darshan_posix_file *file = (struct darshan_posix_file *)posix_buf;
+    int ret;
+
+    ret = darshan_log_putmod(fd, DARSHAN_POSIX_MOD, file,
+        sizeof(struct darshan_posix_file));
+    if(ret < 0)
+        return(-1);
 
     return(0);
 }


hooks/post-receive
--



More information about the Darshan-commits mailing list