Add OS_PATH_SEPARATOR for platforms which have different path separator characters (e.g. Windows and 'classic' MacOS).
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/blktrace.c b/blktrace.c
index 297a8a9..1b9bf3b 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -115,7 +115,7 @@
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
- sprintf(full_path, "%s/%s", path, dir->d_name);
+ sprintf(full_path, "%s%s%s", path, FIO_OS_PATH_SEPARATOR, dir->d_name);
if (lstat(full_path, &st) == -1) {
perror("lstat");
break;
diff --git a/cgroup.c b/cgroup.c
index de00d98..ea6bbd6 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -86,9 +86,9 @@
char *str = malloc(64);
if (td->o.cgroup)
- sprintf(str, "%s/%s", mnt, td->o.cgroup);
+ sprintf(str, "%s%s%s", mnt, FIO_OS_PATH_SEPARATOR, td->o.cgroup);
else
- sprintf(str, "%s/%s", mnt, td->o.name);
+ sprintf(str, "%s%s%s", mnt, FIO_OS_PATH_SEPARATOR, td->o.name);
return str;
}
@@ -99,8 +99,8 @@
{
char tmp[256];
FILE *f;
-
- sprintf(tmp, "%s/%s", path, filename);
+
+ sprintf(tmp, "%s%s%s", path, FIO_OS_PATH_SEPARATOR, filename);
f = fopen(tmp, "w");
if (!f) {
td_verror(td, errno, onerr);
diff --git a/diskutil.c b/diskutil.c
index e4b4b8a..47d739b 100644
--- a/diskutil.c
+++ b/diskutil.c
@@ -215,7 +215,7 @@
!strcmp(dirent->d_name, ".."))
continue;
- sprintf(temppath, "%s/%s", slavesdir, dirent->d_name);
+ sprintf(temppath, "%s%s%s", slavesdir, FIO_OS_PATH_SEPARATOR, dirent->d_name);
/* Can we always assume that the slaves device entries
* are links to the real directories for the slave
* devices?
@@ -240,7 +240,7 @@
if (slavedu)
continue;
- sprintf(temppath, "%s/%s", slavesdir, slavepath);
+ sprintf(temppath, "%s%s%s", slavesdir, FIO_OS_PATH_SEPARATOR, slavepath);
__init_per_file_disk_util(td, majdev, mindev, temppath);
slavedu = disk_util_exists(majdev, mindev);
@@ -327,7 +327,7 @@
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
- sprintf(full_path, "%s/%s", path, dir->d_name);
+ sprintf(full_path, "%s%s%s", path, FIO_OS_PATH_SEPARATOR, dir->d_name);
if (!strcmp(dir->d_name, "dev")) {
if (!check_dev_match(majdev, mindev, full_path)) {
diff --git a/filesetup.c b/filesetup.c
index d55af45..cf5ec8e 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -1138,7 +1138,7 @@
if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
continue;
- sprintf(full_path, "%s/%s", dirname, dir->d_name);
+ sprintf(full_path, "%s%s%s", dirname, FIO_OS_PATH_SEPARATOR, dir->d_name);
if (lstat(full_path, &sb) == -1) {
if (errno != ENOENT) {
diff --git a/os/os.h b/os/os.h
index d6ce9a7..cbb476f 100644
--- a/os/os.h
+++ b/os/os.h
@@ -125,6 +125,10 @@
#define FIO_PREFERRED_ENGINE "sync"
#endif
+#ifndef FIO_OS_PATH_SEPARATOR
+#define FIO_OS_PATH_SEPARATOR "/"
+#endif
+
#ifndef FIO_MAX_JOBS
#define FIO_MAX_JOBS 2048
#endif