From ac0be2acff3864979e5e260d332d25ca90e22417 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 6 Jun 2008 12:08:04 +0200 Subject: [PATCH] Linux sysfs change broke fio disk lookup /sys/block/ is now a sym link to the real path, which broke our disk lookup. Fix it. Signed-off-by: Jens Axboe --- diskutil.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/diskutil.c b/diskutil.c index a38f4fa3..9fb31bf2 100644 --- a/diskutil.c +++ b/diskutil.c @@ -170,7 +170,7 @@ static int check_dev_match(int majdev, int mindev, char *path) 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 @@ static int find_block_dir(int majdev, int mindev, char *path) } } - 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 @@ static void __init_disk_util(struct thread_data *td, struct fio_file *f) last_majdev = majdev; sprintf(foo, "/sys/block"); - if (!find_block_dir(majdev, mindev, foo)) + if (!find_block_dir(majdev, mindev, foo, 1)) return; /* -- 2.25.1