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().
@@ -142,12 +142,19 @@ 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);
+ 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);
}
