blob: 79fad7198bc9b30fea09aaea9840220e14b492be [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001#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>
8#include "../crypto/fs_mgr/include/fs_mgr.h"
9
10#include "cutils/properties.h"
11
12#ifndef PROPERTY_VALUE_MAX
13#define PROPERTY_VALUE_MAX 255
14#endif
15#ifndef FSTAB_PREFIX
16#define FSTAB_PREFIX "/fstab."
17#endif
18
19int main(void)
20{
21 char prop[PROPERTY_VALUE_MAX];
22 char key_loc[PROPERTY_VALUE_MAX];
23 char blk_dev[PROPERTY_VALUE_MAX];
24 char fstab_filename[PROPERTY_VALUE_MAX + sizeof(FSTAB_PREFIX)];
25
26 printf("This tool will gather the build flags needed for decryption support for TWRP.\n");
27 printf("This tool comes with no warranties whatsoever.\n");
28 printf("http://teamw.in\n\n");
29 property_get("ro.crypto.state", prop, "encrypted");
30 if (strcmp(prop, "encrypted") != 0)
31 printf("Your device is not encrypted, continuing anyway.\n\nTW_INCLUDE_CRYPTO := true\n");
32 property_get("ro.crypto.fs_type", prop, "ERROR");
33 printf("TW_CRYPTO_FS_TYPE := \"%s\"\n", prop);
34 property_get("ro.crypto.fs_real_blkdev", prop, "ERROR");
35 printf("TW_CRYPTO_REAL_BLKDEV := \"%s\"\n", prop);
36 property_get("ro.crypto.fs_mnt_point", prop, "ERROR");
37 printf("TW_CRYPTO_MNT_POINT := \"%s\"\n", prop);
38 property_get("ro.crypto.fs_options", prop, "ERROR");
39 printf("TW_CRYPTO_FS_OPTIONS := \"%s\"\n", prop);
40 property_get("ro.crypto.fs_flags", prop, "ERROR");
41 printf("TW_CRYPTO_FS_FLAGS := \"%s\"\n", prop);
42 property_get("ro.crypto.keyfile.userdata", prop, "footer");
43 printf("TW_CRYPTO_KEY_LOC := \"%s\"\n", prop);
44 printf("\n*** NEW FOR JELLY BEAN:\n");
45 strcpy(fstab_filename, FSTAB_PREFIX);
46 property_get("ro.hardware", fstab_filename + sizeof(FSTAB_PREFIX) - 1, "");
47 fs_mgr_get_crypt_info(fstab_filename, key_loc, blk_dev, sizeof(key_loc));
48 printf("fstab file location: '%s'\n\nTW_INCLUDE_JB_CRYPTO := true\n", fstab_filename);
49
50 return 0;
51}