[backfire] fix block-extroot on brcm-2.4 (#9454)
[openwrt-10.03/.git] / package / block-extroot / files / extmount.sh
index dfd6eef0733374db008bce0eae8d2282f2acff51..337951ca0cdc79eb253e0eef2588ec66ed2d8d0a 100644 (file)
@@ -13,12 +13,18 @@ set_jffs_mp() {
 }
 
 er_load_modules() {
-       [ -d $ER_ROOT/etc/modules.d ] && {
-           cd $ER_ROOT/etc/modules.d && {
-               local modules="$(grep -l '# May be required for rootfs' *)"
-               cat $modules | sed 's/^\([^#]\)/insmod \1/' | sh 2>&- || : 
-           }
+       mkdir -p /tmp/extroot_modules/modules.d
+       mkdir -p /tmp/extroot_modules/modules
+       ln -sf /etc/modules.d/* /tmp/overlay/etc/modules.d/* /tmp/extroot_modules/modules.d
+       ln -sf /lib/modules/*/* /tmp/overlay/lib/modules/*/* /tmp/extroot_modules/modules
+       local modules="$(grep -l '# May be required for rootfs' /tmp/extroot_modules/modules.d/*)"
+       cd /tmp/extroot_modules/modules && {
+               module_suffix=ko
+               case "$(uname -r)" in
+                       2.4.*) module_suffix=o ;;
+               esac
+               cat $modules | sed -e 's/^\([^#].*\)/insmod \.\/\1.'$module_suffix'/'| sh 2>&- || :
        }
+       rm -rf /tmp/extroot_modules
 }
 
-