From: Bruce Cran Date: Sun, 28 Apr 2013 15:34:15 +0000 (+0200) Subject: Add support for dumping the status on Windows. X-Git-Tag: fio-2.1~5 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=a0bafb7d88c33b9046073e0bc4af7d64d0caa30b Add support for dumping the status on Windows. Windows uses a per-user temporary directory, with the path stored in the TEMP environment variable. Update check_status_file to check both the Unix TMPDIR and Windows TEMP variables before falling back to /tmp. Signed-off-by: Jens Axboe --- diff --git a/stat.c b/stat.c index b3861887..332ccd0f 100644 --- a/stat.c +++ b/stat.c @@ -1445,11 +1445,21 @@ static struct timeval status_time; static int check_status_file(void) { struct stat sb; + const char *temp_dir; + char fio_status_file_path[PATH_MAX]; - if (stat(FIO_STATUS_FILE, &sb)) + temp_dir = getenv("TMPDIR"); + if (temp_dir == NULL) + temp_dir = getenv("TEMP"); + if (temp_dir == NULL) + temp_dir = "/tmp"; + + snprintf(fio_status_file_path, sizeof(fio_status_file_path), "%s/%s", temp_dir, FIO_STATUS_FILE); + + if (stat(fio_status_file_path, &sb)) return 0; - unlink(FIO_STATUS_FILE); + unlink(fio_status_file_path); return 1; }