From 66b6098d32b92964da95ecb51694474c8bd292dd Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Mon, 22 Aug 2016 17:23:58 +0200 Subject: [PATCH] MTK ramdisk: Specify whether ramdisk is for boot.img or recovery.img --- jni/extract.c | 7 +++++++ jni/repack.c | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jni/extract.c b/jni/extract.c index 393e2140c..3a8edf56a 100644 --- a/jni/extract.c +++ b/jni/extract.c @@ -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 { diff --git a/jni/repack.c b/jni/repack.c index ab6febbc1..c97fae73d 100644 --- a/jni/repack.c +++ b/jni/repack.c @@ -39,7 +39,13 @@ int append_ramdisk(int ofd, off_t pos) { //TODO: RECOVERY OR ROOTFS? char str[32]; memset(str, 0, sizeof(str)); - strcpy(str, "ROOTFS"); + 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));