From: Alexei S. <ale...@gm...> - 2012-04-21 16:09:12
|
Thanks for your investigation! I've looked at the code and decided to go with the solution of not even starting the media_thread when "nocdrom" is set, since the media_thread is only used to scan for CDs in the current code. This way, the emulator is won't be doing useless work when that pref is set. As for your concern of whether other Unixes are affected by the bug, it actually looks like the only caller of SysMediaArrived() in sys_unix.cpp is the code in sys_darwin.cpp, so the issue only affected the Darwin version. I've committed the change to CVS. Thanks again! -Alexei On Sat, Apr 21, 2012 at 2:23 AM, Robert Munafo <mr...@gm...> wrote: > This affects both BasiliskII and SheepShaver, on Mac OS X host > systems, when the "nocdrom" setting is set to "true". > > 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: > > if (type == MEDIA_CD && !PrefsFindBool("nocdrom")) > > but this test only affects whether or not it does the following > "PrefsReplaceString("cdrom", path);" step. > > 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: > > if ((type == MEDIA_CD) && PrefsFindBool("nocdrom")) { > // Do nothing > return; > } > > With this change I am able to insert and eject as many CD-ROMs as I > want while SheepShaver is running, without having to make SheepShaver > quit. > > 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... > > -- > Robert Munafo -- mrob.com > Follow me at: gplus.to/mrob - fb.com/mrob27 - twitter.com/mrob_27 - > mrob27.wordpress.com - youtube.com/user/mrob143 - rilybot.blogspot.com > > ------------------------------------------------------------------------------ > For Developers, A Lot Can Happen In A Second. > Boundary is the first to Know...and Tell You. > Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! > http://p.sf.net/sfu/Boundary-d2dvs2 > _______________________________________________ > basilisk-devel mailing list > bas...@li... > https://lists.sourceforge.net/lists/listinfo/basilisk-devel |