diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2013-09-11 16:10:15 +0200 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2013-09-13 17:36:58 +0200 |
commit | 0a5f43565309fc6cad3d47fd6ad12dc368677d10 (patch) | |
tree | 1abfcb3b03456ba88358b2b863b77a4669c07348 | |
parent | 3a698a2a1aad368d33b08d405fbc44d39f63982a (diff) | |
download | unitd-0a5f43565309fc6cad3d47fd6ad12dc368677d10.tar unitd-0a5f43565309fc6cad3d47fd6ad12dc368677d10.zip |
udevtrigger: simplify scan_subsystem function
Remove the local directory scanning code and
use the scan_subdir function instead.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
-rw-r--r-- | udevtrigger.c | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/udevtrigger.c b/udevtrigger.c index 5a9acac..08ddb06 100644 --- a/udevtrigger.c +++ b/udevtrigger.c @@ -220,32 +220,11 @@ static void scan_subdir(const char *base, const char *subdir, static void scan_subsystem(const char *subsys) { char base[PATH_SIZE]; - DIR *dir; - struct dirent *dent; strlcpy(base, "/sys/", sizeof(base)); strlcat(base, subsys, 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)); - strlcat(dirname, "/devices", sizeof(dirname)); - - /* look for devices */ - scan_subdir(dirname, NULL, true, 0); - } - - closedir(dir); + scan_subdir(base, "/devices", false, 1); } static void scan_block(void) |