Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1 | /* Partition class for TWRP |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | * You should have received a copy of the GNU General Public License |
| 13 | * along with this program; if not, write to the Free Software |
| 14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 15 | * 02110-1301, USA. |
| 16 | * |
| 17 | * The code was written from scratch by Dees_Troy dees_troy at |
| 18 | * yahoo |
| 19 | * |
| 20 | * Copyright (c) 2012 |
| 21 | */ |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <string.h> |
| 26 | #include <sys/stat.h> |
| 27 | #include <sys/vfs.h> |
| 28 | #include <unistd.h> |
| 29 | |
| 30 | #include "variables.h" |
| 31 | #include "common.h" |
| 32 | #include "partitions.hpp" |
| 33 | |
| 34 | TWPartition::TWPartition(void) { |
| 35 | Can_Be_Mounted = false; |
| 36 | Can_Be_Wiped = false; |
| 37 | Wipe_During_Factory_Reset = false; |
| 38 | Wipe_Available_in_GUI = false; |
| 39 | Is_SubPartition = false; |
| 40 | SubPartition_Of = ""; |
| 41 | Symlink_Path = ""; |
| 42 | Symlink_Mount_Point = ""; |
| 43 | Mount_Point = ""; |
| 44 | Block_Device = ""; |
| 45 | Alternate_Block_Device = ""; |
| 46 | Removable = false; |
| 47 | Is_Present = false; |
| 48 | Length = 0; |
| 49 | Size = 0; |
| 50 | Used = 0; |
| 51 | Free = 0; |
| 52 | Backup_Size = 0; |
| 53 | Can_Be_Encrypted = false; |
| 54 | Is_Encrypted = false; |
| 55 | Is_Decrypted = false; |
| 56 | Decrypted_Block_Device = ""; |
| 57 | Display_Name = ""; |
| 58 | Backup_Name = ""; |
| 59 | Backup_Method = NONE; |
| 60 | Has_Data_Media = false; |
| 61 | Is_Storage = false; |
| 62 | Storage_Path = ""; |
| 63 | Current_File_System = ""; |
| 64 | Fstab_File_System = ""; |
| 65 | Format_Block_Size = 0; |
| 66 | } |
| 67 | |
| 68 | TWPartition::~TWPartition(void) { |
| 69 | // Do nothing |
| 70 | } |
| 71 | |
| 72 | bool TWPartition::Process_Fstab_Line(string Line) { |
| 73 | LOGI("STUB TWPartition::Process_Fstab_Line, Line: '%s'\n", Line.c_str()); |
| 74 | return 1; |
| 75 | } |
| 76 | |
| 77 | bool TWPartition::Is_Mounted(void) { |
| 78 | LOGI("STUB TWPartition::Is_Mounted\n"); |
| 79 | return 1; |
| 80 | } |
| 81 | |
| 82 | bool TWPartition::Mount(bool Display_Error) { |
| 83 | LOGI("STUB TWPartition::Mount, Display_Error: %i\n", Display_Error); |
| 84 | if (Is_Mounted()) { |
| 85 | return 1; |
| 86 | } else { |
| 87 | return 1; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | bool TWPartition::UnMount(bool Display_Error) { |
| 92 | LOGI("STUB TWPartition::Mount, Display_Error: %i\n", Display_Error); |
| 93 | if (Is_Mounted()) { |
| 94 | return 1; |
| 95 | } else { |
| 96 | return 1; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | bool TWPartition::Wipe() { |
| 101 | LOGI("STUB TWPartition::Wipe\n"); |
| 102 | return 1; |
| 103 | } |
| 104 | |
| 105 | bool TWPartition::Backup(string backup_folder) { |
| 106 | LOGI("STUB TWPartition::Backup, backup_folder: '%s'\n", backup_folder.c_str()); |
| 107 | return 1; |
| 108 | } |
| 109 | |
| 110 | bool TWPartition::Restore(string restore_folder) { |
| 111 | LOGI("STUB TWPartition::Restore, restore_folder: '%s'\n", restore_folder.c_str()); |
| 112 | return 1; |
| 113 | } |
| 114 | |
| 115 | string TWPartition::Backup_Method_By_Name() { |
| 116 | LOGI("STUB TWPartition::Backup_Method_By_Name\n"); |
| 117 | return "STUB"; |
| 118 | } |
| 119 | |
| 120 | bool TWPartition::Decrypt(string Password) { |
| 121 | LOGI("STUB TWPartition::Decrypt, password: '%s'\n", Password.c_str()); |
| 122 | return 1; |
| 123 | } |
| 124 | |
| 125 | bool TWPartition::Wipe_Encryption() { |
| 126 | LOGI("STUB TWPartition::Wipe_Encryption\n"); |
| 127 | return 1; |
| 128 | } |
| 129 | |
| 130 | void TWPartition::Check_FS_Type() { |
| 131 | LOGI("STUB TWPartition::Check_FS_Type\n"); |
| 132 | return; |
| 133 | } |
| 134 | |
| 135 | bool TWPartition::Wipe_EXT23() { |
| 136 | LOGI("STUB TWPartition::Wipe_EXT23\n"); |
| 137 | return 1; |
| 138 | } |
| 139 | |
| 140 | bool TWPartition::Wipe_EXT4() { |
| 141 | LOGI("STUB TWPartition::Wipe_EXT4\n"); |
| 142 | return 1; |
| 143 | } |
| 144 | |
| 145 | bool TWPartition::Wipe_FAT() { |
| 146 | LOGI("STUB TWPartition::Wipe_FAT\n"); |
| 147 | return 1; |
| 148 | } |
| 149 | |
| 150 | bool TWPartition::Wipe_YAFFS2() { |
| 151 | LOGI("STUB TWPartition::Wipe_YAFFS2\n"); |
| 152 | return 1; |
| 153 | } |
| 154 | |
| 155 | bool TWPartition::Wipe_RMRF() { |
| 156 | LOGI("STUB TWPartition::Wipe_RMRF\n"); |
| 157 | return 1; |
| 158 | } |
| 159 | |
| 160 | bool TWPartition::Wipe_Data_Without_Wiping_Media() { |
| 161 | LOGI("STUB TWPartition::Wipe_Data_Without_Wiping_Media\n"); |
| 162 | return 1; |
| 163 | } |
| 164 | |
| 165 | bool TWPartition::Backup_Tar(string backup_folder) { |
| 166 | LOGI("STUB TWPartition::Backup_Tar, backup_folder: '%s'\n", backup_folder.c_str()); |
| 167 | return 1; |
| 168 | } |
| 169 | |
| 170 | bool TWPartition::Backup_DD(string backup_folder) { |
| 171 | LOGI("STUB TWPartition::Backup_DD, backup_folder: '%s'\n", backup_folder.c_str()); |
| 172 | return 1; |
| 173 | } |
| 174 | |
| 175 | bool TWPartition::Backup_Dump_Image(string backup_folder) { |
| 176 | LOGI("STUB TWPartition::Backup_Dump_Image, backup_folder: '%s'\n", backup_folder.c_str()); |
| 177 | return 1; |
| 178 | } |
| 179 | |
| 180 | bool TWPartition::Restore_Tar(string restore_folder) { |
| 181 | LOGI("STUB TWPartition::Restore_Tar, backup_folder: '%s'\n", restore_folder.c_str()); |
| 182 | return 1; |
| 183 | } |
| 184 | |
| 185 | bool TWPartition::Restore_DD(string restore_folder) { |
| 186 | LOGI("STUB TWPartition::Restore_DD, backup_folder: '%s'\n", restore_folder.c_str()); |
| 187 | return 1; |
| 188 | } |
| 189 | |
| 190 | bool TWPartition::Restore_Flash_Image(string restore_folder) { |
| 191 | LOGI("STUB TWPartition::Restore_Flash_Image, backup_folder: '%s'\n", restore_folder.c_str()); |
| 192 | return 1; |
| 193 | } |