From owner-freebsd-hackers Thu Oct 31 6: 0:22 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4B60437B404 for ; Thu, 31 Oct 2002 06:00:20 -0800 (PST) Received: from smtp.www-service.de (smtp.www-service.de [212.77.161.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id A1C2843E4A for ; Thu, 31 Oct 2002 06:00:18 -0800 (PST) (envelope-from thz@Lennartz-electronic.de) Received: from swd2.tue.le (pD90065DE.dip.t-dialin.net [217.0.101.222]) by smtp.www-service.de (8.11.6/8.11.6) with ESMTP id g9VFHBX10723; Thu, 31 Oct 2002 16:17:12 +0100 Received: from mezcal.tue.le (mezcal.tue.le [192.168.201.20]) by swd2.tue.le (8.12.6/8.12.6) with ESMTP id g9VDxsdt051016; Thu, 31 Oct 2002 14:59:54 +0100 (CET) (envelope-from thz@mezcal.tue.le) Received: from mezcal.tue.le (localhost [127.0.0.1]) by mezcal.tue.le (8.12.6/8.12.3) with ESMTP id g9VDxs1D000512; Thu, 31 Oct 2002 14:59:54 +0100 (CET) (envelope-from thz@mezcal.tue.le) Received: (from thz@localhost) by mezcal.tue.le (8.12.6/8.12.6/Submit) id g9VDxqeP000511; Thu, 31 Oct 2002 14:59:52 +0100 (CET) Date: Thu, 31 Oct 2002 14:59:52 +0100 From: Thomas Zenker To: Poul-Henning Kamp Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Patch to allow a driver to report unrecoverable write errors to the buf layer Message-ID: <20021031145952.A457@mezcal.tue.le> Mail-Followup-To: Poul-Henning Kamp , freebsd-hackers@FreeBSD.ORG References: <20021029182712.A1479@gicco.homeip.net> <94460.1035912876@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <94460.1035912876@critter.freebsd.dk>; from phk@critter.freebsd.dk on Tue, Oct 29, 2002 at 06:34:36PM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Oct 29, 2002 at 06:34:36PM +0100, Poul-Henning Kamp wrote: > In message <20021029182712.A1479@gicco.homeip.net>, Hanspeter Roth writes: > > On Oct 18 at 20:45, Maxim Sobolev spoke: > > > >> again, then again ad infinitum. The same effect if you'll mount > >> write-protected floppy in read/write mode. > > This is just lame, but I'm not willing to to take a shouting match > with the person who committed this brain-damage. > > >As of a write-protected floppy, why is it allowd to be mounted as > >writeable? > >The mount should be degraded to readonly or rejected. > > 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 c/o Lennartz electronic GmbH Bismarckstrasse 136, D-72072 Tuebingen, Germany Phone: +49-(0)7071-93550 Email: thz@lennartz-electronic.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message