*BSD News Article 5172


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel!munnari.oz.au!uunet!wupost!sdd.hp.com!spool.mu.edu!agate!dog.ee.lbl.gov!news!nosc!crash!fpm
From: fpm@crash.cts.com (Frank Maclachlan)
Subject: Bug in 386BSD 0.1 wd driver (w/ fix)
Organization: CTS Network Services (crash, ctsnet), El Cajon, CA
Date: 17 Sep 92 04:29:27 PDT
Message-ID: <1992Sep17.042929.27835@crash>
Followup-To: comp.unix.bsd
Summary: Errors on raw wd device not reported
Keywords: wd, bug, patch
References: <9226116.6625@mulga.cs.mu.OZ.AU>
Lines: 62

----------------------------BUG REPORT------------------------
Name: Frank MacLachlan
Email address: fpm@crash.cts.com
Date: 92/09/16


Hardware info:
    ISA mb w/ OPTi chip set, AMD 386DX/40, 64kb cache & AMI bios
    16 mb ram
    STB SVGA
    Western Digital WD1007V-SE2 ESDI HD/FD controller
    Imprimus 94166-182 182 mb ESDI hard disk


Problem description: 
    I/O errors are not reported when reading/writing from/to the raw
    wd disk device.  I noticed this when using 'dd' to scan a disk
    w/ known bad blocks and couldn't find any.

    The wd driver, '/sys/i386/isa/wd.c', sets the B_ERROR bit in
    bp->b_flags at lines 533 and 553, but fails to put an error code
    into bp->b_error.  Physio() in '/sys/kern/kern__physio.c', which
    manages the raw I/O in this case, ignores the B_ERROR bit in b_flags
    and looks for an error code in b_error.  The user program is fed
    garbage data and no clue that an error occurred.


Problem suspicions:


Solution:
    Apply the following patch to '/sys/i386/isa/wd.c'.  The patch
    assumes that you are patching a virgin wd.c; if not you'll have
    to apply the changes manually.
    

*** wd.c.ORIG	Wed Sep 16 23:32:01 1992
--- wd.c	Wed Sep 16 23:33:35 1992
***************
*** 530,535 ****
--- 530,536 ----
  		}
  #ifdef B_FORMAT
  		if (bp->b_flags & B_FORMAT) {
+ 			bp->b_error = EIO; 
  			bp->b_flags |= B_ERROR;
  			goto done;
  		}
***************
*** 550,555 ****
--- 551,557 ----
  						inb(wdc+wd_error), WDERR_BITS);
  #endif
  				}
+ 				bp->b_error = EIO; 
  				bp->b_flags |= B_ERROR;	/* flag the error */
  			}
  		} else if((du->dk_flags&DKFL_QUIET) == 0) {
----------------------------------------------------------------
UUCP: {hplabs!hp-sdd ucsd nosc}!crash!fpm
ARPA: crash!fpm@nosc.mil
INET: fpm@crash.cts.com