From: Lukas Straub Date: Wed, 19 Jan 2022 21:14:26 +0000 (+0000) Subject: linux-dev-lookup.c: Put the check for replay_redirect in the beginning X-Git-Tag: fio-3.30~90 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=d9d60dbf49bfa62b5bd26f078533088f1de17b6f linux-dev-lookup.c: Put the check for replay_redirect in the beginning The machine may not have any block device nodes (like my dev container) which makes this function fail despite replay_redirect being set. Move the check to the beginning to fix this. Signed-off-by: Lukas Straub Link: https://lore.kernel.org/r/0dd4b6407f7b7f5f15f1fcad409554ff339ffca1.1642626314.git.lukasstraub2@web.de Signed-off-by: Jens Axboe --- diff --git a/oslib/linux-dev-lookup.c b/oslib/linux-dev-lookup.c index 1dda93f2..4335faf9 100644 --- a/oslib/linux-dev-lookup.c +++ b/oslib/linux-dev-lookup.c @@ -16,6 +16,16 @@ int blktrace_lookup_device(const char *redirect, char *path, unsigned int maj, int found = 0; DIR *D; + /* + * If replay_redirect is set then always return this device + * upon lookup which overrides the device lookup based on + * major minor in the actual blktrace + */ + if (redirect) { + strcpy(path, redirect); + return 1; + } + D = opendir(path); if (!D) return 0; @@ -44,17 +54,6 @@ int blktrace_lookup_device(const char *redirect, char *path, unsigned int maj, if (!S_ISBLK(st.st_mode)) continue; - /* - * If replay_redirect is set then always return this device - * upon lookup which overrides the device lookup based on - * major minor in the actual blktrace - */ - if (redirect) { - strcpy(path, redirect); - found = 1; - break; - } - if (maj == major(st.st_rdev) && min == minor(st.st_rdev)) { strcpy(path, full_path); found = 1;