summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorJP Abgrall <jpa@google.com>2014-07-02 14:26:54 -0700
committerJP Abgrall <jpa@google.com>2014-07-02 14:28:50 -0700
commitcee206880ef80ac570df6b369d12f111c00f653a (patch)
tree562e7100d04e0325a9b1bbbe93dbf909402035c5 /init
parentf22b7452940c99b830749cabdd929f9f7cfdaacc (diff)
downloadsystem_core-cee206880ef80ac570df6b369d12f111c00f653a.zip
system_core-cee206880ef80ac570df6b369d12f111c00f653a.tar.gz
system_core-cee206880ef80ac570df6b369d12f111c00f653a.tar.bz2
[HACK]fs_mgr+init: Format via recovery if encryptable /data is wiped
If the encryptable partition is wiped (4KB worth of 0 or 0xff), then reboot into recovery to format /data+/cache This is while waiting for the Mac OS support to format f2fs. The flashstation running on Mac OS will currently just erase userdata and not format it with f2fs. Bug: 15720406 Bug: 15747366 Change-Id: Ib7cca3e1701483a09573457a835750f34da71ee0
Diffstat (limited to 'init')
-rw-r--r--init/builtins.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/init/builtins.c b/init/builtins.c
index dd147f6..f7bd8a9 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -474,6 +474,26 @@ exit_success:
}
+static int wipe_data_via_recovery()
+{
+ mkdir("/cache/recovery", 0700);
+ int fd = open("/cache/recovery/command", O_RDWR|O_CREAT|O_TRUNC, 0600);
+ if (fd >= 0) {
+ write(fd, "--wipe_data", strlen("--wipe_data") + 1);
+ close(fd);
+ } else {
+ ERROR("could not open /cache/recovery/command\n");
+ return -1;
+ }
+ android_reboot(ANDROID_RB_RESTART2, 0, "recovery");
+ while (1) { pause(); } // never reached
+}
+
+
+/*
+ * This function might request a reboot, in which case it will
+ * not return.
+ */
int do_mount_all(int nargs, char **args)
{
pid_t pid;
@@ -529,6 +549,13 @@ int do_mount_all(int nargs, char **args)
* that action.
*/
action_for_each_trigger("nonencrypted", action_add_queue_tail);
+ } else if (ret == FS_MGR_MNTALL_DEV_NEEDS_RECOVERY) {
+ /* Setup a wipe via recovery, and reboot into recovery */
+ ERROR("fs_mgr_mount_all suggested recovery, so wiping data via recovery.\n");
+ ret = wipe_data_via_recovery();
+ /* If reboot worked, there is no return. */
+ } else if (ret > 0) {
+ ERROR("fs_mgr_mount_all returned unexpected error %d\n", ret);
}
/* else ... < 0: error */