diff options
author | Cylen Yao <cylen.yao@mediatek.com> | 2014-05-12 23:29:42 +0800 |
---|---|---|
committer | Todd Poynor <toddpoynor@google.com> | 2014-05-15 18:30:59 +0000 |
commit | 5e0db82858387ba8c529a8fbc667a58b29b79706 (patch) | |
tree | d07ec6f158f7fedc7fb20ec8a7f30c62f04e03a3 /libdiskconfig | |
parent | 8c56cebd4450d5149828216291eb70d4d53aeb2b (diff) | |
download | system_core-5e0db82858387ba8c529a8fbc667a58b29b79706.zip system_core-5e0db82858387ba8c529a8fbc667a58b29b79706.tar.gz system_core-5e0db82858387ba8c529a8fbc667a58b29b79706.tar.bz2 |
libdiskconfig: set MBR signature when creating MBR
When formatting a blank SD card, it needs to set MBR signature when creating MBR.
If not, the 'format' operation will fail.
Change-Id: I860731243797d4da83f370af52822536983009ee
Signed-off-by: Cylen Yao <cylen.yao@mediatek.com>
Diffstat (limited to 'libdiskconfig')
-rw-r--r-- | libdiskconfig/config_mbr.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libdiskconfig/config_mbr.c b/libdiskconfig/config_mbr.c index 7641b29..82d0066 100644 --- a/libdiskconfig/config_mbr.c +++ b/libdiskconfig/config_mbr.c @@ -208,6 +208,26 @@ fail: } +static struct write_list * +mk_mbr_sig() +{ + struct write_list *item; + if (!(item = alloc_wl(sizeof(uint16_t)))) { + ALOGE("Unable to allocate memory for MBR signature."); + return NULL; + } + + { + /* DO NOT DEREFERENCE */ + struct pc_boot_record *mbr = (void *)PC_MBR_DISK_OFFSET; + /* grab the offset in mbr where to write mbr signature. */ + item->offset = (loff_t)((uint32_t)((uint8_t *)(&mbr->mbr_sig))); + } + + *((uint16_t*)item->data) = PC_BIOS_BOOT_SIG; + return item; +} + struct write_list * config_mbr(struct disk_info *dinfo) { @@ -276,6 +296,13 @@ config_mbr(struct disk_info *dinfo) wlist_add(&wr_list, temp_wr); } + if ((temp_wr = mk_mbr_sig())) + wlist_add(&wr_list, temp_wr); + else { + ALOGE("Cannot set MBR signature"); + goto fail; + } + return wr_list; nospace: |