From: almesber@nessie.cs.id.ethz.ch (Werner Almesberger) Subject: Re: Simulation of media changes Date: Fri, 9 Oct 1992 13:54:26 GMT
In article <1992Oct7.024400.16513@sol.ctr.columbia.edu> fsmith@grind.cheme.cmu.edu (Frank Smith) writes:
> Is there a simple way to simulate a media change? I know it's possible.. Is
> there a command syntax to do it? I was told setfdprm could do it but I
> haven't been able to figure out how.
setfdprm has some code in it to use a media change ioctl, but there's no
such thing in the kernel. Fortunately, a more elegant solution exists.
There are two problems with drives that don't signal media changes
properly:
- the auto-detecting floppy devices don't work, so you have to use the
fixed-format ones.
- the track buffer is not invalidated after a media change and can
leak data from one media to another. This can lead to all kinds of
media corruption.
While the first problem can't be easily fixed (unless a media change
ioctl is added, but this doesn't make the whole procedure less awkward),
the following patch (to 0.98pl1, but should work with older kernel
versions too) should fix the latter.
- Werner
================================== cut here ===================================
*** floppy.orig Fri Oct 9 14:35:54 1992
--- floppy.c Fri Oct 9 14:36:11 1992
***************
*** 1174,1179 ****
--- 1174,1180 ----
return -EBUSY;
fd_ref[drive]++;
fd_device[drive] = inode->i_rdev;
+ buffer_drive = buffer_track = -1;
if (old_dev && old_dev != inode->i_rdev)
invalidate_buffers(old_dev);
if (filp && filp->f_mode)
-- _________________________________________________________________________ / Werner Almesberger, ETH Zuerich, CH almesber@nessie.cs.id.ethz.ch / / IFW A44 Tel. +41 1 254 7213 almesberger@rzvax.ethz.ch / /_BITNET:_ALMESBER@CZHETH5A__HEPNET/CHADNET:_[20579::]57414::ALMESBERGER_/