From: Jens Axboe <axboe@suse.de>




 drivers/cdrom/cdrom.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff -puN drivers/cdrom/cdrom.c~cdrom_open-fix drivers/cdrom/cdrom.c
--- 25/drivers/cdrom/cdrom.c~cdrom_open-fix	2003-12-30 02:35:19.000000000 -0800
+++ 25-akpm/drivers/cdrom/cdrom.c	2003-12-30 02:35:19.000000000 -0800
@@ -740,20 +740,21 @@ int cdrom_open(struct cdrom_device_info 
 
 	cdinfo(CD_OPEN, "entering cdrom_open\n"); 
 	cdi->use_count++;
-	ret = -EROFS;
-	if (fp->f_mode & FMODE_WRITE) {
-		if (!CDROM_CAN(CDC_RAM))
-			goto out;
-		if (cdrom_open_write(cdi))
-			goto out;
-	}
 
 	/* if this was a O_NONBLOCK open and we should honor the flags,
 	 * do a quick open without drive/disc integrity checks. */
 	if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS))
 		ret = cdi->ops->open(cdi, 1);
-	else
+	else {
+		if (fp->f_mode & FMODE_WRITE) {
+			ret = -EROFS;
+			if (!CDROM_CAN(CDC_RAM))
+				goto out;
+			if (cdrom_open_write(cdi))
+				goto out;
+		}
 		ret = open_for_data(cdi);
+	}
 
 	cdinfo(CD_OPEN, "Use count for \"/dev/%s\" now %d\n", cdi->name, cdi->use_count);
 	/* Do this on open.  Don't wait for mount, because they might

_