- sprintf(kmod_loader, "/sbin/kmodloader %s/etc/modules-boot.d/ %s", extroot_prefix, extroot_prefix);
- system(kmod_loader);
+ if (stat(block_path, &s) || !S_ISREG(s.st_mode))
+ snprintf(block_path, sizeof(block_path), "/sbin/block");
+
+ if (stat(block_path, &s) || !S_ISREG(s.st_mode))
+ return -1;
+
+ /* set LD_LIBRARY_PATH env var and load kmods from overlay if we found a lib directory there */
+ if (!stat(ldlib_path, &s) && S_ISDIR(s.st_mode)) {
+ setenv("LD_LIBRARY_PATH", ldlib_path, 1);
+ kmod_prefix = dirname(ldlib_path);
+ sprintf(kmod_loader, "/sbin/kmodloader %s/etc/modules-boot.d/ %s", kmod_prefix, kmod_prefix);
+ system(kmod_loader);
+ }