Add the ability to revert a crypto mapping when unmounting a volume
Add the force_and_revert option to the unmount command which will force
the unmount, and revert a crypto mapping. This is used during factory
reset so that when the internal sdcard volume is formatted, it formats
the raw device, not the encrypted mapping.
Change-Id: I36b6ff9bb54863b121de635472a303bf4a2334a9
diff --git a/cryptfs.c b/cryptfs.c
index 50c3e64..3107e3e 100644
--- a/cryptfs.c
+++ b/cryptfs.c
@@ -845,6 +845,15 @@
return rc;
}
+/* Called by vold when it wants to undo the crypto mapping of a volume it
+ * manages. This is usually in response to a factory reset, when we want
+ * to undo the crypto mapping so the volume is formatted in the clear.
+ */
+int cryptfs_revert_volume(const char *label)
+{
+ return delete_crypto_blk_dev((char *)label);
+}
+
/*
* Called by vold when it's asked to mount an encrypted, nonremovable volume.
* Setup a dm-crypt mapping, use the saved master key from