From owner-freebsd-hackers Tue Oct 29 13:25: 3 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 BD78D37B401 for ; Tue, 29 Oct 2002 13:25:01 -0800 (PST) Received: from flamingo.mail.pas.earthlink.net (flamingo.mail.pas.earthlink.net [207.217.120.232]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4CE0343E88 for ; Tue, 29 Oct 2002 13:25:01 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0057.cvx22-bradley.dialup.earthlink.net ([209.179.198.57] helo=mindspring.com) by flamingo.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 186drA-0001wm-00 for freebsd-hackers@FreeBSD.ORG; Tue, 29 Oct 2002 13:25:00 -0800 Message-ID: <3DBEFC5A.5468CADD@mindspring.com> Date: Tue, 29 Oct 2002 13:23:38 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.ORG Subject: Re: Patch to allow a driver to report unrecoverable write errors to the buf layer References: <20021029182712.A1479@gicco.homeip.net> <94460.1035912876@critter.freebsd.dk> <20021029184724.A1682@gicco.homeip.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Hanspeter Roth wrote: > On Oct 29 at 18:34, Poul-Henning Kamp spoke: > > 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. > > Isn't there a means to determine the state of the protection before > the mount is attempted? You can write 0x04ss (sense drive status on standard parameter for drive and head select 'ss') to port 0x03F5; then read disk status register 3 for one byte: bit meaning --- ------------ 7 No drive fault 6 Write protected (1 = protected) 5 Drive ready (1 = ready) 4 Head is on track zero (1 = on track 0) 3 Two sided (1 = two sided, 0 = one sided) 2 Head select (0 = side 0, 1 = side 1) 1 | 0 | bit 1 bit 0 meaning ----- ----- ------------ 0 0 drive 0 selected 0 1 drive 1 selected 1 0 drive 2 selected 1 1 drive 3 selected You can detect "disk change" by selecting a sidk, and then reading 0x03F7 (this works on all PC hardware on or after the IBM PC AT). The byte you read is only interesting for bit 7, unless you can verify that specific controller being used. If bit 7 is zero, then there is a disk present, and it has not been changed. If bit 7 is set, then there is no diskette present, or the disk has not been changed. Therefore, by repeating this operation twice, and seeing a 1 -> 0 transition for bit 7, you can tell a disk is present, or seeing a 1 -> 1 persistance, you can tell there is no disk present (e.g. you will need to save "one behind" on status for this to be useful in detecting both changes and missing disks). Note that this works on 3.5" disks, but only works on 5.25" disks that are 1.2M or larger. In addition, many systems fail to wire up the "disk change" or "disk present" lines from the floppy drive to the controller, hard wiring the disk as being present and unchanged at all times. So "disk change" is unreliable. "If all else fails, read the documentation..." -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message