public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jon Masters <jonathan@jonmasters.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Cal Peake <cp@absolutedigital.net>,
	linux-kernel@vger.kernel.org, jcm@jonmasters.org,
	torvalds@osdl.org, viro@ftp.linux.org.uk, hch@lst.de
Subject: Re: floppy regression from "[PATCH] fix floppy.c to store correct ..."
Date: Sat, 19 Nov 2005 03:44:56 +0000	[thread overview]
Message-ID: <20051119034456.GA10526@apogee.jonmasters.org> (raw)
In-Reply-To: <20051116005958.25adcd4a.akpm@osdl.org>

On Wed, Nov 16, 2005 at 12:59:58AM -0800, Andrew Morton wrote:
> Cal Peake <cp@absolutedigital.net> wrote:

> >  "[PATCH] fix floppy.c to store correct ro/rw status in underlying gendisk"

> > causes an annoying side-effect. Upon first write attempt to a floppy I get 
> > this:

> > $ dd if=bootdisk.img of=/dev/fd0 bs=1440k
> > dd: writing `/dev/fd0': Operation not permitted
> > 1+0 records in
> > 0+0 records out

Yes indeed. I reproduced that behaviour.

> hmm, yes, when floppy_open() does its test we haven't yet gone and
> determined the state of FD_DISK_WRITABLE.  On later opens, we have done, so
> things work OK.

I stuck a test in for first use and had floppy_release free up policy
too. But there are a bunch of problems in the floppy driver I've noticed
in going through it tonight (and there's only so much of that I can take
at 03:43 on a Saturday morning). I'll hopefully followup again.

Jon.

diff -urN linux-2.6.14/drivers/block/floppy.c linux-2.6.14_new/drivers/block/floppy.c
--- linux-2.6.14/drivers/block/floppy.c	2005-10-28 01:02:08.000000000 +0100
+++ linux-2.6.14_new/drivers/block/floppy.c	2005-11-19 03:17:08.000000000 +0000
@@ -1610,10 +1610,11 @@
 			DPRINT("wp=%x\n", ST3 & 0x40);
 		}
 #endif
-		if (!(ST3 & 0x40))
+		if (!(ST3 & 0x40)) {
 			SETF(FD_DISK_WRITABLE);
-		else
+		} else {
 			CLEARF(FD_DISK_WRITABLE);
+		}
 	}
 }
 
@@ -3677,15 +3678,19 @@
 	int drive = (long)inode->i_bdev->bd_disk->private_data;
 
 	down(&open_lock);
+
 	if (UDRS->fd_ref < 0)
 		UDRS->fd_ref = 0;
 	else if (!UDRS->fd_ref--) {
 		DPRINT("floppy_release with fd_ref == 0");
 		UDRS->fd_ref = 0;
 	}
-	if (!UDRS->fd_ref)
+	if (!UDRS->fd_ref) {
+		opened_bdev[drive]->bd_disk->policy = 0;
 		opened_bdev[drive] = NULL;
+	}
 	floppy_release_irq_and_dma();
+
 	up(&open_lock);
 	return 0;
 }
@@ -3714,6 +3719,13 @@
 		USETF(FD_VERIFY);
 	}
 
+	/* set underlying gendisk policy to reflect device ro/rw status */
+	if (UDRS->first_read_date && !(UTESTF(FD_DISK_WRITABLE))) {
+		inode->i_bdev->bd_disk->policy = 1;
+	} else {
+		inode->i_bdev->bd_disk->policy = 0;
+	}
+	
 	if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL)))
 		goto out2;
 
@@ -3788,6 +3800,7 @@
 		if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
 			goto out;
 	}
+
 	up(&open_lock);
 	return 0;
 out:

  parent reply	other threads:[~2005-11-19  3:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-16  5:47 floppy regression from "[PATCH] fix floppy.c to store correct ..." Cal Peake
2005-11-16  8:59 ` Andrew Morton
2005-11-16 11:22   ` Jon Masters
2005-11-19  3:44   ` Jon Masters [this message]
2005-11-21  3:36     ` Cal Peake
2005-11-21 11:59       ` Jon Masters
2005-11-22  3:15     ` Linus Torvalds
2005-11-22  4:21       ` Jon Masters
2005-11-22  7:31     ` Andrew Morton
2005-11-22 11:56       ` Jon Masters
2005-11-22 22:16         ` Andrew Morton
2005-11-23  4:47           ` Jon Masters
2005-11-28 18:37           ` Bill Davidsen
2005-11-28 20:33             ` Jon Masters
2005-11-29 22:00               ` Bill Davidsen
2005-11-30  1:15                 ` Jon Masters
2005-11-16 10:50 ` Mikael Pettersson
     [not found] <59olg-7rC-3@gated-at.bofh.it>
     [not found] ` <59rsT-3Co-27@gated-at.bofh.it>
     [not found]   ` <5arTK-5Wu-1@gated-at.bofh.it>
     [not found]     ` <5bAW4-8wm-19@gated-at.bofh.it>
     [not found]       ` <5bEYO-6oH-15@gated-at.bofh.it>
     [not found]         ` <5bOEG-5jk-19@gated-at.bofh.it>
     [not found]           ` <5bUK2-61i-5@gated-at.bofh.it>
2005-11-23 17:39             ` Bodo Eggert
2005-11-23 18:02               ` Jon Masters

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=20051119034456.GA10526@apogee.jonmasters.org \
    --to=jonathan@jonmasters.org \
    --cc=akpm@osdl.org \
    --cc=cp@absolutedigital.net \
    --cc=hch@lst.de \
    --cc=jcm@jonmasters.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=viro@ftp.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox