Added a -V option to a VHD copy operation to cause a verify pass which will confirm all of the expected data has made it to the target virtual disk
This commit is contained in:
parent
a78c978f96
commit
5727ad1a27
1 changed files with 56 additions and 1 deletions
57
sim_disk.c
57
sim_disk.c
|
@ -920,6 +920,59 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
|
|||
else
|
||||
printf ("\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r));
|
||||
}
|
||||
if ((r == SCPE_OK) && (sim_switches & SWMASK ('V'))) {
|
||||
uint8 *verify_buf = (uint8*) malloc (1024*1024);
|
||||
|
||||
if (!verify_buf) {
|
||||
sim_vhd_disk_close(vhd);
|
||||
remove (gbuf);
|
||||
free (copy_buf);
|
||||
return SCPE_MEM;
|
||||
}
|
||||
for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) {
|
||||
if (!sim_quiet)
|
||||
printf ("%s%d: Verified %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
|
||||
sects = sectors_per_buffer;
|
||||
if (lba + sects > total_sectors)
|
||||
sects = total_sectors - lba;
|
||||
r = sim_disk_rdsect (uptr, lba, copy_buf, NULL, sects);
|
||||
if (r == SCPE_OK) {
|
||||
uint32 saved_unit_flags = uptr->flags;
|
||||
FILE *save_unit_fileref = uptr->fileref;
|
||||
|
||||
sim_disk_set_fmt (uptr, 0, "VHD", NULL);
|
||||
uptr->fileref = vhd;
|
||||
r = sim_disk_rdsect (uptr, lba, verify_buf, NULL, sects);
|
||||
uptr->fileref = save_unit_fileref;
|
||||
uptr->flags = saved_unit_flags;
|
||||
if (r == SCPE_OK) {
|
||||
if (0 != memcmp (copy_buf, verify_buf, 1024*1024))
|
||||
r = SCPE_IOERR;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sim_quiet) {
|
||||
if (r == SCPE_OK)
|
||||
printf ("\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
|
||||
else {
|
||||
t_lba i;
|
||||
uint32 save_dctrl = dptr->dctrl;
|
||||
FILE *save_sim_deb = sim_deb;
|
||||
|
||||
for (i = 0; i < (1024*1024/sector_size); ++i)
|
||||
if (0 != memcmp (copy_buf+i*sector_size, verify_buf+i*sector_size, sector_size))
|
||||
break;
|
||||
printf ("\n%s%d: Verification Error on lbn %d.\n", sim_dname (dptr), (int)(uptr-dptr->units), lba+i);
|
||||
dptr->dctrl = 0xFFFFFFFF;
|
||||
sim_deb = stdout;
|
||||
sim_disk_data_trace (uptr, copy_buf+i*sector_size, lba+i, sector_size, "Expected", TRUE, 1);
|
||||
sim_disk_data_trace (uptr, verify_buf+i*sector_size, lba+i, sector_size, "Found", TRUE, 1);
|
||||
dptr->dctrl = save_dctrl;
|
||||
sim_deb = save_sim_deb;
|
||||
}
|
||||
}
|
||||
free (verify_buf);
|
||||
}
|
||||
free (copy_buf);
|
||||
sim_vhd_disk_close (vhd);
|
||||
sim_disk_detach (uptr);
|
||||
|
@ -1203,7 +1256,9 @@ fprintf (st, " -F Open the indicated disk container in a specific fo
|
|||
fprintf (st, " is to autodetect VHD defaulting to simh if the indicated\n");
|
||||
fprintf (st, " container is not a VHD).\n");
|
||||
fprintf (st, " -C Create a VHD and copy its contents from another disk (simh, VHD,\n");
|
||||
fprintf (st, " or RAW format).\n");
|
||||
fprintf (st, " or RAW format). Add a -V switch to verify a copy operation.\n");
|
||||
fprintf (st, " -V Perform a verification pass to confirm successful data copy\n");
|
||||
fprintf (st, " operation.\n");
|
||||
fprintf (st, " -X When creating a VHD, create a fixed sized VHD (vs a Dynamically\n");
|
||||
fprintf (st, " expanding one).\n");
|
||||
fprintf (st, " -D Create a Differencing VHD (relative to an already existing VHD\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue