From: Christoph Hellwig <hch@lst.de>
To: James Bottomley <James.Bottomley@SteelEye.com>
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH] check whether a disk got writeable in sd_open
Date: Mon, 25 Aug 2003 21:36:48 +0200 [thread overview]
Message-ID: <20030825193648.GA21396@lst.de> (raw)
This is the 2.5 version of a 2.4 patch posted to the list long
ago, the aacraid thread reminded me of it.
The problem is that certain highend arrays allow to mark a r/o
volume writeable on the fly so we have to call check_disk_change
for write-protected devices in sd_open, too.
diff -Nru a/drivers/scsi/sd.c b/drivers/scsi/sd.c
--- a/drivers/scsi/sd.c Wed Jun 25 11:47:26 2003
+++ b/drivers/scsi/sd.c Wed Jun 25 11:47:26 2003
@@ -368,25 +368,24 @@
if (!scsi_block_when_processing_errors(sdev))
goto error_out;
- if (sdev->removable) {
+ if (sdev->removable || sdkp->write_prot)
check_disk_change(inode->i_bdev);
- /*
- * If the drive is empty, just let the open fail.
- */
- retval = -ENOMEDIUM;
- if ((!sdkp->media_present) && !(filp->f_flags & O_NDELAY))
- goto error_out;
+ /*
+ * If the drive is empty, just let the open fail.
+ */
+ retval = -ENOMEDIUM;
+ if (sdev->removable && !sdkp->media_present &&
+ !(filp->f_flags & O_NDELAY))
+ goto error_out;
- /*
- * Similarly, if the device has the write protect tab set,
- * have the open fail if the user expects to be able to write
- * to the thing.
- */
- retval = -EROFS;
- if ((sdkp->write_prot) && (filp->f_mode & FMODE_WRITE))
- goto error_out;
- }
+ /*
+ * If the device has the write protect tab set, have the open fail
+ * if the user expects to be able to write to the thing.
+ */
+ retval = -EROFS;
+ if (sdkp->write_prot && (filp->f_mode & FMODE_WRITE))
+ goto error_out;
/*
* It is possible that the disk changing stuff resulted in
reply other threads:[~2003-08-25 19:36 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=20030825193648.GA21396@lst.de \
--to=hch@lst.de \
--cc=James.Bottomley@SteelEye.com \
--cc=linux-scsi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox