readd ext2/ext3 format support.
Change-Id: I58652abaea8f7a52b70bc1b14aec5b530fe70382
This commit is contained in:
		| @@ -390,8 +390,69 @@ int confirm_selection(const char* title, const char* confirm) | ||||
|     return chosen_item == 7; | ||||
| } | ||||
|  | ||||
| int format_unknown_device(const char* path) | ||||
| #define MKE2FS_BIN      "/sbin/mke2fs" | ||||
| #define TUNE2FS_BIN     "/sbin/tune2fs" | ||||
| #define E2FSCK_BIN      "/sbin/e2fsck" | ||||
|  | ||||
| static int | ||||
| format_ext3_device (const char *device) { | ||||
|     // Run mke2fs | ||||
|     char *const mke2fs[] = {MKE2FS_BIN, "-j", device, NULL}; | ||||
|     if(run_exec_process(mke2fs)) | ||||
|         return -1; | ||||
|  | ||||
|     // Run tune2fs | ||||
|     char *const tune2fs[] = {TUNE2FS_BIN, "-j", "-C", "1", device, NULL}; | ||||
|     if(run_exec_process(tune2fs)) | ||||
|         return -1; | ||||
|  | ||||
|     // Run e2fsck | ||||
|     char *const e2fsck[] = {E2FSCK_BIN, "-fy", device, NULL}; | ||||
|     if(run_exec_process(e2fsck)) | ||||
|         return -1; | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| static int | ||||
| format_ext2_device (const char *device) { | ||||
|     // Run mke2fs | ||||
|     char *const mke2fs[] = {MKE2FS_BIN, device, NULL}; | ||||
|     if(run_exec_process(mke2fs)) | ||||
|         return -1; | ||||
|  | ||||
|     // Run tune2fs | ||||
|     char *const tune2fs[] = {TUNE2FS_BIN, "-C", "1", device, NULL}; | ||||
|     if(run_exec_process(tune2fs)) | ||||
|         return -1; | ||||
|  | ||||
|     // Run e2fsck | ||||
|     char *const e2fsck[] = {E2FSCK_BIN, "-fy", device, NULL}; | ||||
|     if(run_exec_process(e2fsck)) | ||||
|         return -1; | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| int format_unknown_device(const char *device, const char* path, const char *fs_type) | ||||
| { | ||||
|     // device may simply be a name, like "system" | ||||
|     if (device[0] != '/') | ||||
|         return erase_partition(device, fs_type); | ||||
|      | ||||
|     if (strcmp("ext3", device) == 0) { | ||||
|         if (0 != ensure_path_unmounted(path)) | ||||
|             return -11; | ||||
|         return format_ext3_device(device); | ||||
|     } | ||||
|      | ||||
|     if (strcmp("ext2", device) == 0) { | ||||
|         if (0 != ensure_path_unmounted(path)) | ||||
|             return -12; | ||||
|         return format_ext2_device(device); | ||||
|     } | ||||
|  | ||||
|     // if this is SDEXT:, don't worry about it. | ||||
|     if (0 == strcmp(path, "/sd-ext")) | ||||
|     { | ||||
|   | ||||
| @@ -37,8 +37,7 @@ __system(const char *command); | ||||
| void | ||||
| show_advanced_menu(); | ||||
|  | ||||
| int | ||||
| format_unknown_device(const char* root); | ||||
| int format_unknown_device(const char *device, const char* path, const char *fs_type); | ||||
|  | ||||
| void | ||||
| wipe_battery_stats(); | ||||
|   | ||||
| @@ -299,7 +299,7 @@ mmc_find_partition_by_name(const char *name) | ||||
| #define TUNE2FS_BIN     "/sbin/tune2fs" | ||||
| #define E2FSCK_BIN      "/sbin/e2fsck" | ||||
|  | ||||
| static int | ||||
| int | ||||
| run_exec_process ( char **argv) { | ||||
|     pid_t pid; | ||||
|     int status; | ||||
|   | ||||
							
								
								
									
										3
									
								
								roots.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								roots.c
									
									
									
									
									
								
							| @@ -217,7 +217,8 @@ int format_volume(const char* volume) { | ||||
|         LOGE("can't give path \"%s\" to format_volume\n", volume); | ||||
|         return -1; | ||||
| #endif | ||||
|         return format_unknown_device(volume); | ||||
|         printf("Formatting volume %s of fs type %s\n", volume, v->fs_type); | ||||
|         return format_unknown_device(v->device, volume, v->fs_type); | ||||
|     } | ||||
|  | ||||
|     if (ensure_path_unmounted(volume) != 0) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user