Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1 | #include <sys/types.h> |
| 2 | #include <unistd.h> |
| 3 | #include <stdio.h> |
| 4 | #include <string.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <sys/stat.h> |
| 7 | #include <fcntl.h> |
OliverG96 | 06b91e7 | 2013-12-06 00:10:56 +0000 | [diff] [blame] | 8 | #ifdef TW_INCLUDE_JB_CRYPTO |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 9 | #include "../crypto/fs_mgr/include/fs_mgr.h" |
OliverG96 | 06b91e7 | 2013-12-06 00:10:56 +0000 | [diff] [blame] | 10 | #endif |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 11 | |
| 12 | #include "cutils/properties.h" |
| 13 | |
| 14 | #ifndef PROPERTY_VALUE_MAX |
| 15 | #define PROPERTY_VALUE_MAX 255 |
| 16 | #endif |
| 17 | #ifndef FSTAB_PREFIX |
| 18 | #define FSTAB_PREFIX "/fstab." |
| 19 | #endif |
| 20 | |
| 21 | int main(void) |
| 22 | { |
| 23 | char prop[PROPERTY_VALUE_MAX]; |
| 24 | char key_loc[PROPERTY_VALUE_MAX]; |
| 25 | char blk_dev[PROPERTY_VALUE_MAX]; |
| 26 | char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)]; |
| 27 | |
| 28 | printf("This tool will gather the build flags needed for decryption support for TWRP.\n"); |
| 29 | printf("This tool comes with no warranties whatsoever.\n"); |
| 30 | printf("http://teamw.in\n\n"); |
| 31 | property_get("ro.crypto.state", prop, "encrypted"); |
| 32 | if (strcmp(prop, "encrypted") != 0) |
| 33 | printf("Your device is not encrypted, continuing anyway.\n\nTW_INCLUDE_CRYPTO := true\n"); |
| 34 | property_get("ro.crypto.fs_type", prop, "ERROR"); |
| 35 | printf("TW_CRYPTO_FS_TYPE := \"%s\"\n", prop); |
| 36 | property_get("ro.crypto.fs_real_blkdev", prop, "ERROR"); |
| 37 | printf("TW_CRYPTO_REAL_BLKDEV := \"%s\"\n", prop); |
| 38 | property_get("ro.crypto.fs_mnt_point", prop, "ERROR"); |
| 39 | printf("TW_CRYPTO_MNT_POINT := \"%s\"\n", prop); |
| 40 | property_get("ro.crypto.fs_options", prop, "ERROR"); |
| 41 | printf("TW_CRYPTO_FS_OPTIONS := \"%s\"\n", prop); |
| 42 | property_get("ro.crypto.fs_flags", prop, "ERROR"); |
| 43 | printf("TW_CRYPTO_FS_FLAGS := \"%s\"\n", prop); |
| 44 | property_get("ro.crypto.keyfile.userdata", prop, "footer"); |
| 45 | printf("TW_CRYPTO_KEY_LOC := \"%s\"\n", prop); |
OliverG96 | 06b91e7 | 2013-12-06 00:10:56 +0000 | [diff] [blame] | 46 | #ifdef TW_INCLUDE_JB_CRYPTO |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 47 | printf("\n*** NEW FOR JELLY BEAN:\n"); |
| 48 | strcpy(fstab_filename, FSTAB_PREFIX); |
| 49 | property_get("ro.hardware", fstab_filename + sizeof(FSTAB_PREFIX) - 1, ""); |
| 50 | fs_mgr_get_crypt_info(fstab_filename, key_loc, blk_dev, sizeof(key_loc)); |
| 51 | printf("fstab file location: '%s'\n\nTW_INCLUDE_JB_CRYPTO := true\n", fstab_filename); |
OliverG96 | 06b91e7 | 2013-12-06 00:10:56 +0000 | [diff] [blame] | 52 | #endif |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 53 | |
| 54 | return 0; |
| 55 | } |