Flush on writes to hard disk images, fixes partition creation on the Samsung SPC7700LP-W.

This commit is contained in:
OBattler
2024-09-24 04:32:46 +02:00
parent f2eb6a0161
commit 8c705b4ad1
2 changed files with 11 additions and 0 deletions

View File

@@ -577,6 +577,7 @@ hdd_image_write(uint8_t id, uint32_t sector, uint32_t count, uint8_t *buffer)
}
num_write = fwrite(buffer, 512, count, hdd_images[id].file);
fflush(hdd_images[id].file);
hdd_images[id].pos = sector + num_write;
}
}
@@ -618,6 +619,8 @@ hdd_image_zero(uint8_t id, uint32_t sector, uint32_t count)
hdd_images[id].pos = sector + i;
fwrite(empty_sector, 512, 1, hdd_images[id].file);
}
fflush(hdd_images[id].file);
}
}

View File

@@ -89,6 +89,8 @@ mvhd_write_empty_sectors(FILE *f, int sector_count)
for (int i = 0; i < sector_count; i++)
fwrite(zero_bytes, sizeof zero_bytes, 1, f);
fflush(f);
}
/**
@@ -141,6 +143,7 @@ write_bat_entry(MVHDMeta *vhdm, int blk)
mvhd_fseeko64(vhdm->f, table_offset, SEEK_SET);
fwrite(&offset, sizeof offset, 1, vhdm->f);
fflush(vhdm->f);
}
/**
@@ -197,6 +200,8 @@ create_block(MVHDMeta *vhdm, int blk)
/* We no longer have a sparse block. Update that BAT! */
vhdm->block_offset[blk] = sect_offset;
write_bat_entry(vhdm, blk);
fflush(vhdm->f);
}
int
@@ -317,6 +322,7 @@ mvhd_fixed_write(MVHDMeta *vhdm, uint32_t offset, int num_sectors, void *in_buff
addr = (int64_t)offset * MVHD_SECTOR_SIZE;
mvhd_fseeko64(vhdm->f, addr, SEEK_SET);
fwrite(in_buff, transfer_sectors * MVHD_SECTOR_SIZE, 1, vhdm->f);
fflush(vhdm->f);
return truncated_sectors;
}
@@ -376,6 +382,8 @@ mvhd_sparse_diff_write(MVHDMeta *vhdm, uint32_t offset, int num_sectors, void *i
/* And write the sector bitmap for the last block we visited to disk */
write_curr_sect_bitmap(vhdm);
fflush(vhdm->f);
return truncated_sectors;
}