[PATCH] Fixup stat queue file read
authorJens Axboe <axboe@suse.de>
Wed, 31 May 2006 18:43:01 +0000 (20:43 +0200)
committerJens Axboe <axboe@suse.de>
Wed, 31 May 2006 18:43:01 +0000 (20:43 +0200)
Apparently a stat file got added to the partition directory as
well, which broke the lookup.

fio.c

diff --git a/fio.c b/fio.c
index e48a060e9bd2dc1a201742bbdf41b98efc518f25..df284581e0434f3e9eaeac327ee7952c88374000 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1739,23 +1739,19 @@ static void init_disk_util(struct thread_data *td)
                return;
 
        /*
-        * for md/dm, there's no queue dir. we already have the right place
+        * If there's a ../queue/ directory there, we are inside a partition.
+        * Check if that is the case and jump back. For loop/md/dm etc we
+        * are already in the right spot.
         */
-       sprintf(tmp, "%s/stat", foo);
-       if (stat(tmp, &st)) {
-               /*
-                * if this is inside a partition dir, jump back to parent
-                */
-               sprintf(tmp, "%s/queue", foo);
+       sprintf(tmp, "%s/../queue", foo);
+       if (!stat(tmp, &st)) {
+               p = dirname(foo);
+               sprintf(tmp, "%s/queue", p);
                if (stat(tmp, &st)) {
-                       p = dirname(foo);
-                       sprintf(tmp, "%s/queue", p);
-                       if (stat(tmp, &st)) {
-                               fprintf(stderr, "unknown sysfs layout\n");
-                               return;
-                       }
-                       sprintf(foo, "%s", p);
+                       fprintf(stderr, "unknown sysfs layout\n");
+                       return;
                }
+               sprintf(foo, "%s", p);
        }
 
        disk_util_add(dev, foo);