diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2011-11-28 19:24:42 +0700 |
---|---|---|
committer | Pawit Pornkitprasan <p.pawit@gmail.com> | 2011-11-28 19:24:42 +0700 |
commit | e75c838fab3d40b216b1053d37e0e01335550f57 (patch) | |
tree | f18934817fc3e9f9792e4fd4b4f4fb1dfc75e6a9 /setupdatadata.sh | |
parent | 486af594b2da934999a78ff0ebf6b8a7daf6231c (diff) | |
download | device_samsung_aries-common-e75c838fab3d40b216b1053d37e0e01335550f57.zip device_samsung_aries-common-e75c838fab3d40b216b1053d37e0e01335550f57.tar.gz device_samsung_aries-common-e75c838fab3d40b216b1053d37e0e01335550f57.tar.bz2 |
Add encryption support and cleaned up init.aries.rc for it
Diffstat (limited to 'setupdatadata.sh')
-rw-r--r-- | setupdatadata.sh | 40 |
1 files changed, 40 insertions, 0 deletions
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 |