Commit a0cb8f17 authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] check whether a disk got writeable in sd_open

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.
parent 92d5de7f
......@@ -370,25 +370,24 @@ static int sd_open(struct inode *inode, struct file *filp)
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))
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.
* 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))
if (sdkp->write_prot && (filp->f_mode & FMODE_WRITE))
goto error_out;
}
/*
* It is possible that the disk changing stuff resulted in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment