summaryrefslogtreecommitdiff
path: root/fio.c
diff options
context:
space:
mode:
Diffstat (limited to 'fio.c')
-rw-r--r--fio.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/fio.c b/fio.c
index 7d186b0..11a0668 100644
--- a/fio.c
+++ b/fio.c
@@ -1370,16 +1370,16 @@ static int check_dev_match(dev_t dev, char *path)
return 1;
}
-static char *find_block_dir(dev_t dev, char *path)
+static int find_block_dir(dev_t dev, char *path)
{
struct dirent *dir;
- char *found = NULL;
struct stat st;
+ int found = 0;
DIR *D;
D = opendir(path);
if (!D)
- return NULL;
+ return 0;
while ((dir = readdir(D)) != NULL) {
char full_path[256];
@@ -1393,7 +1393,7 @@ static char *find_block_dir(dev_t dev, char *path)
if (!strcmp(dir->d_name, "dev")) {
if (!check_dev_match(dev, full_path)) {
- found = path;
+ found = 1;
break;
}
}
@@ -1406,8 +1406,11 @@ static char *find_block_dir(dev_t dev, char *path)
if (!S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode))
continue;
- if ((found = find_block_dir(dev, full_path)) != NULL)
+ found = find_block_dir(dev, full_path);
+ if (found) {
+ strcpy(path, full_path);
break;
+ }
}
closedir(D);
@@ -1515,7 +1518,7 @@ static void init_disk_util(struct thread_data *td)
struct stat st;
char foo[256], tmp[256];
dev_t dev;
- char *p, *dir;
+ char *p;
if (!td->do_disk_util)
return;
@@ -1543,16 +1546,15 @@ static void init_disk_util(struct thread_data *td)
return;
sprintf(foo, "/sys/block");
- dir = find_block_dir(dev, foo);
- if (!dir)
+ if (!find_block_dir(dev, foo))
return;
/*
* if this is inside a partition dir, jump back to parent
*/
- sprintf(tmp, "%s/queue", dir);
+ sprintf(tmp, "%s/queue", foo);
if (stat(tmp, &st)) {
- p = dirname(dir);
+ p = dirname(foo);
sprintf(tmp, "%s/queue", p);
if (stat(tmp, &st)) {
fprintf(stderr, "unknown sysfs layout\n");