From bea646deee644f24384caf321fb497dd530ba2f0 Mon Sep 17 00:00:00 2001 From: Matt Mower Date: Wed, 9 Jul 2014 11:50:05 -0500 Subject: Do not wipe block misc on bootloader msg update When set_bootloader_message_block() is called, it fopens /misc in write binary mode, wiping all contents other than what is being written. The bootloader msg structure is only 1024+32+32 bytes, so some manufacturers store more than just a bootloader msg on /misc. fopen in read+append mode so that only the bootloader msg is written and the rest of the partition is left untouched. Change-Id: I2d2fbdf067282744864a19d404ca7dc12f688a98 --- bootloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootloader.cpp b/bootloader.cpp index 779ae1b..dec296f 100644 --- a/bootloader.cpp +++ b/bootloader.cpp @@ -185,7 +185,7 @@ static int get_bootloader_message_block(struct bootloader_message *out, static int set_bootloader_message_block(const struct bootloader_message *in, const Volume* v) { wait_for_device(v->blk_device); - FILE* f = fopen(v->blk_device, "wb"); + FILE* f = fopen(v->blk_device, "rb+"); if (f == NULL) { LOGE("Can't open %s\n(%s)\n", v->blk_device, strerror(errno)); return -1; -- cgit v1.1