udevtrigger: simplify scan_class function
authorGabor Juhos <juhosg@openwrt.org>
Wed, 11 Sep 2013 14:10:17 +0000 (16:10 +0200)
committerJohn Crispin <blogic@openwrt.org>
Fri, 13 Sep 2013 15:36:59 +0000 (17:36 +0200)
Remove the local directory scanning code and
use the scan_subdir function instead.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
udevtrigger.c

index 423df6a4b94df3a1fa982a59f60ae2a54b8f6cec..2fb0e68dab62d1239210b6428c466b666110de5c 100644 (file)
@@ -239,29 +239,10 @@ static void scan_block(void)
 static void scan_class(void)
 {
        char base[PATH_SIZE];
-       DIR *dir;
-       struct dirent *dent;
 
        strlcpy(base, "/sys/class", sizeof(base));
 
-       dir = opendir(base);
-       if (dir == NULL)
-               return;
-
-       for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
-               char dirname[PATH_SIZE];
-
-               if (dent->d_name[0] == '.')
-                       continue;
-
-               strlcpy(dirname, base, sizeof(dirname));
-               strlcat(dirname, "/", sizeof(dirname));
-               strlcat(dirname, dent->d_name, sizeof(dirname));
-
-               scan_subdir(dirname, NULL, true, 0);
-       }
-
-       closedir(dir);
+       scan_subdir("/sys/class", NULL, false, 1);
 }
 
 int main(int argc, char *argv[], char *envp[])