From c51bd350403ebe91cf2e21a55625348113aa3130 Mon Sep 17 00:00:00 2001 From: James Christopher Adduono Date: Sat, 21 Jan 2017 00:17:30 -0500 Subject: Try mounting different filesystems during decryption Based on Dees_Troy's approach. Change-Id: Id9aafb6d0c64ab43e2711720a26e30ac86b90235 --- crypto/lollipop/cryptfs.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crypto/lollipop/cryptfs.c b/crypto/lollipop/cryptfs.c index 0c7848d8f..986507e22 100644 --- a/crypto/lollipop/cryptfs.c +++ b/crypto/lollipop/cryptfs.c @@ -1328,6 +1328,21 @@ static int decrypt_master_key(char *passwd, unsigned char *decrypted_master_key, 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 @@ static int test_mount_encrypted_fs(struct crypt_mnt_ftr* crypt_ftr, * 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; -- cgit v1.2.3