Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Jul 2002 23:36:33 +0200 (CEST)
From:      Mark Kettenis <kettenis@chello.nl>
To:        timon@memphis.mephi.ru
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Booting FreeBSD from extended partitions
Message-ID:  <200207212136.g6LLaXBv079668@elgar.kettenis.dyndns.org>
In-Reply-To: <20020721180623.A32258@memphis.mephi.ru> (timon@memphis.mephi.ru)
References:  <20020720174745.A33016@memphis.mephi.ru> <20020721020952.4e61aefc.brad@brad-x.com> <20020721180623.A32258@memphis.mephi.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
   From: "Artem 'Zazoobr' Ignatjev" <timon@memphis.mephi.ru>
   Date: Sun, 21 Jul 2002 18:06:24 +0400

   On Sun, Jul 21, 2002 at 02:09:52AM -0400, Brad Laue wrote:
    >> 	I'm currently trying to make FreeBSD boot from extended
    >> partitions (of course, with help of boot mgr - in my case that's WinNT
    >> loader), and not without any progress: After patching /boot/loader to
    >> understand EXT_X partition type, I'm able to  boot  from /dev/ad4s9.
    > 
    > I'd be very interested in seeing your progress on this, and I think 
    > Simon 'corecode' Schultz would be as well - looking forward to it! 
    > Attach it to your reply.
     Well, I don't think that all subcribers of this list wants to see this
    staff, and don't know whether majordomo allows attaches in this list.
     I will email it to you, and if anyone else is interested in this work,
    I'd put it here: http://memphis.mephi.ru/~timon/
			   Sinceherely yours, Artem 'Zazoobr' Ignatjev.

In case you're wondering why you can't boot from /dev/ad4s10 and
above, take a look at the attached patch for vfs_conf.c.  I also
included my version of a patch to fix the problems with extended
partitions in /boot/loader.  I didn't look too closely at your code,
but my patch arranges things such that the slice numbers used by
/boot/loader match the slice numbers used by the kernel.

I didn't look at boot0 and boot1 since I'm using GRUB on my system.

Mark

PS The patches are against 4.6-STABLE from a week ago or so.

--- /usr/src/sys/boot/i386/libi386/biosdisk.c.orig	Thu Dec 28 14:10:47 2000
+++ /usr/src/sys/boot/i386/libi386/biosdisk.c	Sat Jul 13 03:30:53 2002
@@ -132,7 +132,8 @@ struct devsw biosdisk = {
 static int	bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev);
 static void	bd_closedisk(struct open_disk *od);
 static int	bd_bestslice(struct open_disk *od);
-static void	bd_checkextended(struct open_disk *od, int slicenum);
+static void	bd_checkextended(struct open_disk *od,
+				 struct dos_partition *dp, u_int ext_base);
 
 /*
  * Translate between BIOS device numbers and our private unit numbers.
@@ -308,6 +309,7 @@ bd_printslice(struct open_disk *od, stru
 		break;
 	case 0x00:				/* unused partition */
 	case DOSPTYP_EXT:
+	case 0x0f:
 		return;
 	case 0x01:
 		if (verbose)
@@ -512,7 +514,7 @@ bd_opendisk(struct open_disk **odp, stru
       sizeof(struct dos_partition) * NDOSPART);
     od->od_nslices = 4;			/* extended slices start here */
     for (i = 0; i < NDOSPART; i++)
-        bd_checkextended(od, i);
+        bd_checkextended(od, &od->od_slicetab[i], od->od_slicetab[i].dp_start);
     od->od_flags |= BD_PARTTABOK;
     dptr = &od->od_slicetab[0];
 
@@ -624,22 +626,21 @@ bd_opendisk(struct open_disk **odp, stru
 }
 
 static void
-bd_checkextended(struct open_disk *od, int slicenum)
+bd_checkextended(struct open_disk *od, struct dos_partition *dp,
+		 u_int ext_base)
 {
-	char	buf[BIOSDISK_SECSIZE];
-	struct dos_partition *dp;
+	char buf[BIOSDISK_SECSIZE];
 	u_int base;
-	int i, start, end;
-
-	dp = &od->od_slicetab[slicenum];
-	start = od->od_nslices;
+	int i;
 
 	if (dp->dp_size == 0)
 		goto done;
-	if (dp->dp_typ != DOSPTYP_EXT)
+	if (dp->dp_typ != DOSPTYP_EXT && dp->dp_typ != 0x0f)
 		goto done;
-	if (bd_read(od, (daddr_t)dp->dp_start, 1, buf))
+	if (bd_read(od, (daddr_t)dp->dp_start, 1, buf)) {
+		DEBUG("error reading extended table");
 		goto done;
+	}
 	if (((u_char)buf[0x1fe] != 0x55) || ((u_char)buf[0x1ff] != 0xaa)) {
 		DEBUG("no magic in extended table");
 		goto done;
@@ -651,17 +652,17 @@ bd_checkextended(struct open_disk *od, i
 			continue;
 		if (od->od_nslices == MAX_SLICES)
 			goto done;
-		dp->dp_start += base;
-		bcopy(dp, &od->od_slicetab[od->od_nslices], sizeof(*dp));
-		od->od_nslices++;
+		if (dp->dp_typ == DOSPTYP_EXT || dp->dp_typ == 0x0f) {
+			dp->dp_start += ext_base;
+			bd_checkextended(od, dp, ext_base);
+		} else {
+			dp->dp_start += base;
+			bcopy(dp, &od->od_slicetab[od->od_nslices],
+			      sizeof(*dp));
+			od->od_nslices++;
+		}
 	}
-	end = od->od_nslices;
 
-	/*
-	 * now, recursively check the slices we just added
-	 */
-	for (i = start; i < end; i++)
-		bd_checkextended(od, i);
 done:
 	return;
 }
--- /usr/src/sys/kern/vfs_conf.c.orig	Mon Feb  4 14:08:12 2002
+++ /usr/src/sys/kern/vfs_conf.c	Fri Jul 12 17:34:02 2002
@@ -356,8 +356,10 @@ gotit:
 	while (*cp >= '0' && *cp <= '9')
 		unit = 10 * unit + *cp++ - '0';
 	if (*cp == 's' && cp[1] >= '0' && cp[1] <= '9') {
-		slice = cp[1] - '0' + 1;
-		cp += 2;
+		cp++;
+		while (*cp >= '0' && *cp <= '9')
+			slice = 10 * slice + *cp++ - '0';
+		slice++;
 	}
 	if (*cp >= 'a' && *cp <= 'h') {
 		part = *cp - 'a';




   To Unsubscribe: send mail to majordomo@FreeBSD.org
   with "unsubscribe freebsd-hackers" in the body of the message



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207212136.g6LLaXBv079668>