[comp.sys.atari.st] Mediach

rowley@orville.nas.nasa.GOV (Karl Rowley) (01/30/88)

I have a question about the GEMDOS Mediach() function.  My MWC manual says
this function can return a 0, 1, or 2, meaning "no", "maybe", or "yes."
What situation would cause Mediach() to return "maybe"?

				Karl Rowley
				...ames!orville.nas.nasa.gov!rowley
				rowley@orville.nas.nasa.gov

"Any opinions expressed are my own."

wheels@mks.UUCP (Gerry Wheeler) (02/02/88)

In article <8801292315.AA23295@orville.nas.nasa.gov>,
 rowley@orville.nas.nasa.GOV (Karl Rowley) writes:
> What situation would cause Mediach() to return "maybe"?
> 
> 				Karl Rowley

In one of the recent conferences on BIX, this was brought up. As I
recall, the answer was that Mediach() returns maybe if the disk is
write protected. 

The ST uses the write protect line to sense disk changes. If there is
no disk in the drive, the drive reports "protected". If there is a
disk in the drive, then the drive reports whatever the disk is set
for. So, the ST can accurately sense the changing of writeable disks,
but not protected disks. So, if it reads from a protected disk, it
sets the flag to maybe as soon as the drive motor times out, because
it really doesn't know.
-- 
     Gerry Wheeler                           Phone: (519)884-2251
Mortice Kern Systems Inc.               UUCP: uunet!watmath!mks!wheels
   35 King St. North                             BIX: join mks
Waterloo, Ontario  N2J 2W9                  CompuServe: 73260,1043

fischer-michael@YALE.ARPA (Michael Fischer) (02/03/88)

Karl Rowley asks:
> I have a question about the GEMDOS Mediach() function.  My MWC manual says
> this function can return a 0, 1, or 2, meaning "no", "maybe", or "yes."
> What situation would cause Mediach() to return "maybe"?

"maybe" is returned after a short time (on the order of 1-2 seconds)
has elapsed with no disk activity if the write protect latch has
seen light, which occurs whenever the disk is removed from the drive
but also whenever a disk is write protected.  Rwabs responds to
"maybe" by rereading the boot sector and seeing if the 24 bit serial
number written there agrees with the remembered value.  If so, it
assumes the disk has NOT changed, so it sets the media change value
back to 0 and carries out the request; if not it sets it to 2 and
returns a "media changed" error.  (This also occurs if it was 2
to start with.)  Getbpb is what normally sets it back to 0.

The idea is that a disk cannot be changed without the system noticing
and checking the serial number.  If the disk is write protected,
the boot sector will be read more often than necessary but otherwise
no harm is done.  Too bad if you are unlucky enough to have two
disks with the same id and you insert one right after the other.
Gemdos will not notice that the disks have been changed and will
happily clobber the second disk if you attempt to write on it since
it will use cached FAT information from the first.  Note that this
situation (of duplicate disk ids) will occur with certain copy
programs that copy the entire disk, including the boot sector.  Avoid
using them for making backups of ordinary data disks.

--Mike Fischer <fischer-michael@cs.yale.edu>
-------

apratt@atari.UUCP (Allan Pratt) (02/03/88)

in article <8801292315.AA23295@orville.nas.nasa.gov>, 
rowley@orville.nas.nasa.GOV (Karl Rowley) says:

> I have a question about the GEMDOS Mediach() function.  My MWC manual says
> this function can return a 0, 1, or 2, meaning "no", "maybe", or "yes."
> What situation would cause Mediach() to return "maybe"?

"Maybe" means that the disk was ejected, but the same disk might have
been put back in the drive.  When the drive is in this state, the next
access will cause the BIOS to check the serial number against the last
disk that was there: if they match, then the media hasn't really
changed, and the operation succeeds.  If they don't match, that
operation returns the "media changed" error. 

============================================
Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt

exodus@uop.edu (G.Onufer) (02/04/88)

In article <8802021912.AA05940@ELI.CS.YALE.EDU>, fischer-michael@YALE.ARPA (Michael Fischer) writes:
> The idea is that a disk cannot be changed without the system noticing
> and checking the serial number.  If the disk is write protected,
> the boot sector will be read more often than necessary but otherwise
> no harm is done.  Too bad if you are unlucky enough to have two
> disks with the same id and you insert one right after the other.
> Gemdos will not notice that the disks have been changed and will
> happily clobber the second disk if you attempt to write on it since
> it will use cached FAT information from the first.  Note that this
> situation (of duplicate disk ids) will occur with certain copy
> programs that copy the entire disk, including the boot sector.  Avoid
> using them for making backups of ordinary data disks.
> 
> --Mike Fischer <fischer-michael@cs.yale.edu>
> -------
This will happen also if you have formatted your disks with the original
version of TWISTER.  It never changed the serial numbers on the disks!!

If you have the original, call a BBS and get the one called TWISTE.PRG 
(usually).  A patch is also to be found....

Greg Onufer
exodus@uop.edu

joe@lakesys.UUCP (Joe Pantuso) (02/05/88)

>in article <8801292315.AA23295@orville.nas.nasa.gov>, 
>rowley@orville.nas.nasa.GOV (Karl Rowley) says:
>
>> I have a question about the GEMDOS Mediach() function.  My MWC manual says
>> this function can return a 0, 1, or 2, meaning "no", "maybe", or "yes."
>> What situation would cause Mediach() to return "maybe"?
>
This question has brought up the fact that if you swap disks and the new one
has the same serial number as the last the FAT is not reread. So...
Question: Is there a utility available to read and change serial numbers of
disks?  If you have never heard of one do you know the sector where this info
is stored?

Thanks.

     Snail Mail:       Real Mail:
*-------------------*                                     *---------------*
|Joe Pantuso        |  joe@lakesys.UUCP                   |You too can be |
|1631 n. 69 St.     |  {ihnp4,uwvax}!uwmcsd1!lakesys!joe  |famous in five |
|Wauwatosa WI  53213|                                     |easy lessons   |
*-------------------* "Veteran of the Psychic Wars...."   *---------------*

landon@apple.UUCP (Landon Dyer) (02/06/88)

> I have a question about the GEMDOS Mediach() function.  My MWC manual says
> this function can return a 0, 1, or 2, meaning "no", "maybe", or "yes."
> What situation would cause Mediach() to return "maybe"?

When you have a situation where the BIOS can't detect (for sure) if
the media has been changed or not.  For instance, if you have a
write-protected disk in the drive, and the drive has been idle for
over a second or so, the state changes to "Maybe".

You can still yank out a non-write-protected disk and put it back in
the drive.  So the "Maybe" state really reflects the fact that the
BIOS hasn't had a chance to match disk serial numbers yet.

-Landon
-- 

I speak for me.