Date : Fri, 26 Sep 1986 15:12:12 PDT
From : bridger@RAND-UNIX.ARPA
Subject: Automatic Disk Logging
A slight correction to the discussion: the Digital Research CP/M 2.2
BDOS computes a checksum of each directory sector when it logs in a
new disk (unless cks=0 in the disk parameter block). When a disk
directory sector is read, it is these stored checksums, not the
bitmap of allocated disk groups, that are compared with the values
computed from the (possibly changed) disk.
Writing to a file causes the allocation map (in memory) and the
user-supplied file control block to be updated, and causes the data
to be written to the disk sectors (when the bios flushes the host
buffer); it does not alter the disk directory. The directory
information -- which groups are allocated to which files -- is only
updated on the disk when a file (or one extent of a file) is closed.
Auto-logging DOS's usually can't totally prevent trashing a disk.
Suppose that a program creates a file and writes to it, leaving it
open, and the user then swaps in a different disk. The dos won't
detect the change until the program causes a directory access. So,
if the program continues to write to the file, the data will go onto
the new disk, overwriting whatever is in those groups; the R/O error
will occur at the close (or other directory operation).
Perhaps the original question -- "auto-logging of disks" -- was
really a query about a BIOS operation (as Jay has suggested). A
well-designed bios will do a media-determination check whenever
SELDSK is called with bit 0 of register E RESET (e.g. E = 0 or 2) and
will set the dph and associated dpb accordingly for
sides/density/format ... CP/M 2.2 calls SELDSK with E bit 0 reset
after a ^C and when next selecting a disk that has been logged off.
Of course, only some of the 100+ 5 1/4" formats can be distinguished
by their format pattern. Bioses that support "foreign" formats may
do so automatically (within the supported subset); others may simply
provide a different logical drive and require the user to install the
dpb/dph information before using it. For example, it is possible to
set the Advent/Plu*Perfect Systems Turborom on a Kaypro so that the
bios automatically distinguishes Kaypro DSDD 512 format from Ampro
DSDD 512.
*BIOS-level* auto-disk format determination should be compatible with
any cp/m 2.2-type dos, requiring only ^C, reset, or logoff/logon at
the dos level.
--bridger mitchell