plugins: modprobe: Never follow symlinks in /sys/devices

Unlike find(1), nftw(3) defaults to follow symlinks.  For some kernel
configurations this turned out to be detrimental and caused the plugin
to loop forever scanning modalias files.

Also, check if /sys is mounted before even calling nftw().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2020-04-26 14:55:38 +02:00
parent 3f5ff0d339
commit 2a4052bd8d
+11 -4
View File
@@ -142,11 +142,18 @@ static void coldplug(void *arg)
struct module *m, *tmp;
int rc = 0;
if (!fismnt("/sys")) {
print(1, "Cannot modprobe system, /sys is not mounted");
return;
}
print_desc("Cold plugging system", NULL);
nftw("/sys/devices", scan_alias, 200, FTW_DEPTH);
TAILQ_FOREACH_SAFE(m, &modules, link, tmp) {
rc += modprobe(m->alias);
alias_remove(m);
rc = nftw("/sys/devices", scan_alias, 200, FTW_DEPTH | FTW_PHYS);
if (!rc) {
TAILQ_FOREACH_SAFE(m, &modules, link, tmp) {
rc += modprobe(m->alias);
alias_remove(m);
}
}
print_result(rc);