summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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..7b6ca1c65 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)((uintptr_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: