*BSD News Article 8169


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.hawaii.edu!ames!sun-barr!cs.utexas.edu!uunet!mcsun!fuug!kiae!demos!newsserv
From: "Andrew A. Chernov, Black Mage" <ache@astral.msk.su>
Newsgroups: comp.unix.bsd
Subject: Patch for wd.c (partition offset, pcfs)
Date: Wed, 25 Nov 92 11:17:28 +0300
Distribution: world
Organization: Ha-oh-lahm Yetzirah
Message-ID: <aEOQp4hiD0@astral.msk.su>
Sender: news-service@newcom.kiae.su
Reply-To: ache@astral.msk.su
Keywords: offset partition pcfs
Lines: 42

Hi, I found this bug when I try pcfs.
wd.c driver don't compute partition offset correctly (it lost sectors).
wd.c assumed, that any partition start only with cylinder boundary,
but for MSDOS it is wrong.
I looking for this bug in as.c driver, but everything is OK there.

Fix are very simple and follows:

*** wd.c.was	Sun Nov 22 02:50:57 1992
--- wd.c	Wed Nov 25 10:02:30 1992
***************
*** 397,408 ****
  	lp = &du->dk_dd;
  	secpertrk = lp->d_nsectors;
  	secpercyl = lp->d_secpercyl;
  	cylin = blknum / secpercyl;
  	head = (blknum % secpercyl) / secpertrk;
  	sector = blknum % secpertrk;
- 	if ((du->dk_flags & DKFL_BSDLABEL) != 0 && wdpart(bp->b_dev) != WDRAW)
- 		cylin += lp->d_partitions[wdpart(bp->b_dev)].p_offset
- 				/ secpercyl;
  
  	/* 
  	 * See if the current block is in the bad block list.
--- 397,407 ----
  	lp = &du->dk_dd;
  	secpertrk = lp->d_nsectors;
  	secpercyl = lp->d_secpercyl;
+ 	if ((du->dk_flags & DKFL_BSDLABEL) != 0 && wdpart(bp->b_dev) != WDRAW)
+ 		blknum += lp->d_partitions[wdpart(bp->b_dev)].p_offset;
  	cylin = blknum / secpercyl;
  	head = (blknum % secpercyl) / secpertrk;
  	sector = blknum % secpertrk;
  
  	/* 
  	 * See if the current block is in the bad block list.
-- 
In-This-Life:  Andrew A. Chernov    |  "Hay mas dicha, mas contento
Internet:      ache@astral.msk.su   |  "Que adorar una hermosura
Organization:  The RELCOM Corp.,    |  "Brujuleada entre los lejos
               Moscow, Russia       |  "De lo imposible?!"  (Calderon)