Linux sysfs change broke fio disk lookup
/sys/block/<dev> is now a sym link to the real path, which
broke our disk lookup. Fix it.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/diskutil.c b/diskutil.c
index a38f4fa..9fb31bf 100644
--- a/diskutil.c
+++ b/diskutil.c
@@ -170,7 +170,7 @@
return 1;
}
-static int find_block_dir(int majdev, int mindev, char *path)
+static int find_block_dir(int majdev, int mindev, char *path, int link_ok)
{
struct dirent *dir;
struct stat st;
@@ -196,15 +196,22 @@
}
}
- if (lstat(full_path, &st) == -1) {
- perror("stat");
- break;
+ if (link_ok) {
+ if (stat(full_path, &st) == -1) {
+ perror("stat");
+ break;
+ }
+ } else {
+ if (lstat(full_path, &st) == -1) {
+ perror("stat");
+ break;
+ }
}
if (!S_ISDIR(st.st_mode) || S_ISLNK(st.st_mode))
continue;
- found = find_block_dir(majdev, mindev, full_path);
+ found = find_block_dir(majdev, mindev, full_path, 0);
if (found) {
strcpy(path, full_path);
break;
@@ -277,7 +284,7 @@
last_majdev = majdev;
sprintf(foo, "/sys/block");
- if (!find_block_dir(majdev, mindev, foo))
+ if (!find_block_dir(majdev, mindev, foo, 1))
return;
/*