From e75c838fab3d40b216b1053d37e0e01335550f57 Mon Sep 17 00:00:00 2001 From: Pawit Pornkitprasan Date: Mon, 28 Nov 2011 19:24:42 +0700 Subject: Add encryption support and cleaned up init.aries.rc for it --- setupdatadata.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 setupdatadata.sh (limited to 'setupdatadata.sh') diff --git a/setupdatadata.sh b/setupdatadata.sh new file mode 100644 index 0000000..f3c44e2 --- /dev/null +++ b/setupdatadata.sh @@ -0,0 +1,40 @@ +#!/system/bin/sh +# +# Setup /data/data based on whether the phone is encrypted or not +# and migrate the data to the correct location on en/decryption +# Encrypted => leave on /data/data (/datadata cannot be encrypted) +# Unencrypted => symlink to /datadata for performance + +PATH=/system/bin/:/system/xbin/ + +# There are 4 states which this script can be called from. +# They can be detected using vold.decrypt and ro.crypto.state props + +CRYPTO_STATE="`getprop ro.crypto.state`" +VOLD_DECRYPT="`getprop vold.decrypt`" + +if test "$CRYPTO_STATE" = "unencrypted" ; then + if test "$VOLD_DECRYPT" = "" ; then + # Normal unencrypted boot + rm -r /data/data + ln -s /datadata /data/data + fi + # else: Encrypting, do nothing +else + if test "$VOLD_DECRYPT" = "trigger_post_fs_data" ; then + # Encrypted boot (after decryption) + # Migrate data from /datadata to /data/data + if test -h /data/data ; then + rm /data/data + mkdir /data/data + chown system.system /data/data + chmod 0771 /data/data + cp -a /datadata/* /data/data/ + rm -r /data/data/lost+found + busybox umount /datadata + erase_image datadata + busybox mount /datadata + fi + fi + # else: Encrypted boot (before decryption), do nothing +fi -- cgit v1.1