Re: [cc65] fwrite disk full detection

From: Greg King <greg.king41verizon.net>
Date: 2012-04-25 03:06:33
From: "Uz"; on Sunday, April 22, 2012; at 02:19 PM -0400
>
> On Sun, Apr 22, 2012 at 12:52:51AM +0200, Johan Kotlinski wrote:
> > I was a bit surprised now that fwrite() does not detect disk-full.
> > I.e.,
> > FILE* f = fopen("test", "w");
> > while(1 == fwrite(0xc000, 100, 1, f));
> >
> > ... will create an infinite loop. Is that a bug;
> > or, supposed to work like that, due to hardware limitations?
>
> It is probably a bug.
> Does anybody know how the disks on the serial bus flag a "disk full"
> condition -- or other errors?  fwrite() uses write() which, in turn,
> uses BSOUT. Errors are checked by looking at the carry flag, on return
> from BSOUT. That might be wrong -- cbm_write() checks the result
> of READST instead.

The carry flag is set by Kernal errors, while the STATUS variable is set
by both some Kernal errors and some DOS errors.

The drive DOS cannot write data into a file on a full disk.  Therefore,
it will fail to acknowledge a character that was sent to the file.  The
operation will time out.  That will set a bit in STATUS.  (The same
thing will happen if you try to write into a file that isn't open for
writing, or if you try to read from a file that isn't open for reading.)

CHRIN (BASIN) and CHROUT (BSOUT) don't show time-outs as Kernal errors
(LOAD and SAVE, though, are supposed to translate time-outs into Kernal
failures).
Therefore, write() needs to do what cbm_write() [and read()] does.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Apr 25 04:07:29 2012

This archive was generated by hypermail 2.1.8 : 2012-04-25 04:07:32 CEST