*BSD News Article 34776


Return to BSD News archive

Newsgroups: comp.os.386bsd.development
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!constellation!convex!hermes.oc.com!news.unt.edu!cs.utexas.edu!howland.reston.ans.net!agate!tfs.com!julian
From: julian@tfs.com (Julian Elischer)
Subject: [FreeBSD] patch to allow mounting of DOS drives
Message-ID: <CuxDFB.1nv@tfs.com>
Organization: TRW Financial Systems, Oakland, CA
References: <32uvui$dov@Venus.mcs.com> <331b5v$q00@u.cc.utah.edu> <334mjf$1ku@euterpe.owl.de>
Date: Mon, 22 Aug 1994 07:13:58 GMT
Lines: 186

Ok, here is a patch that I THINK should allow people to mount 
undisklabeled drives and see their DOS partitions.

the four MBR (DOS OS2 or whatever) partitions should appear
as partitions e,f,g and h
e.g. rsd0e or rwd0e through rwd0h.

If you have a disklabel that get's preference.

I cannot test this here, so can someone out there
please report back to me whether this works.


julian

*********************cut here
*** ufs_disksubr.c.orig	Sun Aug 21 22:51:21 1994
--- ufs_disksubr.c	Sun Aug 21 23:52:05 1994
***************
*** 177,182 ****
--- 177,184 ----
  	struct disklabel *dlp;
  	char *msg = NULL;
  	int cyl, dospartoff, i;
+ 	int pseudopart = 4; 	/* we fill in pseudoparts from e through h*/
+ 	int seenBSD = 0;
  
  	/* minimal requirements for archtypal disk label */
  	if (lp->d_secperunit == 0)
***************
*** 185,190 ****
--- 187,198 ----
  	if (lp->d_partitions[0].p_size == 0)
  		lp->d_partitions[0].p_size = 0x1fffffff;
  	lp->d_partitions[0].p_offset = 0;
+ 	lp->d_partitions[1].p_size = 0;
+ 	lp->d_partitions[1].p_offset = 0;
+ 	lp->d_partitions[2].p_size = 0;
+ 	lp->d_partitions[2].p_offset = 0;
+ 	lp->d_partitions[3].p_size = 0;
+ 	lp->d_partitions[3].p_offset = 0;
  
  	/* obtain buffer to probe drive with */
  	bp = geteblk((int)lp->d_secsize);
***************
*** 205,243 ****
  		bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
  		(*strat)(bp);
  
! 		/* if successful, wander through dos partition table */
  		if (biowait(bp)) {
  			msg = "dos partition I/O error";
  			goto done;
! 		} else {
! 			/* XXX how do we check veracity/bounds of this? */
! 			bcopy(bp->b_un.b_addr + DOSPARTOFF, dp,
! 				NDOSPART * sizeof(*dp));
! 			for (i = 0; i < NDOSPART; i++, dp++)
! 				/* is this ours? */
! 				if (dp->dp_size &&
! 					dp->dp_typ == DOSPTYP_386BSD
! 					&& dospartoff == 0) {
  
! 					/* need sector address for SCSI/IDE,
! 					   cylinder for ESDI/ST506/RLL */
  					dospartoff = dp->dp_start;
! 					cyl = DPCYL(dp->dp_scyl, dp->dp_ssect);
! 
! 					/* update disklabel with details */
  					lp->d_partitions[0].p_size =
  						dp->dp_size;
  					lp->d_partitions[0].p_offset = 
  						dp->dp_start;
- 					lp->d_ntracks = dp->dp_ehd + 1;
- 					lp->d_nsectors = DPSECT(dp->dp_esect);
- 					lp->d_subtype |= (lp->d_subtype & 3)
- 							+ i | DSTYPE_INDOSPART;
- 					lp->d_secpercyl = lp->d_ntracks *
- 						lp->d_nsectors;
  				}
  		}
! 			
  	}
  	
  	/* next, dig out disk label */
--- 213,303 ----
  		bp->b_cylin = DOSBBSECTOR / lp->d_secpercyl;
  		(*strat)(bp);
  
! 		/*
! 		 * if we failed in the read, give up.
! 		 */
  		if (biowait(bp)) {
  			msg = "dos partition I/O error";
  			goto done;
! 		} 
! 		/*
! 		 * If there seems to be  BIOS bootblock and partition table
! 		 * in that block, then try interpret it, otherwise
! 		 * give up and use whatever we have synthesised so far
! 		 */
! 		if ((bp->b_un.b_addr[510] |= 0x55)
! 		  ||(bp->b_un.b_addr[511] |= 0xaa)) {
! 			msg = "Disk has no Fdisk partitions";
! 			goto done;
! 		}
  
! 		/* XXX how do we check veracity/bounds of this? */
! 		bcopy(bp->b_un.b_addr + DOSPARTOFF, dp,
! 			NDOSPART * sizeof(*dp));
! 		/*
! 		 * We set up the last 4 partitions in the 
! 		 * disklabel to reflect the DOS partitions 
! 		 * In case we never find a disklabel, in which
! 		 * case this information will be all we have
! 		 * but it might be all we need to access a DOS
! 		 * partition.
! 		 */
! 		for (i = 0; i < NDOSPART; i++, dp++,pseudopart++) {
! 
! 			/*
! 			 * Set this DOS part into the disklabel
! 			 */
! 			lp->d_partitions[pseudopart].p_size = 
! 				dp->dp_size;
! 			lp->d_partitions[pseudopart].p_offset = 
! 				dp->dp_start;
! 			/*
! 			 * If we haven't seen a *BSD partition then
! 			 * check if this is a valid part..
! 			 * if it is it may be the best we are going to
! 			 * to see, so take note of it to deduce a 
! 			 * geometry in case we never find a disklabel.
! 			 */
! 			if (dp->dp_size && (seenBSD == 0)) {
! 				if( dp->dp_typ == DOSPTYP_386BSD) {
! 					/*
! 					 * If it IS our part, then we
! 					 * need sector address for
! 					 * SCSI/IDE, cylinder for
! 					 * ESDI/ST506/RLL
! 					 */
  					dospartoff = dp->dp_start;
! 					seenBSD = 1;
! 					cyl = DPCYL(dp->dp_scyl,
! 						dp->dp_ssect);
! 
! 					/*
! 					 * update disklabel with
! 					 * details for reading the REAL
! 					 * disklabel it it exists 
! 					 */
  					lp->d_partitions[0].p_size =
  						dp->dp_size;
  					lp->d_partitions[0].p_offset = 
  						dp->dp_start;
  				}
+ 				/*
+ 				 * Try deduce the geometry, working
+ 				 * on the principle that  this
+ 				 * partition PROBABLY ends on a 
+ 				 * cylinder boundary.
+ 				 * This is really a kludge, but we are
+ 				 * forced into it by the PC's design.
+ 				 */
+ 				lp->d_ntracks = dp->dp_ehd + 1;
+ 				lp->d_nsectors = DPSECT(dp->dp_esect);
+ 				lp->d_subtype |= (lp->d_subtype & 3)
+ 						+ i | DSTYPE_INDOSPART;
+ 				lp->d_secpercyl = lp->d_ntracks *
+ 					lp->d_nsectors;
+ 			}
  		}
! 		lp->d_npartitions = 8;
  	}
  	
  	/* next, dig out disk label */
*********************cut here
+----------------------------------+       ______ _  __
|   __--_|\  Julian Elischer       |       \     U \/ / On assignment
|  /       \ julian@tfs.com        +------>x   USA    \ in a very strange
| (   OZ    ) 300 lakeside Dr. oakland CA. \___   ___ | country !
+- X_.---._/  USA+(510) 645-3137(wk)           \_/   \\            
          v