Fix: Media-Change CDROM (ioctl CDROMRESET)

Thomas Niederreiter (tn@bv.rz.fh-muenchen.de)
Tue, 30 Apr 1996 12:32:43 +0200 (MET DST)


Hi, its me again...

I stated my problem with the undetected Media-Change on CD-Rom's after
generic-scsi-reads a few days before, but nobody could help me.

I asked for an ioctl that fixes my problem with the unflushed read-buffers.
Well I already made a kernel-patch that addresses the problem by
invalidating the buffers after a close of the generic-scsi-device.
This worked, but was not very nice.

Now I looked at all the cdrom-ioctls myself and found that most other
CD-Rom drivers support a CDROMRESET-ioctl, but the scsi-cd-driver misses
such a feature.

I appended my patch, that implements this reset into sr_ioctl.c.
I hope this one makes it into the kernel, because I need such a feature
to get my current project running (Full featured CD-Recorder-Software)
and I don't want tell all the users that they must patch the kernel
prior the usage of my program!

I am still looking for a way to solve this without a kernel-patch, but
I searched a long time, and this patch seems to be the most resonable
solution.

Thomas Niederreiter

P.S.
I included this patch into 1.3.97 and noticed no negative
drawbacks, even when calling CDROMRESET while the drive
was operating.

--- sr_ioctl.c.orig Tue Apr 30 11:14:15 1996
+++ sr_ioctl.c Tue Apr 30 11:19:14 1996
@@ -555,12 +555,21 @@
}

case BLKRASET:
+ {
if(!suser()) return -EACCES;
if(!(inode->i_rdev)) return -EINVAL;
if(arg > 0xff) return -EINVAL;
read_ahead[MAJOR(inode->i_rdev)] = arg;
return 0;
RO_IOCTLS(dev,arg);
+ }
+
+ case CDROMRESET:
+ {
+ invalidate_buffers(MKDEV(MAJOR(inode->i_rdev),MINOR(inode->i_rdev)));
+ return 0;
+ }
+
default:
return scsi_ioctl(scsi_CDs[target].device,cmd,(void *) arg);
}