int cow_bitmap_size;
int cow_fd;
int64_t cow_sectors_offset;
+ int boot_sector_enabled;
+ uint8_t boot_sector_data[512];
+
char filename[1024];
};
if (is_changed(bs->cow_bitmap, sector_num, nb_sectors, &n)) {
fd = bs->cow_fd;
offset = bs->cow_sectors_offset;
+ } else if (sector_num == 0 && bs->boot_sector_enabled) {
+ memcpy(buf, bs->boot_sector_data, 512);
+ n = 1;
+ goto next;
} else {
fd = bs->fd;
offset = 0;
return -1;
}
}
+ next:
nb_sectors -= n;
sector_num += n;
buf += n * 512;
{
int ret, fd, i;
int64_t offset, retl;
-
+
if (bs->read_only)
return -1;
{
*nb_sectors_ptr = bs->total_sectors;
}
+
+/* force a given boot sector. */
+void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size)
+{
+ bs->boot_sector_enabled = 1;
+ if (size > 512)
+ size = 512;
+ memcpy(bs->boot_sector_data, data, size);
+ memset(bs->boot_sector_data + size, 0, 512 - size);
+}