summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/ics/cryptfs.c54
-rw-r--r--data.cpp9
-rw-r--r--partition.cpp4
-rw-r--r--partitionmanager.cpp55
-rw-r--r--roots.cpp3
5 files changed, 79 insertions, 46 deletions
diff --git a/crypto/ics/cryptfs.c b/crypto/ics/cryptfs.c
index 054036628..5751cf74d 100644
--- a/crypto/ics/cryptfs.c
+++ b/crypto/ics/cryptfs.c
@@ -239,7 +239,7 @@ static int get_crypt_ftr_and_key(char *real_blk_name, struct crypt_mnt_ftr *cryp
if (!strcmp(key_loc, KEY_IN_FOOTER)) {
fname = real_blk_name;
if ( (fd = open(fname, O_RDONLY)) < 0) {
- ui_print("Cannot open real block device %s\n", fname);
+ printf("Cannot open real block device %s\n", fname);
return -1;
}
@@ -255,45 +255,45 @@ static int get_crypt_ftr_and_key(char *real_blk_name, struct crypt_mnt_ftr *cryp
off = ((off64_t)nr_sec * 512) - CRYPT_FOOTER_OFFSET;
if (lseek64(fd, off, SEEK_SET) == -1) {
- ui_print("Cannot seek to real block device footer\n");
+ printf("Cannot seek to real block device footer\n");
goto errout;
}
} else if (key_loc[0] == '/') {
fname = key_loc;
if ( (fd = open(fname, O_RDONLY)) < 0) {
- ui_print("Cannot open footer file %s\n", fname);
+ printf("Cannot open footer file %s\n", fname);
return -1;
}
/* Make sure it's 16 Kbytes in length */
fstat(fd, &statbuf);
if (S_ISREG(statbuf.st_mode) && (statbuf.st_size != 0x4000)) {
- ui_print("footer file %s is not the expected size!\n", fname);
+ printf("footer file %s is not the expected size!\n", fname);
goto errout;
}
} else {
- ui_print("Unexpected value for" KEY_LOC_PROP "\n");
+ printf("Unexpected value for" KEY_LOC_PROP "\n");
return -1;;
}
if ( (cnt = read(fd, crypt_ftr, sizeof(struct crypt_mnt_ftr))) != sizeof(struct crypt_mnt_ftr)) {
- ui_print("Cannot read real block device footer\n");
+ printf("Cannot read real block device footer\n");
goto errout;
}
if (crypt_ftr->magic != CRYPT_MNT_MAGIC) {
- ui_print("Bad magic for real block device %s\n", fname);
+ printf("Bad magic for real block device %s\n", fname);
goto errout;
}
if (crypt_ftr->major_version != 1) {
- ui_print("Cannot understand major version %d real block device footer\n",
+ printf("Cannot understand major version %d real block device footer\n",
crypt_ftr->major_version);
goto errout;
}
if (crypt_ftr->minor_version != 0) {
- ui_print("Warning: crypto footer minor version %d, expected 0, continuing...\n",
+ printf("Warning: crypto footer minor version %d, expected 0, continuing...\n",
crypt_ftr->minor_version);
}
@@ -302,29 +302,29 @@ static int get_crypt_ftr_and_key(char *real_blk_name, struct crypt_mnt_ftr *cryp
* Skip to it's stated end so we can read the key.
*/
if (lseek(fd, crypt_ftr->ftr_size - sizeof(struct crypt_mnt_ftr), SEEK_CUR) == -1) {
- ui_print("Cannot seek to start of key\n");
+ printf("Cannot seek to start of key\n");
goto errout;
}
}
if (crypt_ftr->keysize != KEY_LEN_BYTES) {
- ui_print("Keysize of %d bits not supported for real block device %s\n",
+ printf("Keysize of %d bits not supported for real block device %s\n",
crypt_ftr->keysize * 8, fname);
goto errout;
}
if ( (cnt = read(fd, key, crypt_ftr->keysize)) != crypt_ftr->keysize) {
- ui_print("Cannot read key for real block device %s\n", fname);
+ printf("Cannot read key for real block device %s\n", fname);
goto errout;
}
if (lseek64(fd, KEY_TO_SALT_PADDING, SEEK_CUR) == -1) {
- ui_print("Cannot seek to real block device salt\n");
+ printf("Cannot seek to real block device salt\n");
goto errout;
}
if ( (cnt = read(fd, salt, SALT_LEN)) != SALT_LEN) {
- ui_print("Cannot read salt for real block device %s\n", fname);
+ printf("Cannot read salt for real block device %s\n", fname);
goto errout;
}
@@ -372,7 +372,7 @@ static int create_crypto_blk_dev(struct crypt_mnt_ftr *crypt_ftr, unsigned char
int retval = -1;
if ((fd = open("/dev/device-mapper", O_RDWR)) < 0 ) {
- ui_print("Cannot open device-mapper\n");
+ printf("Cannot open device-mapper\n");
goto errout;
}
@@ -380,14 +380,14 @@ static int create_crypto_blk_dev(struct crypt_mnt_ftr *crypt_ftr, unsigned char
ioctl_init(io, DM_CRYPT_BUF_SIZE, name, 0);
if (ioctl(fd, DM_DEV_CREATE, io)) {
- ui_print("Cannot create dm-crypt device\n");
+ printf("Cannot create dm-crypt device\n");
goto errout;
}
/* Get the device status, in particular, the name of it's device file */
ioctl_init(io, DM_CRYPT_BUF_SIZE, name, 0);
if (ioctl(fd, DM_DEV_STATUS, io)) {
- ui_print("Cannot retrieve dm-crypt device status\n");
+ printf("Cannot retrieve dm-crypt device status\n");
goto errout;
}
minor = (io->dev & 0xff) | ((io->dev >> 12) & 0xfff00);
@@ -412,7 +412,7 @@ static int create_crypto_blk_dev(struct crypt_mnt_ftr *crypt_ftr, unsigned char
tgt->next = crypt_params - buffer;
if (ioctl(fd, DM_TABLE_LOAD, io)) {
- ui_print("Cannot load dm-crypt mapping table.\n");
+ printf("Cannot load dm-crypt mapping table.\n");
goto errout;
}
@@ -420,7 +420,7 @@ static int create_crypto_blk_dev(struct crypt_mnt_ftr *crypt_ftr, unsigned char
ioctl_init(io, 4096, name, 0);
if (ioctl(fd, DM_DEV_SUSPEND, io)) {
- ui_print("Cannot resume the dm-crypt device\n");
+ printf("Cannot resume the dm-crypt device\n");
goto errout;
}
@@ -441,7 +441,7 @@ static int delete_crypto_blk_dev(char *name)
int retval = -1;
if ((fd = open("/dev/device-mapper", O_RDWR)) < 0 ) {
- ui_print("Cannot open device-mapper\n");
+ printf("Cannot open device-mapper\n");
goto errout;
}
@@ -449,7 +449,7 @@ static int delete_crypto_blk_dev(char *name)
ioctl_init(io, DM_CRYPT_BUF_SIZE, name, 0);
if (ioctl(fd, DM_DEV_REMOVE, io)) {
- ui_print("Cannot remove dm-crypt device\n");
+ printf("Cannot remove dm-crypt device\n");
goto errout;
}
@@ -775,21 +775,21 @@ static int test_mount_encrypted_fs(char *passwd, char *mount_point, char *label)
property_get("ro.crypto.state", encrypted_state, "");
if ( master_key_saved || strcmp(encrypted_state, "encrypted") ) {
- ui_print("encrypted fs already validated or not running with encryption, aborting");
+ printf("encrypted fs already validated or not running with encryption, aborting");
return -1;
}
if (get_orig_mount_parms(mount_point, fs_type, real_blkdev, &mnt_flags, fs_options)) {
- ui_print("Error reading original mount parms for mount point %s\n", mount_point);
+ printf("Error reading original mount parms for mount point %s\n", mount_point);
return -1;
}
if (get_crypt_ftr_and_key(real_blkdev, &crypt_ftr, encrypted_master_key, salt)) {
- ui_print("Error getting crypt footer and key\n");
+ printf("Error getting crypt footer and key\n");
return -1;
}
- ui_print("crypt_ftr->fs_size = %lld\n", crypt_ftr.fs_size);
+ printf("crypt_ftr->fs_size = %lld\n", crypt_ftr.fs_size);
orig_failed_decrypt_count = crypt_ftr.failed_decrypt_count;
if (! (crypt_ftr.flags & CRYPT_MNT_KEY_UNENCRYPTED) ) {
@@ -798,7 +798,7 @@ static int test_mount_encrypted_fs(char *passwd, char *mount_point, char *label)
if (create_crypto_blk_dev(&crypt_ftr, decrypted_master_key,
real_blkdev, crypto_blkdev, label)) {
- ui_print("Error creating decrypted block device\n");
+ printf("Error creating decrypted block device\n");
return -1;
}
@@ -812,7 +812,7 @@ static int test_mount_encrypted_fs(char *passwd, char *mount_point, char *label)
sprintf(tmp_mount_point, "%s/tmp_mnt", mount_point);
mkdir(tmp_mount_point, 0755);
if ( mount(crypto_blkdev, tmp_mount_point, "ext4", MS_RDONLY, "") ) {
- ui_print("Error temp mounting decrypted block device\n");
+ printf("Error temp mounting decrypted block device\n");
delete_crypto_blk_dev(label);
crypt_ftr.failed_decrypt_count++;
} else {
diff --git a/data.cpp b/data.cpp
index 21293641c..70411a11a 100644
--- a/data.cpp
+++ b/data.cpp
@@ -605,6 +605,15 @@ void DataManager::SetDefaultValues()
str += dev_id;
SetValue(TW_BACKUPS_FOLDER_VAR, str, 0);
+#ifdef SP1_NAME
+ if (strlen(EXPAND(SP1_NAME))) mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP1_NAME)));
+#endif
+#ifdef SP2_NAME
+ if (strlen(EXPAND(SP2_NAME))) mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP2_NAME)));
+#endif
+#ifdef SP3_NAME
+ if (strlen(EXPAND(SP3_NAME))) mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP3_NAME)));
+#endif
#ifdef SP1_DISPLAY_NAME
if (strlen(EXPAND(SP1_DISPLAY_NAME))) mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP1_DISPLAY_NAME)));
#endif
diff --git a/partition.cpp b/partition.cpp
index 063603933..bbcb48c70 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -148,7 +148,7 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
// Do nothing
} else {
// Unhandled data
- LOGI("Unhandled fstab information: '%s', %i\n", ptr, index);
+ LOGI("Unhandled fstab information: '%s', %i, line: '%s'\n", ptr, index, Line.c_str());
}
}
while (index < line_len && full_line[index] != '\0')
@@ -1249,7 +1249,7 @@ bool TWPartition::Restore_Flash_Image(string restore_folder) {
bool TWPartition::Update_Size(bool Display_Error) {
bool ret = false;
- if (!Can_Be_Mounted)
+ if (!Can_Be_Mounted && !Is_Encrypted)
return false;
if (Removable || Is_Encrypted) {
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 968507274..a42c30308 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -66,6 +66,7 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error)
TWPartition* partition = new TWPartition();
string line = fstab_line;
+ memset(fstab_line, 0, sizeof(fstab_line));
if (partition->Process_Fstab_Line(line, Display_Error)) {
Partitions.push_back(partition);
@@ -646,7 +647,7 @@ int TWPartitionManager::Run_Backup(void) {
#ifdef SP1_NAME
DataManager::GetValue(TW_BACKUP_SP1_VAR, check);
if (check) {
- backup_sp1 = Find_Partition_By_Path(SP1_NAME);
+ backup_sp1 = Find_Partition_By_Path(EXPAND(SP1_NAME));
if (backup_sp1 != NULL) {
partition_count++;
if (backup_sp1->Backup_Method == 1)
@@ -654,7 +655,7 @@ int TWPartitionManager::Run_Backup(void) {
else
img_bytes += backup_sp1->Backup_Size;
} else {
- LOGE("Unable to locate %s partition.\n", SP1_NAME);
+ LOGE("Unable to locate %s partition.\n", EXPAND(SP1_NAME));
return false;
}
}
@@ -662,7 +663,7 @@ int TWPartitionManager::Run_Backup(void) {
#ifdef SP2_NAME
DataManager::GetValue(TW_BACKUP_SP2_VAR, check);
if (check) {
- backup_sp2 = Find_Partition_By_Path(SP2_NAME);
+ backup_sp2 = Find_Partition_By_Path(EXPAND(SP2_NAME));
if (backup_sp2 != NULL) {
partition_count++;
if (backup_sp2->Backup_Method == 1)
@@ -670,7 +671,7 @@ int TWPartitionManager::Run_Backup(void) {
else
img_bytes += backup_sp2->Backup_Size;
} else {
- LOGE("Unable to locate %s partition.\n", SP2_NAME);
+ LOGE("Unable to locate %s partition.\n", EXPAND(SP2_NAME));
return false;
}
}
@@ -678,7 +679,7 @@ int TWPartitionManager::Run_Backup(void) {
#ifdef SP3_NAME
DataManager::GetValue(TW_BACKUP_SP3_VAR, check);
if (check) {
- backup_sp3 = Find_Partition_By_Path(SP3_NAME);
+ backup_sp3 = Find_Partition_By_Path(EXPAND(SP3_NAME));
if (backup_sp3 != NULL) {
partition_count++;
if (backup_sp3->Backup_Method == 1)
@@ -686,7 +687,7 @@ int TWPartitionManager::Run_Backup(void) {
else
img_bytes += backup_sp3->Backup_Size;
} else {
- LOGE("Unable to locate %s partition.\n", SP3_NAME);
+ LOGE("Unable to locate %s partition.\n", EXPAND(SP3_NAME));
return false;
}
}
@@ -856,9 +857,9 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
#ifdef SP1_NAME
DataManager::GetValue(TW_RESTORE_SP1_VAR, check);
if (check > 0) {
- restore_sp1 = Find_Partition_By_Path(SP1_NAME);
+ restore_sp1 = Find_Partition_By_Path(EXPAND(SP1_NAME));
if (restore_sp1 == NULL) {
- LOGE("Unable to locate %s partition.\n", SP1_NAME);
+ LOGE("Unable to locate %s partition.\n", EXPAND(SP1_NAME));
return false;
}
partition_count++;
@@ -867,9 +868,9 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
#ifdef SP2_NAME
DataManager::GetValue(TW_RESTORE_SP2_VAR, check);
if (check > 0) {
- restore_sp2 = Find_Partition_By_Path(SP2_NAME);
+ restore_sp2 = Find_Partition_By_Path(EXPAND(SP2_NAME));
if (restore_sp2 == NULL) {
- LOGE("Unable to locate %s partition.\n", SP2_NAME);
+ LOGE("Unable to locate %s partition.\n", EXPAND(SP2_NAME));
return false;
}
partition_count++;
@@ -878,9 +879,9 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
#ifdef SP3_NAME
DataManager::GetValue(TW_RESTORE_SP3_VAR, check);
if (check > 0) {
- restore_sp3 = Find_Partition_By_Path(SP3_NAME);
+ restore_sp3 = Find_Partition_By_Path(EXPAND(SP3_NAME));
if (restore_sp3 == NULL) {
- LOGE("Unable to locate %s partition.\n", SP3_NAME);
+ LOGE("Unable to locate %s partition.\n", EXPAND(SP3_NAME));
return false;
}
partition_count++;
@@ -1049,15 +1050,15 @@ void TWPartitionManager::Set_Restore_Files(string Restore_Name) {
if (Part->Backup_Path == "/sd-ext")
tw_restore_sdext = 1;
#ifdef SP1_NAME
- if (Part->Backup_Path == TWFunc::Get_Root_Path(SP1_Name))
+ if (Part->Backup_Path == TWFunc::Get_Root_Path(EXPAND(SP1_NAME)))
tw_restore_sp1 = 1;
#endif
#ifdef SP2_NAME
- if (Part->Backup_Path == TWFunc::Get_Root_Path(SP2_Name))
+ if (Part->Backup_Path == TWFunc::Get_Root_Path(EXPAND(SP2_NAME)))
tw_restore_sp2 = 1;
#endif
#ifdef SP3_NAME
- if (Part->Backup_Path == TWFunc::Get_Root_Path(SP3_Name))
+ if (Part->Backup_Path == TWFunc::Get_Root_Path(EXPAND(SP3_NAME)))
tw_restore_sp3 = 1;
#endif
}
@@ -1288,6 +1289,24 @@ void TWPartitionManager::Update_System_Details(void) {
} else
DataManager::SetValue(TW_HAS_ANDROID_SECURE, 1);
}
+#ifdef SP1_NAME
+ if ((*iter)->Backup_Name == EXPAND(SP1_NAME)) {
+ int backup_display_size = (int)((*iter)->Backup_Size / 1048576LLU);
+ DataManager::SetValue(TW_BACKUP_SP1_SIZE, backup_display_size);
+ }
+#endif
+#ifdef SP2_NAME
+ if ((*iter)->Backup_Name == EXPAND(SP2_NAME)) {
+ int backup_display_size = (int)((*iter)->Backup_Size / 1048576LLU);
+ DataManager::SetValue(TW_BACKUP_SP2_SIZE, backup_display_size);
+ }
+#endif
+#ifdef SP3_NAME
+ if ((*iter)->Backup_Name == EXPAND(SP3_NAME)) {
+ int backup_display_size = (int)((*iter)->Backup_Size / 1048576LLU);
+ DataManager::SetValue(TW_BACKUP_SP3_SIZE, backup_display_size);
+ }
+#endif
}
}
DataManager::SetValue(TW_BACKUP_DATA_SIZE, data_size);
@@ -1302,8 +1321,10 @@ void TWPartitionManager::Update_System_Details(void) {
if (has_dual_storage == 1) {
// We have dual storage, see if we're using the internal storage that should always be present
if (current_storage_path == DataManager::GetSettingsStoragePath()) {
- // Not able to use internal, so error!
- LOGE("Unable to mount internal storage.\n");
+ if (!FreeStorage->Is_Encrypted) {
+ // Not able to use internal, so error!
+ LOGE("Unable to mount internal storage.\n");
+ }
DataManager::SetValue(TW_STORAGE_FREE_SIZE, 0);
} else {
// We were using external, flip to internal
diff --git a/roots.cpp b/roots.cpp
index 9cbaa499a..d7ffb3161 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -288,7 +288,10 @@ int format_volume(const char* volume) {
if (strcmp(v->fs_type, "ext4") == 0) {
#ifdef USE_EXT4
+/*
int result = make_ext4fs(v->device, v->length, volume, sehandle);
+*/
+ int result = 0;
#else
int result = 0;
#endif