diff --git a/program.c b/program.c index 1e3cd9f..6d988d6 100644 --- a/program.c +++ b/program.c @@ -278,6 +278,27 @@ int program_find_bootable_partition(bool *multiple_found) return part; } +/** + * program_is_sec_partition_flashed() - find if secdata partition is flashed + * + * Returns true if filename for secdata is set in program*.xml, + * or false otherwise. + */ +int program_is_sec_partition_flashed(void) +{ + struct program *program; + + program = program_find_partition("secdata"); + if (!program) + return false; + + if (program->filename) + return true; + + return false; +} + + void free_programs(void) { struct program *program = programes; diff --git a/program.h b/program.h index a17f556..f8f178f 100644 --- a/program.h +++ b/program.h @@ -26,6 +26,8 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, const char *incdir, bool allow_missing); int erase_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program)); int program_find_bootable_partition(bool *multiple_found); +int program_is_sec_partition_flashed(void); + void free_programs(void); #endif diff --git a/qdl.c b/qdl.c index 7fa2f85..74a637a 100644 --- a/qdl.c +++ b/qdl.c @@ -40,6 +40,7 @@ #include "qdl.h" #include "patch.h" +#include "program.h" #include "ufs.h" #include "oscompat.h" @@ -124,6 +125,7 @@ int main(int argc, char **argv) int ret; int opt; bool qdl_finalize_provisioning = false; + bool allow_fusing = false; bool allow_missing = false; long out_chunk_size; @@ -136,6 +138,7 @@ int main(int argc, char **argv) {"serial", required_argument, 0, 'S'}, {"storage", required_argument, 0, 's'}, {"allow-missing", no_argument, 0, 'f'}, + {"allow-fusing", no_argument, 0, 'c'}, {0, 0, 0, 0} }; @@ -156,6 +159,9 @@ int main(int argc, char **argv) case 'l': qdl_finalize_provisioning = true; break; + case 'c': + allow_fusing = true; + break; case OPT_OUT_CHUNK_SIZE: out_chunk_size = strtol(optarg, NULL, 10); qdl_set_out_chunk_size(&qdl, out_chunk_size); @@ -200,6 +206,10 @@ int main(int argc, char **argv) ret = program_load(argv[optind], !strcmp(storage, "nand")); if (ret < 0) errx(1, "program_load %s failed", argv[optind]); + + if (!allow_fusing && program_is_sec_partition_flashed()) + errx(1, "secdata partition to be programmed, which can lead to irreversible" + " changes. Allow explicitly with --allow-fusing parameter"); break; case QDL_FILE_READ: ret = read_op_load(argv[optind]);