generate fstab using mkfstab.sh. implement restore of system data and cache in nandroid
diff --git a/nandroid/mkfstab.sh b/nandroid/mkfstab.sh
new file mode 100755
index 0000000..649ae2f
--- /dev/null
+++ b/nandroid/mkfstab.sh
@@ -0,0 +1,33 @@
+#!/sbin/sh
+
+cat /proc/mtd | while read mtdentry
+do
+ mtd=$(echo $mtdentry | awk '{print $1}')
+ mtd=$(echo $mtd | sed s/mtd//)
+ mtd=$(echo $mtd | sed s/://)
+ exist=$(ls -l /dev/block/mtdblock$mtd) 2> /dev/null
+ if [ -z "$exist" ]
+ then
+ continue
+ fi
+ partition=$(echo $mtdentry | awk '{print $4}')
+ partition=$(echo $partition | sed s/\"//g)
+ mount=$partition
+ type=
+ if [ "$partition" = "system" ]
+ then
+ type=yaffs2
+ elif [ "$partition" = "userdata" ]
+ then
+ type=yaffs2
+ mount=data
+ elif [ "$partition" == "cache" ]
+ then
+ type=yaffs2
+ else
+ continue
+ fi
+
+ echo "/dev/block/mtdblock$mtd /$mount $type rw"
+done
+echo "/dev/block/mmcblk0p1" /sdcard vfat rw
\ No newline at end of file
diff --git a/nandroid/nandroid-mobile.sh b/nandroid/nandroid-mobile.sh
index 4929074..e8ae697 100755
--- a/nandroid/nandroid-mobile.sh
+++ b/nandroid/nandroid-mobile.sh
@@ -94,6 +94,11 @@
exit 1
fi
fi
+ unyaffs=`which unyaffs`
+ if [ "$unyaffs" == "" ]; then
+ echo "error: unyaffs not found in path"
+ exit 1
+ fi
break
;;
esac
@@ -133,17 +138,15 @@
echo "error: $RESTOREPATH/nandroid.md5 not found, cannot verify backup data"
exit 1
fi
- umount /system 2>/dev/null
- umount /data 2>/dev/null
- if [ ! "`mount | grep data`" == "" ]; then
- echo "error: unable to umount /data, aborting"
- exit 1
- fi
- if [ ! "`mount | grep system`" == "" ]; then
- echo "error: unable to umount /system, aborting"
- exit 1
- fi
-
+ umount /system 2>/dev/null
+ umount /data 2>/dev/null
+ mount -o rw /system || FAIL=1
+ mount -o rw /data || FAIL=2
+ case $FAIL in
+ 1) echo "Error mounting system read-write"; umount /system /data /cache; exit 1;;
+ 2) echo "Error mounting data read-write"; umount /system /data /cache; exit 1;;
+ esac
+
echo "Verifying backup images..."
CWD=$PWD
cd $RESTOREPATH
@@ -156,8 +159,18 @@
echo "Flashing $image..."
$flash_image $image $image.img
done
- echo "Flashing system and data not currently supported"
- echo "Restore done"
+ curdir=$(pwd)
+ for image in system data cache; do
+ echo "Unpacking $image..."
+ cd /$image
+ rm -rf *
+ unyaffs $curdir/$image.img
+ cd $curdir
+ done
+ sync
+ umount /system
+ umount /data
+ echo "Restore done"
exit 0
;;
backup)