Added assortment of empty diskettes to library, and updated DiskDump to support a target disk size (--size replaces the older, kludgier --mbhd)

This commit is contained in:
Jeff Parsons 2016-03-28 17:08:15 -07:00
commit f81e55f0ee
10 changed files with 68 additions and 15 deletions

View file

@ -3,6 +3,10 @@
<control type="list" binding="listDrives"/>
<control type="list" binding="listDisks">
<disk path="">None</disk>
<disk path="/disks/pc/empty/EMPTY-360K.json">Empty Diskette (360K)</disk>
<disk path="/disks/pc/empty/EMPTY-720K.json">Empty Diskette (720K)</disk>
<disk path="/disks/pc/empty/EMPTY-1200K.json">Empty Diskette (1200K)</disk>
<disk path="/disks/pc/empty/EMPTY-1440K.json">Empty Diskette (1440K)</disk>
<disk path="/disks/pc/cpm/1.1b/CPM86-DISK1.json">CP/M-86 (Disk 1)</disk>
<disk path="/disks/pc/cpm/1.1b/CPM86-DISK2.json">CP/M-86 (Disk 2)</disk>
<disk path="/disks/pc/diags/ibm/1.02/5150_ADVDIAG_102.json">IBM PC Diagnostics 1.02</disk>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/versions/pcjs/1.21.4/manifest.xsl"?>
<manifest type="software">
<title>Empty Diskettes</title>
<disk id="disk01" size="368640" chs="40:2:9" img="archive/EMPTY-360K.img" href="/disks/pc/empty/EMPTY-360K.json" md5="0eb5e6f6353fc8ad26b6797d70b68db3" md5json="7c921c4a1f4c593450fcec3d2c31be12">
<name>Empty Diskette (360K)</name>
</disk>
<disk id="disk02" size="737280" chs="80:2:9" img="archive/EMPTY-720K.img" href="/disks/pc/empty/EMPTY-720K.json" md5="47e1407b2db85a28bf2e09a382625931" md5json="fcc0bf088cd2c17a6e5ab914d3a2c00d">
<name>Empty Diskette (720K)</name>
</disk>
<disk id="disk03" size="1228800" chs="80:2:15" img="archive/EMPTY-1200K.img" href="/disks/pc/empty/EMPTY-1200K.json" md5="83a86afcd82f0aa926b550dee6dd184d" md5json="d10e2de81b1d49db2c7a0b551f8dc6a0">
<name>Empty Diskette (1200K)</name>
</disk>
<disk id="disk04" size="1474560" chs="80:2:18" img="archive/EMPTY-1440K.img" href="/disks/pc/empty/EMPTY-1440K.json" md5="d34cf1c8b2c8f77d90b612bb9796cd1c" md5json="aaa6577aceffa56b1e9e427719a341c8">
<name>Empty Diskette (1440K)</name>
</disk>
</manifest>

View file

@ -3,6 +3,7 @@
<control type="list" binding="listDrives"/>
<control type="list" binding="listDisks">
<disk path="">None</disk>
<manifest ref="/disks/pc/empty/manifest.xml"/>
<manifest ref="/disks/pc/cpm/1.1b/manifest.xml"/>
<manifest ref="/disks/pc/diags/ibm/manifest.xml"/>
<manifest ref="/disks/pc/dos/ibm/1.00/manifest.xml"/>

View file

@ -311,9 +311,6 @@ BufferPF.prototype.slice = function(start, end)
/**
* DiskDump()
*
* TODO: Honor the caller's mbHD size. At the moment, any hard disk request translates to 10Mb,
* since we rely on a "canned" BPB in aDefaultBPBs.
*
* TODO: If sServerRoot is set, make sure sDiskPath refers to something in either /apps/ or /disks/,
* to prevent random enumeration of other server resources.
*
@ -322,12 +319,12 @@ BufferPF.prototype.slice = function(start, end)
* @param {Array|null} [asExclude] contains filename exclusions, if any
* @param {string} [sFormat] is the output format, one of "json"|"data"|"hex"|"bytes"|"img"
* @param {boolean|string} [fComments] enables comments and other readability enhancements in the JSON output
* @param {string} [mbHD] specifies a hard disk size, in megabytes, when building a new image
* @param {string} [sSize] specifies a target disk size, in kilobytes, when building a new image
* @param {string|null} [sServerRoot]
* @param {string} [sManifestFile]
* @param {Object} [argv] optional (experimental) arguments, if any
*/
function DiskDump(sDiskPath, asExclude, sFormat, fComments, mbHD, sServerRoot, sManifestFile, argv)
function DiskDump(sDiskPath, asExclude, sFormat, fComments, sSize, sServerRoot, sManifestFile, argv)
{
/*
* I used to set this.sServerRoot to "sServerRoot || process.cwd()", but in reality, the
@ -341,7 +338,7 @@ function DiskDump(sDiskPath, asExclude, sFormat, fComments, mbHD, sServerRoot, s
this.sDiskPath = path.join(this.sServerRoot, sDiskPath);
}
this.asExclude = asExclude || DiskDump.asExclusions;
this.mbHD = mbHD? parseInt(mbHD, 10) : 0;
this.kbTarget = +sSize || 0;
this.sFormat = (sFormat || DumpAPI.FORMAT.JSON);
this.fJSONNative = (this.sFormat == DumpAPI.FORMAT.JSON && !fComments);
this.nJSONIndent = 0;
@ -458,6 +455,22 @@ DiskDump.aDefaultBPBs = [
0x02, 0x00, // 0x1A: number of heads (2)
0x00, 0x00, 0x00, 0x00 // 0x1C: number of hidden sectors (always 0 for non-partitioned media)
],
[ // define BPB for 720Kb diskette
0xEB, 0xFE, 0x90, // 0x00: JMP instruction, following by 8-byte OEM signature
0x50, 0x43, 0x4A, 0x53, 0x2E, 0x4F, 0x52, 0x47, // MY_OEM_STRING
// 0x49, 0x42, 0x4D, 0x20, 0x20, 0x35, 0x2E, 0x30, // "IBM 5.0" (this is a real OEM signature)
0x00, 0x02, // 0x0B: bytes per sector (0x200 or 512)
0x02, // 0x0D: sectors per cluster (2)
0x01, 0x00, // 0x0E: reserved sectors; ie, # sectors preceding the first FAT--usually just the boot sector (1)
0x02, // 0x10: FAT copies (2)
0x70, 0x00, // 0x11: root directory entries (0x70 or 112) 0x70 * 0x20 = 0xE00 (1 sector is 0x200 bytes, total of 7 sectors)
0xA0, 0x05, // 0x13: number of sectors (0x5A0 or 1440)
0xF9, // 0x15: media type
0x03, 0x00, // 0x16: sectors per FAT (3)
0x09, 0x00, // 0x18: sectors per track (9)
0x02, 0x00, // 0x1A: number of heads (2)
0x00, 0x00, 0x00, 0x00 // 0x1C: number of hidden sectors (always 0 for non-partitioned media)
],
[ // define BPB for 1.2Mb diskette
0xEB, 0xFE, 0x90, // 0x00: JMP instruction, following by 8-byte OEM signature
0x50, 0x43, 0x4A, 0x53, 0x2E, 0x4F, 0x52, 0x47, // MY_OEM_STRING
@ -543,7 +556,8 @@ DiskDump.asTextFileExts = [".MD", ".ME", ".ASM", ".BAS", ".TXT", ".XML"];
*
* Additional command-line arguments include:
*
* --mbhd={number}: requests a hard disk image with the given number of megabytes (eg, 10 for a 10mb image)
* --mbhd={number}: requests a hard disk image with the given number of megabytes (DEPRECATED)
* --size={number}: requests a target disk size with the given number of kilobytes (eg, 360, 720, 1200, 1440, 10000)
* --exclude={filename}: specifies a filename that should be excluded from the image; repeat as often as needed
* --overwrite: allows the --output option to overwrite an existing file; default is to NOT overwrite
* --manifest[={filename}]: update the specified manifest.xml file with details about the disk image
@ -625,7 +639,13 @@ DiskDump.CLI = function()
var sManifestTitle = argv['title'];
if (sDiskPath) {
var disk = new DiskDump(sDiskPath, asExclude, argv['format'], argv['comments'], argv['mbhd'], sServerRoot, sManifestFile, argv);
var sSize = argv['mbhd'];
if (!sSize) {
sSize = argv['size'];
} else {
sSize = (sSize * 1000).toString();
}
var disk = new DiskDump(sDiskPath, asExclude, argv['format'], argv['comments'], sSize, sServerRoot, sManifestFile, argv);
if (sDir) {
disk.buildImage(true, function(err) {
DiskDump.outputDisk(err, disk, sDiskPath, sOutputFile, fOverwrite, sManifestTitle);
@ -2246,7 +2266,8 @@ DiskDump.prototype.buildImageFromFiles = function(aFiles, done)
/*
* Put reasonable upper limits on both individual file sizes and the total size of all files.
*/
var cbMax = (this.mbHD? this.mbHD * 1024 * 1024 : 1440 * 1024);
var cbMax = (this.kbTarget || 1440) * 1024;
var nTargetSectors = (this.kbTarget? this.kbTarget * 2 : 0);
var cbTotal = this.calcFileSizes(aFiles);
if (fDebug) DiskDump.logConsole("total calculated size for " + aFiles.length + " files/folders: " + cbTotal + " bytes (0x" + str.toHex(cbTotal) + ")");
@ -2269,7 +2290,7 @@ DiskDump.prototype.buildImageFromFiles = function(aFiles, done)
* If this BPB is for a hard disk but a hard disk size was not specified, skip it.
*/
abBoot = DiskDump.aDefaultBPBs[iBPB];
if ((abBoot[0x15] == 0xF8) != (this.mbHD > 0)) continue;
if ((abBoot[0x15] == 0xF8) != (this.kbTarget >= 10000)) continue;
cbSector = abBoot[0x0B] | (abBoot[0x0C] << 8);
cSectorsPerCluster = abBoot[0x0D];
cbCluster = cbSector * cSectorsPerCluster;
@ -2282,7 +2303,7 @@ DiskDump.prototype.buildImageFromFiles = function(aFiles, done)
cHeads = abBoot[0x1A] | (abBoot[0x1B] << 8);
cDataSectors = cTotalSectors - cRootSectors - cFATs * cFATSectors + 1;
cbAvail = cDataSectors * cbSector;
if (cbTotal <= cbAvail) break; // found a BPB that works!
if (nTargetSectors && cTotalSectors == nTargetSectors || !nTargetSectors && cbTotal <= cbAvail) break;
}
if (iBPB == DiskDump.aDefaultBPBs.length) {
@ -2318,7 +2339,7 @@ DiskDump.prototype.buildImageFromFiles = function(aFiles, done)
/*
* Output a Master Boot Record (MBR), if a hard disk image was requested
*/
if (this.mbHD > 0) {
if (this.kbTarget >= 10000) {
abSector = this.buildMBR(cHeads, cSectorsPerTrack, cbSector, cTotalSectors);
offDisk += this.copyData(offDisk, abSector);
}

View file

@ -720,13 +720,18 @@ HTTPAPI.processDumpAPI = function(req, res)
sFormat = req.query[DumpAPI.QUERY.FORMAT] || DumpAPI.FORMAT.JSON;
fComments = (req.query[DumpAPI.QUERY.COMMENTS]? true : false);
var mbHD = req.query[DumpAPI.QUERY.MBHD];
var sSize = req.query[DumpAPI.QUERY.MBHD];
if (sSize) {
sSize = (sSize * 1000).toString();
} else {
sSize = req.query[DumpAPI.QUERY.SIZE];
}
/*
* TODO: Consider adding support for DiskDump's "exclusion" option to the API interface
* (the command-line interface supports it).
*/
var disk = new DiskDump(sDisk, null, sFormat, fComments, mbHD, sServerRoot);
var disk = new DiskDump(sDisk, null, sFormat, fComments, sSize, sServerRoot);
if (aCommand[0] == DumpAPI.QUERY.DISK || aCommand[0] == DumpAPI.QUERY.IMG) {
disk.loadFile(function(err) {
HTTPAPI.dumpDisk(err, disk, res);

View file

@ -63,7 +63,8 @@ var DumpAPI = {
FORMAT: "format", // value is one of FORMAT values below
COMMENTS: "comments", // value is either "true" or "false"
DECIMAL: "decimal", // value is either "true" to force all numbers to decimal, "false" or undefined otherwise
MBHD: "mbhd" // value is hard disk size in Mb (formerly "mbsize") (DiskDump only)
MBHD: "mbhd", // value is hard disk size in Mb (formerly "mbsize") (DiskDump only) (DEPRECATED)
SIZE: "size" // value is target disk size in Kb (supersedes "mbhd") (DiskDump only)
},
FORMAT: {
JSON: "json", // default