diff options
Diffstat (limited to 'udevstart.c')
-rw-r--r-- | udevstart.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/udevstart.c b/udevstart.c index 1d9b60464c..2d11edeca2 100644 --- a/udevstart.c +++ b/udevstart.c @@ -87,8 +87,13 @@ static void udev_scan(void) DIR *dir; struct dirent *dent; - devpath = "block"; - dir = opendir(SYSBLOCK); + /* + * We want to scan the class tree first as lvm and dm needs to be able + * to have access to the char control device when probing the block + * devices. + */ + devpath = "class"; + dir = opendir(SYSCLASS); if (dir != NULL) { for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { char dirname[MAX_PATHLEN]; @@ -99,15 +104,12 @@ static void udev_scan(void) (strcmp(dent->d_name, "..") == 0)) continue; - snprintf(dirname, MAX_PATHLEN, "/block/%s", dent->d_name); - dirname[MAX_PATHLEN-1] = '\0'; - udev_exec(dirname, "block"); - - snprintf(dirname, MAX_PATHLEN, "%s/%s", SYSBLOCK, dent->d_name); + snprintf(dirname, MAX_PATHLEN, "%s/%s", SYSCLASS, dent->d_name); + dirname[MAX_PATHLEN] = '\0'; dir2 = opendir(dirname); if (dir2 != NULL) { for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) { - char dirname2[MAX_PATHLEN]; + char dirname2[MAX_PATHLEN-1]; DIR *dir3; struct dirent *dent3; @@ -124,10 +126,10 @@ static void udev_scan(void) char filename[MAX_PATHLEN]; if (strcmp(dent3->d_name, "dev") == 0) { - snprintf(filename, MAX_PATHLEN, "/block/%s/%s", + snprintf(filename, MAX_PATHLEN, "/class/%s/%s", dent->d_name, dent2->d_name); filename[MAX_PATHLEN-1] = '\0'; - udev_exec(filename, "block"); + udev_exec(filename, dent->d_name); } } closedir(dir3); @@ -139,8 +141,8 @@ static void udev_scan(void) closedir(dir); } - devpath = "class"; - dir = opendir(SYSCLASS); + devpath = "block"; + dir = opendir(SYSBLOCK); if (dir != NULL) { for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) { char dirname[MAX_PATHLEN]; @@ -151,12 +153,15 @@ static void udev_scan(void) (strcmp(dent->d_name, "..") == 0)) continue; - snprintf(dirname, MAX_PATHLEN, "%s/%s", SYSCLASS, dent->d_name); - dirname[MAX_PATHLEN] = '\0'; + snprintf(dirname, MAX_PATHLEN, "/block/%s", dent->d_name); + dirname[MAX_PATHLEN-1] = '\0'; + udev_exec(dirname, "block"); + + snprintf(dirname, MAX_PATHLEN, "%s/%s", SYSBLOCK, dent->d_name); dir2 = opendir(dirname); if (dir2 != NULL) { for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) { - char dirname2[MAX_PATHLEN-1]; + char dirname2[MAX_PATHLEN]; DIR *dir3; struct dirent *dent3; @@ -173,10 +178,10 @@ static void udev_scan(void) char filename[MAX_PATHLEN]; if (strcmp(dent3->d_name, "dev") == 0) { - snprintf(filename, MAX_PATHLEN, "/class/%s/%s", + snprintf(filename, MAX_PATHLEN, "/block/%s/%s", dent->d_name, dent2->d_name); filename[MAX_PATHLEN-1] = '\0'; - udev_exec(filename, dent->d_name); + udev_exec(filename, "block"); } } closedir(dir3); @@ -189,7 +194,6 @@ static void udev_scan(void) } } - int main(int argc, char *argv[], char *envp[]) { init_logging("udevstart"); |