Skip to content

Commit

Permalink
fix filesystem detection for nandroid backup
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtrip committed Jan 26, 2011
1 parent df95d8e commit b066305
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
88 changes: 87 additions & 1 deletion sbin/postrecoveryboot.sh
Expand Up @@ -2,7 +2,93 @@

rm /etc
mkdir /etc
cat /res/etc/recovery.fstab > /etc/recovery.fstab

sdcard_device='/dev/block/mmcblk0p1'
cache_partition='/dev/block/stl11'
dbdata_partition='/dev/block/stl10'
data_partition='/dev/block/mmcblk0p2'
system_partition='/dev/block/stl9'

generate_cwm_fstab()
{
for x in cache datadata data system; do
get_partition_for $x
get_fs_for $x
get_cwm_fstab_mount_option_for $fs
echo "$partition /$x $fs $cwm_mount_options" >> /etc/fstab
echo "/$x $fs $partition" >> /etc/recovery.fstab
done

# internal sdcard/USB Storage
echo "$sdcard_device /sdcard vfat rw,uid=1000,gid=1015,iocharset=iso8859-1,shortname=mixed,utf8" >> /etc/fstab
echo "/sdcard vfat $sdcard_device" >> /etc/recovery.fstab

# external sdcard/USB Storage
echo "/dev/block/mmcblk1p1 /sd-ext vfat rw,uid=1000,gid=1015,iocharset=iso8859-1,shortname=mixed,utf8" >> /etc/fstab
echo "/sd-ext vfat /dev/block/mmcblk1p1" >> /etc/recovery.fstab
}

detect_all_filesystems()
{
system_fs=`detect_fs_on system`
dbdata_fs=`detect_fs_on dbdata`
cache_fs=`detect_fs_on cache`
data_fs=`detect_fs_on data`
}

detect_fs_on()
{
resource=$1
get_partition_for $resource
log "filesystem detection on $resource:"
if /sbin/tune2fs -l $partition 1>&2; then
# we found an ext2/3/4 partition. but is it real ?
# if the data partition mounts as rfs, it means
# that this Ext4 partition is just lost bits still here
log "Ext4 on $partition" 1
echo ext4
return
fi
log "RFS on $partition" 1
echo rfs
}

get_partition_for()
{
# resource partition getter which set a global variable named partition
case $1 in
cache) partition=$cache_partition ;;
dbdata) partition=$dbdata_partition ;;
datadata) partition=$dbdata_partition ;;
data) partition=$data_partition ;;
system) partition=$system_partition ;;
esac
}

get_fs_for()
{
# resource filesystem getter which set a global variable named fs
case $1 in
cache) fs=$cache_fs ;;
dbdata) fs=$dbdata_fs ;;
datadata) fs=$dbdata_fs ;;
data) fs=$data_fs ;;
system) fs=$system_fs ;;
esac
}

get_cwm_fstab_mount_option_for()
{
if test "$1" = "ext4"; then
cwm_mount_options='journal=ordered,nodelalloc'
else
cwm_mount_options='check=no'
fi
}

detect_all_filesystems

generate_cwm_fstab

rm /sdcard
mkdir /sdcard
Expand Down
Binary file modified sbin/recovery
Binary file not shown.

0 comments on commit b066305

Please sign in to comment.