]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix cdrom mt rainier probe
authorPat LaVarre <p.lavarre@ieee.org>
Fri, 16 Jul 2004 04:17:27 +0000 (21:17 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 16 Jul 2004 04:17:27 +0000 (21:17 -0700)
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 <axboe@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/cdrom/cdrom.c
drivers/ide/ide-cd.c
drivers/scsi/sr.c

index cd67fcddf3949112239bd038d3d4fca7cb87e068..c19679a3082635772c120bf7f12916167266b834 100644 (file)
@@ -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;
                }
        }
index 0bb248239107cd98592cf8789906db5864a7342e..7e8c89f29c30575093ae33ddadb37667e21fe77c 100644 (file)
@@ -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
index ba7b03203246b61d25dbd5d028a35a66eae04fcc..06aa858f9a809934d0e48844ce9e83c8c066ee79 100644 (file)
@@ -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);