DragonFly submit List (threaded) for 2004-12
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
[PATCH] for /boot/loader
This is my first working version which actually will boot from
an extended(logical) slice -- which implies that DFly could now
be installed to an extended partition if desired.
There is at least one minor annoyance with this version. The
loader churns the hard drive more than it should while reading
the DOS partition table because it invokes my new code many,
many times. This should not happen, it seems to me -- how
many times does it need to check for extended partitions,
after all? I think there is an additional design problem
somewhere else in the loader that I haven't looked for yet.
Anyway, I'd appreciate some testing and feedback on this
first attempt:
--- src/sys/boot/i386/libi386/biosdisk.c.orig 2004-12-07 14:59:39.000000000 -0800
+++ src/sys/boot/i386/libi386/biosdisk.c 2004-12-13 06:52:13.000000000 -0800
@@ -135,7 +135,7 @@
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_chainextended(struct open_disk *od, u_int32_t base, u_int32_t offset);
/*
* Translate between BIOS device numbers and our private unit numbers.
@@ -521,9 +521,14 @@
*/
bcopy(buf + DOSPARTOFF, &od->od_slicetab,
sizeof(struct dos_partition) * NDOSPART);
- od->od_nslices = 4; /* extended slices start here */
- for (i = 0; i < NDOSPART; i++)
- bd_checkextended(od, i);
+ od->od_nslices = 3; /* extended slices start here */
+
+ dptr = &od->od_slicetab[0];
+ for (i = 0; i < NDOSPART; i++, dptr++)
+ {
+ if ((dptr->dp_typ == DOSPTYP_EXT) || (dptr->dp_typ == DOSPTYP_EXTLBA))
+ bd_chainextended(od, dptr->dp_start, 0); /* 1st offset is zero */
+ }
od->od_flags |= BD_PARTTABOK;
dptr = &od->od_slicetab[0];
@@ -637,46 +642,34 @@
return(error);
}
+
static void
-bd_checkextended(struct open_disk *od, int slicenum)
+bd_chainextended(struct open_disk *od, u_int32_t base, u_int32_t offset)
{
- char buf[BIOSDISK_SECSIZE];
- struct dos_partition *dp;
- u_int base;
- int i, start, end;
-
- dp = &od->od_slicetab[slicenum];
- start = od->od_nslices;
+ char buf[BIOSDISK_SECSIZE];
+ struct dos_partition *dp1, *dp2;
- if (dp->dp_size == 0)
- goto done;
- if (dp->dp_typ != DOSPTYP_EXT)
- goto done;
- if (bd_read(od, (daddr_t)dp->dp_start, 1, buf))
- goto done;
- if (((u_char)buf[0x1fe] != 0x55) || ((u_char)buf[0x1ff] != 0xaa)) {
- DEBUG("no magic in extended table");
- goto done;
- }
- base = dp->dp_start;
- dp = (struct dos_partition *)(&buf[DOSPARTOFF]);
- for (i = 0; i < NDOSPART; i++, dp++) {
- if (dp->dp_size == 0)
- continue;
- if (od->od_nslices == NEXTDOSPART)
- goto done;
- dp->dp_start += base;
- bcopy(dp, &od->od_slicetab[od->od_nslices], sizeof(*dp));
- od->od_nslices++;
+ if (bd_read(od, (daddr_t)(base + offset), 1, buf)) {
+ printf("\nerror reading extended partition table");
+ return;
}
- end = od->od_nslices;
+
+ od->od_nslices++; /* number of slices */
+ dp2 = &od->od_slicetab[od->od_nslices]; /* ptr to in-memory partition table */
+
+ dp1 = (struct dos_partition *)(&buf[DOSPARTOFF]); /* 1st record in on-disk XPT*/
+ /* set up in-memory PT record */
+ /* I left out cyl/head fields. Do we need them? */
+ dp2->dp_typ = dp1->dp_typ;
+ dp2->dp_start = base + offset + dp1->dp_start; /* first sector of XP */
+ dp2->dp_size = dp1->dp_size;
+
+ dp1++ ; /* 2nd record in XPT has offset to next XPT */
+
+ /* a pox on recursion */
+ if ((dp1->dp_typ == DOSPTYP_EXT) || (dp1->dp_typ == DOSPTYP_EXTLBA))
+ bd_chainextended(od, base, dp1->dp_start);
- /*
- * now, recursively check the slices we just added
- */
- for (i = start; i < end; i++)
- bd_checkextended(od, i);
-done:
return;
}
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]