Re: Of removable devices

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Fri Feb 18 2000 - 10:48:48 EST


On Fri, 18 Feb 2000, David Balazic wrote:

> Jesse Pollard wrote :
> > >It is perfectly possible to handle this kind of thing on PC hardware, as
> > >evidenced by other operating systems that do it. If it's too hard for
> > >Linux then fine, but that should be admitted fairly instead of just saying
> > >the user is an idiot for wanting it.
> >
> > really? All systems using the current floppy drives have that problem. If
> > the user pops the floppy out you are just as likely to get a blown format
> > and getting a warning "put that back" message. Once the format is blown
> > putting it back is useless.
>
> What do you mean by "blown format" ?
>
> I you eject a floppy during read on amiga , just just get a "Put it back
> in !"
> message , and when you put in back in , it continues with read and
> nothing bad
> happens.
> For writing it is a little bit worse , becasue amigaOS just overwrites (
> AFAIK )
> the entire track ,so some older sectors might be lost, but this isn't
> the case
> on wintel PCs, because they operate sector-wise , so it shouldn't be a
> problem.
>

An interrupted write caused by physically lifting the heads prior to
removing media will corrupt the sector, probably the whole track, and
often adjacent tracks.

The result will be that the sector(s) will not be found when the diskette
is replaced. A blank floppy has no sector information and, since it's
not "hard-sectored" anymore, a complete track must be written with
all the sector information. This is called "formatting". It is not
the so-called DOS format which just writes file-system data if it
finds that the diskette is already readable.

There is a special mode of controller operation for doing this. The
result of formatting a track is that there is header information to find
the sectors, plus dummy data, plus the CRC, plus a "write-splice" area
between each sector.

I'm sorry to bore those who already know this, but there are lots of
new PC users who never bought a box of diskettes that were not already
formatted. Many, perhaps most, now think that you just take a diskette
out of the box, put it into the drive and write. These same users,
once they blue-screen their machine by trying to use a diskette with
a bad sector, just throw it away not knowing that you can make them
just like new (possibly better), by reformatting them.

Since sectors may be interleaved, if you destroy a sector, there is
no way for the controller to find it during the next sector write
so you can "replace" it without doing something special and
time-consuming.

The special thing, first done by Peter Norton, in early versions of
Norton's utilities, was to set the controller to "read-long" mode
where the CRC is not checked. Each sector was read into memory, including
any unreadable bad sectors (junk was read with errors ignored). Then
the track was re-formatted, then the sectors were written back. The
previous bad sectors were now "good", but contained junk data.

To recover from a user removing a floppy during a write would require
something quite like this. Since the OS doesn't know what sectors had
been destroyed, it would have to read the entire diskette contents into
memory (to find destroyed sectors), reformat any tracks that contained
bad sectors, then write those back.

This takes a great deal of time because you can't just read a whole
track into memory if that track has a bad sector. You can try it
first, then if there is an error, you have to read one sector at a
time.

This results in a readable diskette, but with possibly corrupt file-system
data.

To rebuild a 1.44 Mb diskette under DOS, where nothing else is going on,
takes about 4 minutes. If you intend to do this with a Linux daemon,
you will need to extend the notion of a Virtual File System so that
a virtual diskette is being read or written while the recovery is
going on. This is certainly possible, but it's not a matter of
just popping up a window and waiting for the user to put in the
"correct" diskette. It may not even be possible to verify that a
correct diskette has been inserted because track 0, sector 1, where
the boot-sector and diskette serial number exists, may no longer
be readable.

FYI I extended Peter Norton's idea of fixing floppy diskettes to
fixing hard disks (free software on the defunct PROGRAM EXCHANGE).
This utility was called "Spin OK" after some thief company stole
the source for their own and called it "Spin Right". It would find
the optimum sector interleave for each track during the repair
process.

Cheers,
Dick Johnson

Penguin : Linux version 2.3.41 on an i686 machine (800.63 BogoMips).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:22 EST