Commit 8133b98d authored by Pat LaVarre's avatar Pat LaVarre Committed by Linus Torvalds

[PATCH] fix cdrom mt rainier probe

Writing to RAM capable media was broken by the moving of write flag
detection from probe to drive open time.  The media would stay
terminally RO due to the set_disk_ro() call. 

This fixes the code to do the right thing - the detection stays at open
time (which it must, since it depends on the media), and we fail with
-EROFS if the media can't be written.
Signed-off-by: default avatarJens Axboe <axboe@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 3d3b3a55
......@@ -897,10 +897,10 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
goto err;
if (fp->f_mode & FMODE_WRITE) {
ret = -EROFS;
if (!CDROM_CAN(CDC_RAM))
goto err;
if (cdrom_open_write(cdi))
goto err;
if (!CDROM_CAN(CDC_RAM))
goto err;
ret = 0;
}
}
......
......@@ -785,14 +785,6 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
do_end_request = 1;
} else if (sense_key == ILLEGAL_REQUEST ||
sense_key == DATA_PROTECT) {
/*
* check if this was a write protected media
*/
if (rq_data_dir(rq) == WRITE) {
printk("ide-cd: media marked write protected\n");
set_disk_ro(drive->disk, 1);
}
/* No point in retrying after an illegal
request or data protect error.*/
ide_dump_status (drive, "command error", stat);
......@@ -3248,9 +3240,8 @@ int ide_cdrom_setup (ide_drive_t *drive)
nslots = ide_cdrom_probe_capabilities (drive);
/*
* set correct block size and read-only for non-ram media
* set correct block size
*/
set_disk_ro(drive->disk, !CDROM_CONFIG_FLAGS(drive)->ram);
blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE);
#if 0
......
......@@ -775,9 +775,6 @@ static void get_capabilities(struct scsi_cd *cd)
""
};
/* Set read only initially */
set_disk_ro(cd->disk, 1);
/* allocate a request for the TEST_UNIT_READY */
SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
if (!SRpnt) {
......@@ -885,7 +882,6 @@ static void get_capabilities(struct scsi_cd *cd)
if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM)) !=
(CDC_DVD_RAM | CDC_MRW_W | CDC_RAM)) {
cd->device->writeable = 1;
set_disk_ro(cd->disk, 0);
}
scsi_release_request(SRpnt);
......
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