Try mounting different filesystems during decryption
Based on Dees_Troy's approach.
Change-Id: Id9aafb6d0c64ab43e2711720a26e30ac86b90235
diff --git a/crypto/lollipop/cryptfs.c b/crypto/lollipop/cryptfs.c
index 0c7848d..986507e 100644
--- a/crypto/lollipop/cryptfs.c
+++ b/crypto/lollipop/cryptfs.c
@@ -1328,6 +1328,21 @@
return ret;
}
+static int try_mount_multiple_fs(const char *crypto_blkdev,
+ const char *mount_point,
+ const char *file_system)
+{
+ if (!mount(crypto_blkdev, mount_point, file_system, 0, NULL))
+ return 0;
+ if (strcmp(file_system, "ext4") &&
+ !mount(crypto_blkdev, mount_point, "ext4", 0, NULL))
+ return 0;
+ if (strcmp(file_system, "f2fs") &&
+ !mount(crypto_blkdev, mount_point, "f2fs", 0, NULL))
+ return 0;
+ return 1;
+}
+
static int test_mount_encrypted_fs(struct crypt_mnt_ftr* crypt_ftr,
char *passwd, char *mount_point, char *label)
{
@@ -1426,7 +1441,7 @@
* the footer, not the key. */
sprintf(tmp_mount_point, "%s/tmp_mnt", mount_point);
mkdir(tmp_mount_point, 0755);
- if (mount(crypto_blkdev, tmp_mount_point, file_system, 0, NULL) != 0) {
+ if (try_mount_multiple_fs(crypto_blkdev, tmp_mount_point, file_system)) {
printf("Error temp mounting decrypted block device '%s'\n", crypto_blkdev);
delete_crypto_blk_dev(label);
rc = 1;