Re: Cursory analyses of CBM readdir bug (was: [cc65] Re: readdir bug)

From: Spiro Trikaliotis <ml-cc651trikaliotis.net>
Date: 2013-01-04 13:21:57
Hello,

* On Thu, Jan 03, 2013 at 11:27:45PM +0100 silverdr@wfmh.org.pl wrote:
> 
> On 2013-01-03, at 21:07, Spiro Trikaliotis wrote:

> > Here, the close is the problem. Closing the command/error channel is a special
> > case in the floppy, which interferes with your open file.
> 
> Which still qualifies as a bug to me, doesn't it to to you? :-)

Well, in a sense, probably. ;)

> > IIRC, closing the command channel results in closing all open channel in
> > the floppy (I would have to confirm it, but I am almost sure that this
> > was the case).
> > 
> > Thus, the solution: Never ever close the command channel.
> 
> I know the solution. Just it seems to be rather a workaround..

Indeed.

> I am used to free resources as soon as I don't need them.

That's ok, but you are neglecting what is really happening in the C64
and the floppy.

The OPEN 2,8,15 is a no-op from the floppy's point of view. There is no
IEC traffic generated by it from the C64 side.

All it does is to set up some internal resource in the C64.

In fact, if anyone would do all the IEC traffic with the IEC routines,
not the CHRIN/CHROUT with CHKIN/CKOUT and the like, there would be no
need to close the channel at all.


In fact, I am unsure of what was really the intention of the CBM
engineers: Did the floppy programmers not take into account that the
error channel could be closed (as it does not make much sense from the
floppy's point of view: There is no need for opening it in the first
place), or what is a deliberate decision to close all files when the
error channel is closed - a "reset all" function. Or was there another
reason? I guess we will never know.

But you are absolutely right, this is something that should have been
documented. I was bitten by it myself, but I totally forgot about this
behaviour until you mentioned it.


> Therefore I
> didn't even suspect that closing one file (no matter what file it is)
> may interfere with another but yes, now I know :-) Funny enough I
> never encountered that bug before.

The error channel is not a file - like the dir, which is not a file, but
a special file. ;)

Regards,
Spiro.

-- 
Spiro R. Trikaliotis
http://www.trikaliotis.net/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Jan 4 13:22:21 2013

This archive was generated by hypermail 2.1.8 : 2013-01-04 13:22:26 CET