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
This commit is contained in:
Matt Mower
2014-07-09 11:50:05 -05:00
committed by Gerrit Code Review
parent 62ba6526b7
commit 2fec60a5dc

View File

@@ -275,7 +275,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;
@@ -317,7 +317,7 @@ int get_bootloader_message_block_name(struct bootloader_message *out) {
int set_bootloader_message_block_name(const struct bootloader_message *in,
const char* block_name) {
wait_for_device(block_name);
FILE* f = fopen(block_name, "wb");
FILE* f = fopen(block_name, "rb+");
if (f == NULL) {
printf("Can't open %s\n(%s)\n", block_name, strerror(errno));
return -1;