summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-09-11 16:10:14 +0200
committerJohn Crispin <blogic@openwrt.org>2013-09-13 17:36:58 +0200
commit3a698a2a1aad368d33b08d405fbc44d39f63982a (patch)
treef5d0f33d5649fb7bdbbf703f52d9bca074154e0e
parent583568b22fbab0d6d6128433cedf7f1a88c183c1 (diff)
downloadunitd-3a698a2a1aad368d33b08d405fbc44d39f63982a.tar
unitd-3a698a2a1aad368d33b08d405fbc44d39f63982a.zip
udevtrigger: extend scan_subdir function
Add more arguments to the function to make it usable recursively. Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
-rw-r--r--udevtrigger.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/udevtrigger.c b/udevtrigger.c
index 2f1af35..5a9acac 100644
--- a/udevtrigger.c
+++ b/udevtrigger.c
@@ -179,7 +179,8 @@ static int device_list_insert(const char *path)
return 0;
}
-static void scan_subdir(const char *base)
+static void scan_subdir(const char *base, const char *subdir,
+ bool insert, int depth)
{
DIR *dir;
struct dirent *dent;
@@ -197,7 +198,20 @@ static void scan_subdir(const char *base)
strlcpy(dirname, base, sizeof(dirname));
strlcat(dirname, "/", sizeof(dirname));
strlcat(dirname, dent->d_name, sizeof(dirname));
- device_list_insert(dirname);
+
+ if (insert) {
+ int err;
+
+ err = device_list_insert(dirname);
+ if (err)
+ continue;
+ }
+
+ if (subdir)
+ strlcat(dirname, subdir, sizeof(base));
+
+ if (depth)
+ scan_subdir(dirname, NULL, true, depth - 1);
}
closedir(dir);
@@ -228,7 +242,7 @@ static void scan_subsystem(const char *subsys)
strlcat(dirname, "/devices", sizeof(dirname));
/* look for devices */
- scan_subdir(dirname);
+ scan_subdir(dirname, NULL, true, 0);
}
closedir(dir);
@@ -259,7 +273,7 @@ static void scan_block(void)
continue;
/* look for partitions */
- scan_subdir(dirname);
+ scan_subdir(dirname, NULL, true, 0);
}
closedir(dir);
@@ -287,7 +301,7 @@ static void scan_class(void)
strlcat(dirname, "/", sizeof(dirname));
strlcat(dirname, dent->d_name, sizeof(dirname));
- scan_subdir(dirname);
+ scan_subdir(dirname, NULL, true, 0);
}
closedir(dir);