pmt: apply version 1.7.0 changes

This commit is contained in:
2024-04-09 23:46:15 +03:00
committed by GitHub
parent a2aee5c5e8
commit 0b34fdbfd9

View File

@@ -1,13 +1,3 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <stdbool.h>
#include <stddef.h>
#include "include/common.h"
/* By YZBruh */ /* By YZBruh */
/* /*
@@ -26,8 +16,22 @@
* limitations under the License. * limitations under the License.
*/ */
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <stdbool.h>
#include "include/pmt.h"
extern char *cust_cxt; extern char *cust_cxt;
extern bool use_cust_cxt; extern bool pmt_use_cust_cxt;
extern bool pmt_force_mode;
/* flasher func */ /* flasher func */
void flash(char *target_flash_partition, char *target_file, char *flash_partition_style) void flash(char *target_flash_partition, char *target_file, char *flash_partition_style)
@@ -36,7 +40,7 @@ void flash(char *target_flash_partition, char *target_file, char *flash_partitio
/* determine device block */ /* determine device block */
/* for classic */ /* for classic */
if (strstr(flash_partition_style, "classic") != NULL) { if (strstr(flash_partition_style, "classic") != NULL) {
if (use_cust_cxt) { if (pmt_use_cust_cxt) {
sprintf(flasher_path, "%s/%s", cust_cxt, target_flash_partition); sprintf(flasher_path, "%s/%s", cust_cxt, target_flash_partition);
} else { } else {
sprintf(flasher_path, "/dev/block/by-name/%s", target_flash_partition); sprintf(flasher_path, "/dev/block/by-name/%s", target_flash_partition);
@@ -45,14 +49,20 @@ void flash(char *target_flash_partition, char *target_file, char *flash_partitio
} else if (strstr(flash_partition_style, "logical") != NULL) { } else if (strstr(flash_partition_style, "logical") != NULL) {
sprintf(flasher_path, "/dev/block/mapper/%s", target_flash_partition); sprintf(flasher_path, "/dev/block/mapper/%s", target_flash_partition);
} else { } else {
error("İnvalid partition type!\n"); if (!pmt_force_mode) {
error("İnvalid partition type!\n", 30);
} else {
exit(30);
}
} }
/* check partition */ /* check partition */
if (access(flasher_path, F_OK) == -1) { if (access(flasher_path, F_OK) == -1) {
error("Partition not found!\n"); if (!pmt_force_mode) {
} else { error("Partition not found!\n", 31);
printf("Target partition: %s\nFlashing...\n", target_flash_partition); } else {
exit(31);
}
} }
/* setting up */ /* setting up */
@@ -61,10 +71,16 @@ void flash(char *target_flash_partition, char *target_file, char *flash_partitio
/* start flash */ /* start flash */
if (system(flasher_cmd) != 0) { if (system(flasher_cmd) != 0) {
error("Failed!\n"); if (!pmt_force_mode) {
} else { error("Failed!\n", 98);
printf("%sSuccess.%s\n", ANSI_GREEN, ANSI_RESET); } else {
exit(98);
}
} }
} }
#ifdef __cplusplus
}
#endif
/* end of code */ /* end of code */