summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 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: