Microsoft KB Archive/57840

Recognizing CD-ROM Disc Change Information

PSS ID Number: Q57840 Article last modified on 10-31-1994

1.00 1.01 2.00 2.10

MS-DOS

= SYMPTOMS =

Microsoft MS-DOS CD-ROM Extensions (MSCDEX) does not seem to automatically recognize a CD-ROM disc change. When you remove the current disc from the drive and replace it with a new disc and type “dir” (without the quotation marks), a directory listing of the previous disc appears.

= CAUSE =

MSCDEX taps into the network interface of MS-DOS, a modular way that a non- FAT-based file system can install itself into MS-DOS. However, MS-DOS makes some assumptions about this network driver interface.

For example, MS-DOS assumes that network drives are fixed (not removable, like a floppy disk). Thus, MS-DOS does not check for disk changes in a network drive, since MS-DOS knows that the network drive is always there. When a network disconnection is made (for example, by using the Microsoft LAN Manager command NET USE Z: /D), the network software removes the specified drive from the MS-DOS drive table, making this an invalid drive specification.

For CD-ROM discs, it is not quite the same. MSCDEX does need to check for disc changes. MSCDEX has to manually check to see if the drive has changed. It would be a performance hit to make this check at each disc access (and especially during a system call, which is called many times and is supposed to be very fast, similar to an MS-DOS Find Next system call). Thus, MSCDEX checks for a CD-ROM disc change only when an application calls one of the following three MS-DOS system calls:

Find First Open Change Directory

This is similar to the way the MS-DOS floppy block device driver checks for floppy disk changes. However, because CD-ROMs contain so much information, and because their access speed is often not as fast as some users would like, occasionally some users may remove a disc from the drive before a read is complete. This can confuse MSCDEX–it doesn’t check for a disc change in the middle of a read.

= RESOLUTION =

Always make sure that an I/O operation is complete before swapping CD-ROMs. For example, if a program has a file open on CD-ROM A, make sure that drive A is closed and that a new disc is inserted before a new file-open call is made for a file on the new disc.

The same advice applies to CD-ROM applications. In addition, CD-ROM applications that need to ensure that the disc in the drive is the correct one can read the disc’s volume information to make sure that the current disc is the same one that was previously accessed. For example, perform an MS-DOS Find First system call and look for the volume ID of the disc. Not only does this give MSCDEX the opportunity to check for a disc change, it also returns information to the application that it can use for its own double-checking purposes.

At a lower level, the CD-ROM device driver, which is written by the CD-ROM independent hardware vendor (IHV) or original equipment manufacturer (OEM), must also report disc changes properly. If the device driver doesn’t properly report disc changes to MSCDEX, MSCDEX cannot properly report disc changes to MS-DOS or any CD-ROM applications. There have been a few reported problems with some OEM device drivers. Sometimes the problem is as simple as using the device driver with the wrong hardware drive model, or not including a switch on the “device=” command line. If you suspect that either of these problems is occurring, contact your CD-ROM drive manufacturer for more information.

In summary, if the OEM CD-ROM device driver properly reports media change conditions to MSCDEX, and if the user and/or application does not swap discs in the middle of an I/O operation, you should not have any CD-ROM disc change problems.

This information is also contained in the Microsoft MS-DOS CD-ROM Extensions document “Questions and Answers,” included with the Microsoft MS- DOS CD-ROM Extensions Information Kit. The following information is taken from this document:

Q. What is the best way for my application to know if the disc has been changed since it was last accessed?

A. Use the DOS function Find First (interrupt 21h function 4Eh) and look for the volume ID. When the disc has been read and MSCDEX (the actual CD-ROM program) has already initialized the internal information it keeps for each disc, this is a relatively inexpensive operation. The information is in memory and the disc does not have to be touched, so checking the volume ID is very quick. Only if the disc has been changed does the disc have to be touched. This operation takes considerably longer than if the disc was not changed, but even so this has to be done anyway because MSCDEX has to read and initialize what it knows about the new disc so it can report the volume ID correctly, so that the application will know if the disc in the drive is the one that it is looking for.

KBCategory: kbusage KBSubcategory: ============================================================================= Copyright Microsoft Corporation 1994.