1
0
mirror of https://github.com/simh/simh.git synced 2026-01-26 04:01:38 +00:00

SCP: Provide command context for messages emitted during ATTACH and DETACH

Context and non error messages will be suppressed in quiet mode or when -Q
switch is explicitly supplied on command line
This commit is contained in:
Mark Pizzolato
2017-10-22 08:33:21 -07:00
parent 5b248cf7f4
commit 3d1f092573
4 changed files with 39 additions and 68 deletions

View File

@@ -1362,9 +1362,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
sim_switches = saved_sim_switches;
return sim_messagef (r, "Can't open source VHD: %s\n", cptr);
}
if (!sim_quiet) {
sim_printf ("%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
}
sim_messagef (SCPE_OK, "%s%d: creating new virtual disk '%s'\n", sim_dname (dptr), (int)(uptr-dptr->units), gbuf);
capac_factor = ((dptr->dwidth / dptr->aincr) == 16) ? 2 : 1; /* capacity units (word: 2, byte: 1) */
vhd = sim_vhd_disk_create (gbuf, ((t_offset)uptr->capac)*capac_factor*((dptr->flags & DEV_SECTORS) ? 512 : 1));
if (!vhd) {
@@ -1383,8 +1381,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
return SCPE_MEM;
}
for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) {
if (!sim_quiet)
sim_printf ("%s%d: Copied %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
sim_messagef (SCPE_OK, "%s%d: Copied %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;
@@ -1400,12 +1397,10 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
uptr->flags = saved_unit_flags;
}
}
if (!sim_quiet) {
if (r == SCPE_OK)
sim_printf ("\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
else
sim_printf ("\n%s%d: Error copying: %s.\n", sim_dname (dptr), (int)(uptr-dptr->units), sim_error_text (r));
}
if (r == SCPE_OK)
sim_messagef (SCPE_OK, "\n%s%d: Copied %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
else
sim_messagef (r, "\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);
@@ -1416,8 +1411,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
return SCPE_MEM;
}
for (lba = 0; (lba < total_sectors) && (r == SCPE_OK); lba += sects) {
if (!sim_quiet)
sim_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));
sim_messagef (SCPE_OK, "%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;
@@ -1439,7 +1433,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop
}
if (!sim_quiet) {
if (r == SCPE_OK)
sim_printf ("\n%s%d: Verified %dMB. Done.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)(((t_offset)lba*sector_size)/1000000));
sim_messagef (r, "\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;
@@ -1544,9 +1538,7 @@ if ((sim_switches & SWMASK ('R')) || /* read only? */
if (uptr->fileref == NULL) /* open fail? */
return _err_return (uptr, SCPE_OPENERR); /* yes, error */
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
if (!sim_quiet) {
sim_printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
}
sim_messagef (SCPE_OK, "%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
}
else { /* normal */
uptr->fileref = open_function (cptr, "rb+"); /* open r/w */
@@ -1558,8 +1550,7 @@ else { /* normal */
if (uptr->fileref == NULL) /* open fail? */
return _err_return (uptr, SCPE_OPENERR);/* yes, error */
uptr->flags = uptr->flags | UNIT_RO; /* set rd only */
if (!sim_quiet)
sim_printf ("%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
sim_messagef (SCPE_OK, "%s%d: unit is read only\n", sim_dname (dptr), (int)(uptr-dptr->units));
}
else { /* doesn't exist */
if (sim_switches & SWMASK ('E')) /* must exist? */
@@ -1570,8 +1561,7 @@ else { /* normal */
uptr->fileref = open_function (cptr, "wb+");/* open new file */
if (uptr->fileref == NULL) /* open fail? */
return _err_return (uptr, SCPE_OPENERR);/* yes, error */
if (!sim_quiet)
sim_printf ("%s%d: creating new file\n", sim_dname (dptr), (int)(uptr-dptr->units));
sim_messagef (SCPE_OK, "%s%d: creating new file\n", sim_dname (dptr), (int)(uptr-dptr->units));
created = TRUE;
}
} /* end if null */
@@ -1655,11 +1645,9 @@ if ((created) && (!copied)) {
(void)remove (cptr); /* remove the created file */
return SCPE_OPENERR;
}
if (!sim_quiet)
sim_printf ("%s%d: Initialized To Sector Address %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
sim_messagef (SCPE_OK, "%s%d: Initialized To Sector Address %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
}
if (!sim_quiet)
sim_printf ("%s%d: Initialized To Sector Address %dMB. 100%% complete.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000));
sim_messagef (SCPE_OK, "%s%d: Initialized To Sector Address %dMB. 100%% complete.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000));
free (init_buf);
}
if (pdp11tracksize)
@@ -1708,11 +1696,9 @@ if (sim_switches & SWMASK ('K')) {
}
}
}
if (!sim_quiet)
sim_printf ("%s%d: Verified containing Sector Address %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
sim_messagef (SCPE_OK, "%s%d: Verified containing Sector Address %dMB. %d%% complete.\r", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000), (int)((((float)lba)*100)/total_sectors));
}
if (!sim_quiet)
sim_printf ("%s%d: Verified containing Sector Address %dMB. 100%% complete.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000));
sim_messagef (SCPE_OK, "%s%d: Verified containing Sector Address %dMB. 100%% complete.\n", sim_dname (dptr), (int)(uptr-dptr->units), (int)((((float)lba)*sector_size)/1000000));
free (verify_buf);
uptr->dynflags |= UNIT_DISK_CHK;
}
@@ -3643,8 +3629,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
continue;
++BlocksToMerge;
}
if (!sim_quiet)
sim_printf ("Merging %s\ninto %s\n", szVHDPath, hVHD->ParentVHDPath);
sim_messagef (SCPE_OK, "Merging %s\ninto %s\n", szVHDPath, hVHD->ParentVHDPath);
for (BlockNumber=NeededBlock=0; BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries); ++BlockNumber) {
uint32 BlockSectors = SectorsPerBlock;
@@ -3667,8 +3652,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
SectorSize,
SectorsPerBlock*BlockNumber))
break;
if (!sim_quiet)
sim_printf ("Merged %dMB. %d%% complete.\r", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000), (int)((((float)NeededBlock)*100)/BlocksToMerge));
sim_messagef (SCPE_OK, "Merged %dMB. %d%% complete.\r", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000), (int)((((float)NeededBlock)*100)/BlocksToMerge));
hVHD->BAT[BlockNumber] = VHD_BAT_FREE_ENTRY;
}
if (BlockNumber < NtoHl (hVHD->Dynamic.MaxTableEntries)) {
@@ -3676,8 +3660,7 @@ static FILE *sim_vhd_disk_merge (const char *szVHDPath, char **ParentVHD)
}
else {
Status = 0;
if (!sim_quiet)
sim_printf ("Merged %dMB. 100%% complete.\n", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000));
sim_messagef (SCPE_OK, "Merged %dMB. 100%% complete.\n", (int)((((float)NeededBlock)*SectorsPerBlock)*SectorSize/1000000));
fclose (hVHD->File);
hVHD->File = NULL;
(void)remove (szVHDPath);