MTK ramdisk: Specify whether ramdisk is for boot.img or recovery.img

This commit is contained in:
Pierre-Hugues Husson 2016-08-22 17:23:58 +02:00 committed by topjohnwu
parent 348bc1d0fc
commit 66b6098d32
2 changed files with 14 additions and 1 deletions

View File

@ -27,6 +27,13 @@ void dump_ramdisk(uint8_t *ptr, size_t size) {
dump(ptr, size, "ramdisk.gz");
//MTK header
} else if(memcmp(ptr, "\x88\x16\x88\x58", 4) == 0) {
if(memcmp(ptr+4, "RECOVERY", 8)==0) {
dump(ptr, 0, "ramdisk-mtk-recovery");
} else if(memcmp(ptr+4, "ROOTFS\0\0", 8)==0) {
dump(ptr, 0, "ramdisk-mtk-boot");
} else {
exit(1);
}
dump(ptr, 0, "ramdisk-mtk"); //Create an mtk flag
dump_ramdisk(ptr+512, size-512);
} else {

View File

@ -39,7 +39,13 @@ int append_ramdisk(int ofd, off_t pos) {
//TODO: RECOVERY OR ROOTFS?
char str[32];
memset(str, 0, sizeof(str));
if(access("ramdisk-mtk-boot", R_OK)==0) {
strcpy(str, "ROOTFS");
} else if(access("ramdisk-mtk-recovery", R_OK)==0) {
strcpy(str, "RECOVERY");
} else {
exit(1);
}
memcpy(buf+8, str, sizeof(str));
memset(buf+8+sizeof(str), 0xff, 512-8-sizeof(str));