Commit 6faec77b authored by Philip Carns's avatar Philip Carns

track working directory


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@608 3b7491f3-a168-0410-bf4b-c445ed680a29
parent c506372d
......@@ -19,6 +19,7 @@
#include <search.h>
#include <assert.h>
#include <libgen.h>
#include <limits.h>
#define __USE_GNU
#include <pthread.h>
......@@ -100,6 +101,7 @@ DARSHAN_FORWARD_DECL(fwrite, size_t, (const void *ptr, size_t size, size_t nmemb
DARSHAN_FORWARD_DECL(fseek, int, (FILE *stream, long offset, int whence));
DARSHAN_FORWARD_DECL(fsync, int, (int fd));
DARSHAN_FORWARD_DECL(fdatasync, int, (int fd));
DARSHAN_FORWARD_DECL(chdir, int, (const char* path));
pthread_mutex_t cp_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
struct darshan_job_runtime* darshan_global_job = NULL;
......@@ -122,6 +124,8 @@ static char* exclusions[] = {
NULL
};
static char working_dir[PATH_MAX] = {0};
static double posix_wtime(void);
static void cp_access_counter(struct darshan_file_runtime* file, ssize_t size, enum cp_counter_type type);
......@@ -577,6 +581,21 @@ int DARSHAN_DECL(open)(const char *path, int flags, ...)
return(ret);
}
int DARSHAN_DECL(chdir)(const char *path)
{
int ret;
MAP_OR_FAIL(chdir);
ret = __real_chdir(path);
if(ret == 0)
{
strncpy(working_dir, path, PATH_MAX-1);
}
return(ret);
}
FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode)
{
FILE* ret;
......@@ -1083,6 +1102,13 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank)
/* turn off tracing */
return;
}
/* find current working directory */
if(getcwd(working_dir, PATH_MAX) == NULL)
{
/* turn off tracing if we can't find working dir */
return;
}
disable_timing = getenv("DARSHAN_DISABLE_TIMING");
......@@ -1115,6 +1141,7 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank)
darshan_mem_alignment = 1;
}
/* allocate structure to track darshan_global_job information */
darshan_global_job = malloc(sizeof(*darshan_global_job));
if(!darshan_global_job)
......
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