Add OS_PATH_SEPARATOR for platforms which have different path separator characters...
authorBruce Cran <bruce@cran.org.uk>
Mon, 20 Feb 2012 17:01:46 +0000 (17:01 +0000)
committerJens Axboe <axboe@kernel.dk>
Mon, 20 Feb 2012 18:33:04 +0000 (19:33 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
blktrace.c
cgroup.c
diskutil.c
filesetup.c
os/os.h

index 297a8a947af254200aed536788b095811a0d34ac..1b9bf3b8452c51a40612917179d00977dc231513 100644 (file)
@@ -115,7 +115,7 @@ static int lookup_device(struct thread_data *td, char *path, unsigned int maj,
                if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
                        continue;
 
                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;
                if (lstat(full_path, &st) == -1) {
                        perror("lstat");
                        break;
index de00d986eb05246b25e853c3af524149f1b53e22..ea6bbd69168d7578fcf5836f8d9267f05bc15448 100644 (file)
--- a/cgroup.c
+++ b/cgroup.c
@@ -86,9 +86,9 @@ static char *get_cgroup_root(struct thread_data *td, char *mnt)
        char *str = malloc(64);
 
        if (td->o.cgroup)
        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
        else
-               sprintf(str, "%s/%s", mnt, td->o.name);
+               sprintf(str, "%s%s%s", mnt, FIO_OS_PATH_SEPARATOR, td->o.name);
 
        return str;
 }
 
        return str;
 }
@@ -99,8 +99,8 @@ static int write_int_to_file(struct thread_data *td, const char *path,
 {
        char tmp[256];
        FILE *f;
 {
        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);
        f = fopen(tmp, "w");
        if (!f) {
                td_verror(td, errno, onerr);
index e4b4b8a57830f8c1661672be0fd613e1b9dd40fd..47d739bb4332b7acd7306b47f9c15c65b9a361d4 100644 (file)
@@ -215,7 +215,7 @@ static void find_add_disk_slaves(struct thread_data *td, char *path,
                    !strcmp(dirent->d_name, ".."))
                        continue;
 
                    !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?
                /* Can we always assume that the slaves device entries
                 * are links to the real directories for the slave
                 * devices?
@@ -240,7 +240,7 @@ static void find_add_disk_slaves(struct thread_data *td, char *path,
                if (slavedu)
                        continue;
 
                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);
 
                __init_per_file_disk_util(td, majdev, mindev, temppath);
                slavedu = disk_util_exists(majdev, mindev);
 
@@ -327,7 +327,7 @@ static int find_block_dir(int majdev, int mindev, char *path, int link_ok)
                if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
                        continue;
 
                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)) {
 
                if (!strcmp(dir->d_name, "dev")) {
                        if (!check_dev_match(majdev, mindev, full_path)) {
index d55af45404af36ab8d1204479d844d5525bc7adb..cf5ec8e95585ffd004c95d3ff4f2e1188aee2ec6 100644 (file)
@@ -1138,7 +1138,7 @@ static int recurse_dir(struct thread_data *td, const char *dirname)
                if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
                        continue;
 
                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) {
 
                if (lstat(full_path, &sb) == -1) {
                        if (errno != ENOENT) {
diff --git a/os/os.h b/os/os.h
index d6ce9a778acf518b6811d13e88b093204b292a9d..cbb476fe532a63375d7bcea6cc9d99f978194381 100644 (file)
--- a/os/os.h
+++ b/os/os.h
@@ -125,6 +125,10 @@ typedef unsigned long os_cpu_mask_t;
 #define FIO_PREFERRED_ENGINE   "sync"
 #endif
 
 #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
 #ifndef FIO_MAX_JOBS
 #define FIO_MAX_JOBS           2048
 #endif