From 8133b98db714f51ca800876f9684fe5c80f8db48 Mon Sep 17 00:00:00 2001 From: Pat LaVarre Date: Thu, 15 Jul 2004 21:17:27 -0700 Subject: [PATCH] [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: Jens Axboe Signed-off-by: Linus Torvalds --- drivers/cdrom/cdrom.c | 4 ++-- drivers/ide/ide-cd.c | 11 +---------- drivers/scsi/sr.c | 4 ---- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index cd67fcddf3949..c19679a308263 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -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; } } diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 0bb248239107c..7e8c89f29c305 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -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 diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index ba7b03203246b..06aa858f9a809 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -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); -- 2.53.0