All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Wilkens <robw@optonline.net>
To: linux-kernel@vger.kernel.org
Subject: Floppy bug - And fix, kind of :-)
Date: Thu, 09 Jan 2003 19:10:31 -0500	[thread overview]
Message-ID: <1042157430.841.29.camel@RobsPC.RobertWilkens.com> (raw)

Someone reported a bug in the linux.kernel newsgroup which I presumed
was somehow linked to this mailing list which I finally found my way on
to.  Glad to be here.

Anyway, enough of the pleasantries.  I'm a newbie to the Linux kernel,
but formerly a professional kernel developer.  I left for mental health
reasons, long story.

The bug that someone reported was that when they did a "dd" using the
device "/dev/fd0u1440" and there was no disk in the drive, it would only
fail about half of the time.  The rest of the tiem it would succeed,
which is bad because there was no disk and for it so succeed and not get
an ENXIO on openning the device was wrong.

I was able to reproduce this bug, and fix it, on my machine.

The fix isn't pretty, though, and it's a one line fix.  I'll leave it to
others here (open for discussion) to suggest the more propper fix, after
all I am a newbie here.  My fix may be fine, though.  I just don't know.

Basically, the error traced back to the floppy_revalidate(kdev_t dev)
function in drivers/block/floppy.c .. There's a line in there which
reads "if (NO_GEOM) {", and my fix is to change that line to "if (1) {".

Yep, that means that the code inside that block gets executed every
time.

You see, the problem is that only when the code inside that block gets
executed, though, is there some reading done from the drive which tests
the initial drive status.  

Of course, if someone is openning a special "u1440" version of the
device (minor number 28 instead of minor number 0), then there may be a
good reason that this code shouldn't be executed.  I just don't know
what that is because I don't know what those special device files are
for.

If those files are to specially handle, for example, 720kb disks in a
1440kb drive, then I'm not sure this particular piece of code being
enabled will -break- that.  Of course, I only can find one floppy disk,
and it's a 1440kb disk.  I don't have tons of floppies hanging around.

Someone may have already addressed this issue, too.  I don't know.

If anyone was interested, though, I was able to reproduce this problem
simply by not having a disk in the drive and repeatedly opening the
drive with simple test.c code (with O_WROLY|O_CREAT|O_TRUNC as dd was
using).  If I openned "/dev/fd0", I would consistently get a failure as
expected, but if I openned "/dev/fd0u1440" I would less consistently get
a failure.

I haven't checked a 2.5 kernel.  This was in 2.4.20.

-Rob

p.s. Sorry for the long message.  I figure too much detail is better
than too little.


                 reply	other threads:[~2003-01-10  0:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1042157430.841.29.camel@RobsPC.RobertWilkens.com \
    --to=robw@optonline.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.