On Oct 31 at 14:59, Thomas Zenker spoke:

> On Tue, Oct 29, 2002 at 06:34:36PM +0100, Poul-Henning Kamp wrote:
> > That's a slightly more involved issue because you would have to
> > actually try to write to it before you find out that you can't.
> 
> for stable I have a patch, which checks during open for write
> protection of the floppy if FWRITE bit is set and fails with EPERM
> if this is the case. This works reliably for me. The reason I haven't
> sent this patch in is, there is a possible conflict with accesses
> to a second floppy disk drive at the same time. Anyway, better than
> panic'ing the machine...
> 
> Actually all accesses to the controller hardware are serialized
> thru a state machine "fdstate". The Bad Thing is, that this state
> machine is bound too tight to the strategy (i.e. you get some job
> done via a buffer or nothing). Best example is the interfacing of
> formatting via the B_FORMAT/B_XXX kludge.  The Right Thing would
> be to redesign  the interface to the state machine to get jobs done
> from any source (with or without buffer) and maintaining state of
> write protection.
> 
> Index: sys/isa/fd.c
> ===================================================================
> RCS file: /usr/cvs/FreeBSD/src/sys/isa/fd.c,v
> retrieving revision 1.176.2.8
> diff -u -r1.176.2.8 fd.c
> --- sys/isa/fd.c      15 May 2002 21:56:14 -0000      1.176.2.8
> +++ sys/isa/fd.c      31 Oct 2002 13:06:05 -0000
> @@ -1448,6 +1448,21 @@
>               }
>       }
>       fd->ft = fd_types + type - 1;
> +     if (flags & FWRITE) {   /* check for write protection */
> +             int r, s, st3;
> +             s = splbio();
> +             set_motor(fdc, fd->fdsu, TURNON); /* select drive */
> +             r = fd_sense_drive_status(fdc, &st3);
> +             set_motor(fdc, fd->fdsu, TURNOFF);
> +             fdc->state = RESETCTLR;
> +             splx(s);
> +             if(r != 0)
> +                     return(ENXIO);
> +             if (st3 & NE7_ST3_WP) {
> +                     device_printf(fd->dev, "write protected\n");
> +                     return(EPERM);
> +             }
> +     }
>       fd->flags |= FD_OPEN;
>       /*
>        * Clearing the DMA overrun counter at open time is a bit messy.
> 
> 
> Cheers,
> 
> -- Thomas Zenker

Hey, exactly! Thank you!

Could the core team consider this patch to get merged into 4.8?

-Hanspeter

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to