summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCylen Yao2014-05-12 10:29:42 -0500
committerTodd Poynor2014-05-15 13:30:59 -0500
commit5e0db82858387ba8c529a8fbc667a58b29b79706 (patch)
treed07ec6f158f7fedc7fb20ec8a7f30c62f04e03a3 /libdiskconfig
parent8c56cebd4450d5149828216291eb70d4d53aeb2b (diff)
downloadplatform-system-core-5e0db82858387ba8c529a8fbc667a58b29b79706.tar.gz
platform-system-core-5e0db82858387ba8c529a8fbc667a58b29b79706.tar.xz
platform-system-core-5e0db82858387ba8c529a8fbc667a58b29b79706.zip
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.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libdiskconfig/config_mbr.c b/libdiskconfig/config_mbr.c
index 7641b29e2..82d006622 100644
--- a/libdiskconfig/config_mbr.c
+++ b/libdiskconfig/config_mbr.c
@@ -208,6 +208,26 @@ fail:
208} 208}
209 209
210 210
211static struct write_list *
212mk_mbr_sig()
213{
214 struct write_list *item;
215 if (!(item = alloc_wl(sizeof(uint16_t)))) {
216 ALOGE("Unable to allocate memory for MBR signature.");
217 return NULL;
218 }
219
220 {
221 /* DO NOT DEREFERENCE */
222 struct pc_boot_record *mbr = (void *)PC_MBR_DISK_OFFSET;
223 /* grab the offset in mbr where to write mbr signature. */
224 item->offset = (loff_t)((uint32_t)((uint8_t *)(&mbr->mbr_sig)));
225 }
226
227 *((uint16_t*)item->data) = PC_BIOS_BOOT_SIG;
228 return item;
229}
230
211struct write_list * 231struct write_list *
212config_mbr(struct disk_info *dinfo) 232config_mbr(struct disk_info *dinfo)
213{ 233{
@@ -276,6 +296,13 @@ config_mbr(struct disk_info *dinfo)
276 wlist_add(&wr_list, temp_wr); 296 wlist_add(&wr_list, temp_wr);
277 } 297 }
278 298
299 if ((temp_wr = mk_mbr_sig()))
300 wlist_add(&wr_list, temp_wr);
301 else {
302 ALOGE("Cannot set MBR signature");
303 goto fail;
304 }
305
279 return wr_list; 306 return wr_list;
280 307
281nospace: 308nospace: