Skip to content

Commit

Permalink
Added undocumented '--trim' option to pc.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Sep 8, 2023
1 parent 38a1400 commit f3d2dcc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions blog/_posts/2023/2023-09-05-wrapping-up-support-for-fat.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ To confirm this, I tested a drive configuration (162 cylinders, 4 heads, and 17

Here's how I built it using `pc.js`:

% pc.js --sys=pcdos --ver=2.00 --drivetype=162:4:17 --test --save=test.img
% pc.js --sys=pcdos --ver=2.00 --drivetype=162:4:17 --trim --save=test.img

The undocumented `--test` flag tells `pc.js` to bypass its normal DOS-compatibility rules and build/format the disk with an "optimized" 12-bit FAT, and the `--save` option saves the disk image without starting a machine. And although DOS 2.00 didn't like it, `test.img` was an otherwise perfectly valid and usable disk image, and `fsck_msdos` on macOS reported no problems.
The undocumented `--trim` flag tells `pc.js` to bypass its normal DOS-compatibility rules and build/format the disk with an "optimized" 12-bit FAT, and the `--save` option saves the disk image without starting a machine. And although DOS 2.00 didn't like it, `test.img` was an otherwise perfectly valid and usable disk image, and `fsck_msdos` on macOS reported no problems.

It's understandable that DOS 2.00 would be skeptical of its own BPBs, in part because BPBs were a new feature that probably evolved during the development of DOS 2.00, so they would have been dealing with disks with no BPBs, out-dated BPBs, or even invalid BPBs. However, perhaps the biggest problem was FDISK, because whenever FDISK created a DOS partition, it would simply update the partition table in the Master Boot Record and then reboot, leaving the partition's boot sector and any BPB it previously contained in place. And that old BPB might be completely inappropriate.

Expand Down
2 changes: 1 addition & 1 deletion tools/pc/pc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,7 @@ function main(argc, argv)
fDebug = removeFlag('debug') || fDebug;
fVerbose = removeFlag('verbose') || fVerbose;
fTest = removeFlag('test') || fTest;
if (fTest) driveInfo.trimFAT = true;
if (removeFlag('trim')) driveInfo.trimFAT = true;

device.setDebug(fDebug);
device.setMessages(MESSAGE.DISK + MESSAGE.WARN + MESSAGE.ERROR + (fDebug && fVerbose? MESSAGE.DEBUG : 0) + (fVerbose? MESSAGE.INFO : 0), true);
Expand Down

0 comments on commit f3d2dcc

Please sign in to comment.