User`s guide

2.3.11 Disk Reset and Removable Media
The BDOS functions, Disk Reset (function 13) and Reset Drive (function 37) allow
a program to control when a disk's directory is to be reinitialized for file operations.
This process of initializing a disk's directory is called logging-in the drive. When
CP/M 3 is cold started, all drives are in the reset state. Subsequently, as drives are
referenced, they are automatically logged-in by the file system. Once logged-in, a
drive remains in the logged-in state until it is reset by BDOS function 13 or 37.
Following the reset operation, the drive is again automatically logged-in by the file
system when it is next used. Note that BDOS functions 13 and 37 have similar effects
except that function 13 is directed to all drives on the system. Any combination of
drives can be reset with Function 37.
Logging-in a drive consists of several steps. The most important step is the initiali-
zation of the drive's allocation vector. The allocation vector records the allocation
and deallocation of data blocks to files, as files are created, extended, deleted, and
truncated, Another function performed during drive log-in is the initialization of the
directory check-sum vector. The file system uses the check-sum vector to detect media
changes on a drive. Note that permanent drives, which are drives that do not support
media changes, might not have check-sum vectors. If directory hashing has been
specified for the drive, a BIOS and GENCPM option, the file system creates a hash
table for the directory during log-in.
The primary use of the drive reset functions is to prepare for a media change on a
drive. Subsequently, when the drive is accessed by a BDOS function call, the drive is
automatically logged-in. Resetting a drive has two important side effects. First of all,
any pending blocking/deblocking buffers on the reset drive are discarded. Secondly,
any data blocks that have been allocated to files that have not been closed are lost.
An application program should close files, particularly files that have been written to,
prior to resetting a drive.
Although CP/M 3 automatically relogs in removable media when media changes
are detected, the application program should still explicitly reset a drive before
prompting the user to change disks.
2-27
2.3 BDOS File System CP/M 3 Programmer's Guide