On 03/12/2014 01:24 PM, Bruce Cran wrote:
There's already code to use the environment variables TMP or TEMP, except it appends "tmp" to whatever it gets.
Yes, my point was to use it. Something like the attached. -- Jens Axboe
diff --git a/os/os-windows.h b/os/os-windows.h index 49f96068ff32..499e098f8b82 100644 --- a/os/os-windows.h +++ b/os/os-windows.h @@ -167,6 +167,8 @@ static inline void os_get_tmpdir(char *path, int len) GetTempPath(len, path); } +#define FIO_HAVE_OS_GET_TMPDIR + static inline int gettid(void) { return GetCurrentThreadId(); diff --git a/stat.c b/stat.c index e43db8f9d075..df3bd93d32e5 100644 --- a/stat.c +++ b/stat.c @@ -13,6 +13,7 @@ #include "json.h" #include "lib/getrusage.h" #include "idletime.h" +#include "os/os.h" static struct fio_mutex *stat_mutex; @@ -1480,7 +1481,7 @@ void show_running_run_stats(void) static int status_interval_init; static struct timeval status_time; -#define FIO_STATUS_FILE "/tmp/fio-dump-status" +#define FIO_STATUS_FILE "fio-dump-status" static int check_status_file(void) { @@ -1491,10 +1492,22 @@ static int check_status_file(void) temp_dir = getenv("TMPDIR"); if (temp_dir == NULL) temp_dir = getenv("TEMP"); - if (temp_dir == NULL) + if (temp_dir == NULL) { +#ifdef FIO_HAVE_OS_GET_TMPDIR + temp_dir = NULL; + os_get_tmpdir(status_file_path, sizeof(status_file_path)); +#else temp_dir = "/tmp"; +#endif + } - snprintf(fio_status_file_path, sizeof(fio_status_file_path), "%s/%s", temp_dir, FIO_STATUS_FILE); + if (temp_dir) + snprintf(fio_status_file_path, sizeof(fio_status_file_path), "%s/%s", temp_dir, FIO_STATUS_FILE); + else { + size_t len = strlen(fio_status_file_path); + + snprintf(fio_status_file_path + len, sizeof(fio_status_file_path) - len, "%s", FIO_STATUS_FILE); + } if (stat(fio_status_file_path, &sb)) return 0;