I keep lots of old files archived on CD-ROMs, and I often use these CD-ROMs while BasiliskII or SheepShaver is running. The CD-ROMs are for MacOS X, they wouldn't work in the emulator even if I tried, so I have "nocdrom true" in both my .basilisk_ii_prefs and .sheepshaver_prefs files.
There has been a bug for many years that causes this setting to only partly work. "nocdrom true" prevents the emulator from emulating the CD-ROM, but if you insert a disc after launching the emulator, it still grabs onto the CD-ROM as if it were being used, and it never lets go. If you want to eject the CD-ROM, the Finder removes the icon from the desktop but it doesn't eject. Disk Utility tells you it can't be unmounted. You have to quit BasiliskII or SheepShaver before ejecting it.
A little searching through the source code turns up the routine "SysMediaArrived", which is defined in sys_unix.cpp and invoked from sys_darwin.cpp. As you can see, it does perform an appropriate test:
Code: Select all
if (type == MEDIA_CD && !PrefsFindBool("nocdrom"))
The rest of the actions, including in particular the call to "cdrom_open(fh, path)", are performed regardless of the "nocdrom" setting.
This makes it open the CD-ROM device (such as "/dev/disk1" on one of the systems I tested) which is why the disc cannot be ejected. Unfortunately, there is no way to get it to close the device later. Because CD-ROM is turned off, the disc never appears inside the emulated MacOS, and so there is no way to ask the emulated Mac to eject it.
The fix I decided to try is relatively simple. If "nocdrom" is true, the entire SysMediaArrived routine is superfluous. So I added a test at the very beginning of SysMediaArrived that exits:
Code: Select all
if ((type == MEDIA_CD) && PrefsFindBool("nocdrom")) {
// Do nothing
return;
}
There are probably other ways to fix this. SysMediaArrived is called from media_arrived in sys_darwin.cpp, and media_arrived is installed by a call to IOServiceAddMatchingNotification. I suspect that one could put a test of PrefsFindBool("nocdrom") somewhere in here to prevent installing the notification handler in the first place. But I don't know what else that might affect (there might be other media that can arrive apart from CDROMs).
Also, the presence of the incorrect code in sys_unix.cpp makes it look like this bug might also affect Linux users.
Comments welcome...