Commit 6e75dade authored by Glenn K. Lockwood's avatar Glenn K. Lockwood

Merge branch 'master' into gkl/obfuscate-fs-fix to pull in fix from d4dc84f4

parents 0d1f6e80 173d3d49
......@@ -126,7 +126,11 @@ char* darshan_clean_file_path(const char* path)
char* cwd = NULL;
char* filter = NULL;
if(!path || strlen(path) < 1)
/* NOTE: the last check in this if statement is for path strings that
* begin with the '<' character. We assume that these are special
* reserved paths used by Darshan, like <STDIN>.
*/
if(!path || strlen(path) < 1 || path[0] == '<')
return(NULL);
if(path[0] == '/')
......
......@@ -94,7 +94,9 @@ DARSHAN_FORWARD_DECL(fputc, int, (int c, FILE *stream));
DARSHAN_FORWARD_DECL(putw, int, (int w, FILE *stream));
DARSHAN_FORWARD_DECL(fputs, int, (const char *s, FILE *stream));
DARSHAN_FORWARD_DECL(fprintf, int, (FILE *stream, const char *format, ...));
DARSHAN_FORWARD_DECL(printf, int, (const char *format, ...));
DARSHAN_FORWARD_DECL(vfprintf, int, (FILE *stream, const char *format, va_list));
DARSHAN_FORWARD_DECL(vprintf, int, (const char *format, va_list));
DARSHAN_FORWARD_DECL(fread, size_t, (void *ptr, size_t size, size_t nmemb, FILE *stream));
DARSHAN_FORWARD_DECL(fgetc, int, (FILE *stream));
DARSHAN_FORWARD_DECL(getw, int, (FILE *stream));
......@@ -463,6 +465,25 @@ int DARSHAN_DECL(fputs)(const char *s, FILE *stream)
return(ret);
}
int DARSHAN_DECL(vprintf)(const char *format, va_list ap)
{
int ret;
double tm1, tm2;
MAP_OR_FAIL(vprintf);
tm1 = darshan_core_wtime();
ret = __real_vprintf(format, ap);
tm2 = darshan_core_wtime();
STDIO_PRE_RECORD();
if(ret > 0)
STDIO_RECORD_WRITE(stdout, ret, tm1, tm2, 0);
STDIO_POST_RECORD();
return(ret);
}
int DARSHAN_DECL(vfprintf)(FILE *stream, const char *format, va_list ap)
{
int ret;
......@@ -472,14 +493,38 @@ int DARSHAN_DECL(vfprintf)(FILE *stream, const char *format, va_list ap)
MAP_OR_FAIL(vfprintf);
tm1 = darshan_core_wtime();
start_off = ftell(stream);
ret = __real_vfprintf(stream, format, ap);
end_off = ftell(stream);
tm2 = darshan_core_wtime();
STDIO_PRE_RECORD();
if(ret > 0)
STDIO_RECORD_WRITE(stream, (end_off-start_off), tm1, tm2, 0);
STDIO_RECORD_WRITE(stream, ret, tm1, tm2, 0);
STDIO_POST_RECORD();
return(ret);
}
int DARSHAN_DECL(printf)(const char *format, ...)
{
int ret;
double tm1, tm2;
va_list ap;
MAP_OR_FAIL(vprintf);
tm1 = darshan_core_wtime();
/* NOTE: we intentionally switch to vprintf here to handle the variable
* length arguments.
*/
va_start(ap, format);
ret = __real_vprintf(format, ap);
va_end(ap);
tm2 = darshan_core_wtime();
STDIO_PRE_RECORD();
if(ret > 0)
STDIO_RECORD_WRITE(stdout, ret, tm1, tm2, 0);
STDIO_POST_RECORD();
return(ret);
......@@ -491,7 +536,6 @@ int DARSHAN_DECL(fprintf)(FILE *stream, const char *format, ...)
int ret;
double tm1, tm2;
va_list ap;
long start_off, end_off;
MAP_OR_FAIL(vfprintf);
......@@ -499,16 +543,14 @@ int DARSHAN_DECL(fprintf)(FILE *stream, const char *format, ...)
/* NOTE: we intentionally switch to vfprintf here to handle the variable
* length arguments.
*/
start_off = ftell(stream);
va_start(ap, format);
ret = __real_vfprintf(stream, format, ap);
va_end(ap);
end_off = ftell(stream);
tm2 = darshan_core_wtime();
STDIO_PRE_RECORD();
if(ret > 0)
STDIO_RECORD_WRITE(stream, (end_off-start_off), tm1, tm2, 0);
STDIO_RECORD_WRITE(stream, ret, tm1, tm2, 0);
STDIO_POST_RECORD();
return(ret);
......@@ -939,6 +981,11 @@ static void stdio_runtime_initialize()
return;
}
memset(stdio_runtime, 0, sizeof(*stdio_runtime));
/* instantiate records for stdin, stdout, and stderr */
STDIO_RECORD_OPEN(stdin, "<STDIN>", 0, 0);
STDIO_RECORD_OPEN(stdout, "<STDOUT>", 0, 0);
STDIO_RECORD_OPEN(stderr, "<STDERR>", 0, 0);
}
/************************************************************************
......
......@@ -20,6 +20,7 @@
--wrap=fseeko64
--wrap=fprintf
--wrap=vfprintf
--wrap=vprintf
--wrap=fputc
--wrap=fputs
--wrap=putw
......@@ -27,3 +28,4 @@
--wrap=fsetpos64
--wrap=rewind
--wrap=__isoc99_fscanf
--wrap=printf
......@@ -120,7 +120,7 @@ static int darshan_log_put_bgq_rec(darshan_fd fd, void* bgq_buf, int ver)
int ret;
ret = darshan_log_put_mod(fd, DARSHAN_BGQ_MOD, rec,
sizeof(struct darshan_bgq_record), ver);
sizeof(struct darshan_bgq_record), DARSHAN_BGQ_VER);
if(ret < 0)
return(-1);
......
......@@ -85,7 +85,7 @@ static int darshan_log_put_hdf5_file(darshan_fd fd, void* hdf5_buf, int ver)
int ret;
ret = darshan_log_put_mod(fd, DARSHAN_HDF5_MOD, file,
sizeof(struct darshan_hdf5_file), ver);
sizeof(struct darshan_hdf5_file), DARSHAN_HDF5_VER);
if(ret < 0)
return(-1);
......
......@@ -593,15 +593,15 @@ int darshan_log_put_namehash(darshan_fd fd, struct darshan_name_record_ref *hash
assert(state);
/* allocate memory for largest possible hash record */
name_rec = malloc(sizeof(struct darshan_name_record) + PATH_MAX);
name_rec = malloc(sizeof(darshan_record_id) + PATH_MAX + 1);
if(!name_rec)
return(-1);
memset(name_rec, 0, sizeof(struct darshan_name_record) + PATH_MAX);
memset(name_rec, 0, sizeof(darshan_record_id) + PATH_MAX + 1);
/* individually serialize each hash record and write to log file */
HASH_ITER(hlink, hash, ref, tmp)
{
name_rec_len = sizeof(struct darshan_name_record) + strlen(ref->name_record->name);
name_rec_len = sizeof(darshan_record_id) + strlen(ref->name_record->name) + 1;
memcpy(name_rec, ref->name_record, name_rec_len);
/* write this hash entry to log file */
......
......@@ -94,7 +94,7 @@ static int darshan_log_put_lustre_record(darshan_fd fd, void* lustre_buf, int ve
int ret;
ret = darshan_log_put_mod(fd, DARSHAN_LUSTRE_MOD, rec,
LUSTRE_RECORD_SIZE(rec->counters[LUSTRE_STRIPE_WIDTH]), ver);
LUSTRE_RECORD_SIZE(rec->counters[LUSTRE_STRIPE_WIDTH]), DARSHAN_LUSTRE_VER);
if(ret < 0)
return(-1);
......
......@@ -85,7 +85,7 @@ static int darshan_log_put_mpiio_file(darshan_fd fd, void* mpiio_buf, int ver)
int ret;
ret = darshan_log_put_mod(fd, DARSHAN_MPIIO_MOD, file,
sizeof(struct darshan_mpiio_file), ver);
sizeof(struct darshan_mpiio_file), DARSHAN_MPIIO_VER);
if(ret < 0)
return(-1);
......
......@@ -102,7 +102,7 @@ static int darshan_log_put_null_record(darshan_fd fd, void* null_buf, int ver)
/* append NULL record to darshan log file */
ret = darshan_log_put_mod(fd, DARSHAN_NULL_MOD, rec,
sizeof(struct darshan_null_record), ver);
sizeof(struct darshan_null_record), DARSHAN_NULL_VER);
if(ret < 0)
return(-1);
......
......@@ -85,7 +85,7 @@ static int darshan_log_put_pnetcdf_file(darshan_fd fd, void* pnetcdf_buf, int ve
int ret;
ret = darshan_log_put_mod(fd, DARSHAN_PNETCDF_MOD, file,
sizeof(struct darshan_pnetcdf_file), ver);
sizeof(struct darshan_pnetcdf_file), DARSHAN_PNETCDF_VER);
if(ret < 0)
return(-1);
......
......@@ -120,7 +120,7 @@ static int darshan_log_put_posix_file(darshan_fd fd, void* posix_buf, int ver)
int ret;
ret = darshan_log_put_mod(fd, DARSHAN_POSIX_MOD, file,
sizeof(struct darshan_posix_file), ver);
sizeof(struct darshan_posix_file), DARSHAN_POSIX_VER);
if(ret < 0)
return(-1);
......
......@@ -99,7 +99,7 @@ static int darshan_log_put_stdio_record(darshan_fd fd, void* stdio_buf, int ver)
/* append STDIO record to darshan log file */
ret = darshan_log_put_mod(fd, DARSHAN_STDIO_MOD, rec,
sizeof(struct darshan_stdio_file), ver);
sizeof(struct darshan_stdio_file), DARSHAN_STDIO_VER);
if(ret < 0)
return(-1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment