3 #include <sys/sysmacros.h>
9 #include "linux-dev-lookup.h"
11 int blktrace_lookup_device(const char *redirect, char *path, unsigned int maj,
20 * If replay_redirect is set then always return this device
21 * upon lookup which overrides the device lookup based on
22 * major minor in the actual blktrace
25 strcpy(path, redirect);
33 while ((dir = readdir(D)) != NULL) {
36 if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, ".."))
39 sprintf(full_path, "%s/%s", path, dir->d_name);
40 if (lstat(full_path, &st) == -1) {
45 if (S_ISDIR(st.st_mode)) {
46 found = blktrace_lookup_device(redirect, full_path,
49 strcpy(path, full_path);
54 if (!S_ISBLK(st.st_mode))
57 if (maj == major(st.st_rdev) && min == minor(st.st_rdev)) {
58 strcpy(path, full_path);