jklap

Untitled

May 19th, 2014
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.09 KB | None | 0 0
  1. diff --git a/target/linux/mvebu/mamba/base-files/lib/preinit/81_mount_ubifs_overlay b/target/linux/mvebu/mamba/base-files/lib/preinit/81_mount_ubifs_overlay
  2. index 14e1a52..4df654d 100644
  3. --- a/target/linux/mvebu/mamba/base-files/lib/preinit/81_mount_ubifs_overlay
  4. +++ b/target/linux/mvebu/mamba/base-files/lib/preinit/81_mount_ubifs_overlay
  5. @@ -2,24 +2,10 @@
  6.  
  7.  SYSCFG_UBIFS_MNT=/tmp/syscfg
  8.  get_current_rootfs_label() {
  9. -       boot_part=`/usr/sbin/fw_printenv -n boot_part`
  10. -       rootfs_label=""
  11. -       if [ "$boot_part" -eq 1 ]
  12. -       then
  13. -               # primary boot image
  14. -               rootfs_label="rootfs"
  15. -       elif [ "$boot_part" -eq 2 ]
  16. -       then
  17. -               # alternative boot image
  18. -               rootfs_label="alt_rootfs"
  19. -       else
  20. -               # try to guess from bootarg, should not come here
  21. -               grep -q "mtdblock5" /proc/cmdline && boot_part=1 \
  22. -                       && rootfs_label="rootfs"
  23. -               grep -q "mtdblock7" /proc/cmdline && boot_part=2 \
  24. -                       && rootfs_label="alt_rootfs"
  25. -               fw_setenv boot_part $boot_part
  26. -       fi
  27. +       grep -q "mtdblock5" /proc/cmdline && boot_part=1 \
  28. +               && rootfs_label="rootfs"
  29. +       grep -q "mtdblock7" /proc/cmdline && boot_part=2 \
  30. +               && rootfs_label="alt_rootfs"
  31.         echo "$rootfs_label"
  32.  }
  33.  
  34. @@ -65,22 +51,28 @@ try_ubifs_syscfg_mount() {
  35.         fi
  36.         if [ $recover_ubifs -eq 1 ]
  37.         then
  38. -               echo "ubifs syscfg partition is damaged"
  39. -               echo "try to recover by formatting $mtdpart..."
  40. -               [ -e /dev/ubi0 ] && ubidetach -m $mtdpart_idx
  41. -               ubiformat -y -q /dev/mtd$mtdpart_idx
  42. -               ubiattach -m $mtdpart_idx /dev/ubi_ctrl
  43. -               ubi0_nod_id=`cat /sys/class/ubi/ubi0/dev | tr -s ":" " "`
  44. -               [ ! -e /dev/ubi0 ] && mknod /dev/ubi0 c ${ubi0_nod_id}
  45. -               ubimkvol /dev/ubi0 -n 0 -N syscfg -t dynamic --maxavsize
  46. +               ubifs_recover
  47.         fi
  48.         # finally mount the ubifs
  49. -       mount -t ubifs -o noatime ubi0:syscfg $SYSCFG_UBIFS_MNT || return 1
  50. +       mount -t ubifs -o noatime ubi0:syscfg $SYSCFG_UBIFS_MNT || \
  51. +               ubifs_recover || \
  52. +               mount -t ubifs -o noatime ubi0:syscfg $SYSCFG_UBIFS_MNT || return 1
  53.         [ ! -d $SYSCFG_UBIFS_MNT/openwrt_overlay ] && mkdir -p $SYSCFG_UBIFS_MNT/openwrt_overlay
  54.         mount -o bind $SYSCFG_UBIFS_MNT/openwrt_overlay $overlay_mountpoint
  55.         return 0
  56.  }
  57.  
  58. +ubifs_recover() {
  59. +       echo "ubifs syscfg partition is damaged"
  60. +       echo "try to recover by formatting $mtdpart..."
  61. +       [ -e /dev/ubi0 ] && ubidetach -m $mtdpart_idx
  62. +       ubiformat -y -q /dev/mtd$mtdpart_idx
  63. +       ubiattach -m $mtdpart_idx /dev/ubi_ctrl
  64. +       ubi0_nod_id=`cat /sys/class/ubi/ubi0/dev | tr -s ":" " "`
  65. +       [ ! -e /dev/ubi0 ] && mknod /dev/ubi0 c ${ubi0_nod_id}
  66. +       ubimkvol /dev/ubi0 -n 0 -N syscfg -t dynamic --maxavsize
  67. +}
  68. +
  69.  ubifs_syscfg_rootfs_pivot() {
  70.         echo "switching to ubifs sysfs overlay"
  71.         fopivot /overlay /rom
Advertisement
Add Comment
Please, Sign In to add comment