Hi !
After investigating a bit further the issue, I believe that the
appended patch makes installboot(8) behave correctly. I removed
extended partition numbering, since in would always print '1'. Last
hunk is merely a typo fix.
Comments are welcome.
Cheers,
hyjial.
Index: installboot.c
===================================================================
RCS file: /cvs/openbsd/src/sys/arch/i386/stand/installboot/installboot.c,v
retrieving revision 1.55
diff -u -r1.55 installboot.c
--- installboot.c 30 May 2009 23:13:18 -0000 1.55
+++ installboot.c 3 Sep 2009 07:25:28 -0000
@@ -94,7 +94,7 @@
static void sym_set_value(struct sym_data *, char *, u_int32_t);
static void pbr_set_symbols(char *, char *, struct sym_data *);
static void usage(void);
-static long findopenbsd(int, struct disklabel *, off_t, int *);
+static long findopenbsd(int, struct disklabel *, off_t, off_t, int *);
static void
usage(void)
@@ -196,7 +196,8 @@
if (dl.d_type != 0 && dl.d_type != DTYPE_FLOPPY &&
dl.d_type != DTYPE_VND) {
/* Find OpenBSD partition. */
- start = findopenbsd(devfd, &dl, (off_t)DOSBBSECTOR, &n);
+ start = findopenbsd(devfd, &dl, (off_t)DOSBBSECTOR,
+ (off_t)DOSBBSECTOR, &n);
if (start == -1)
errx(1, "no OpenBSD partition");
startoff = (off_t)start * dl.d_secsize;
@@ -213,8 +214,13 @@
return 0;
}
-long
-findopenbsd(int devfd, struct disklabel *dl, off_t mbroff, int *n)
+/*
+ * Find the partition we live on from MBR.
+ * mbroff: absolute offset of the boot record we are going to delve in.
+ * base: base of the offsets we are going to find.
+ */
+static long
+findopenbsd(int devfd, struct disklabel *dl, off_t mbroff, off_t base, int *n)
{
struct dos_mbr mbr;
struct dos_partition *dp;
@@ -239,19 +245,19 @@
if (dp->dp_typ == DOSPTYP_OPENBSD) {
if (verbose)
fprintf(stderr,
- "using MBR partition %ld: type 0x%02X
offset %d\n",
+ "using MBR partition %ld: type 0x%02X
offset %lld\n",
(long)(dp - mbr.dmbr_parts),
- dp->dp_typ, dp->dp_start);
- return (dp->dp_start + mbroff);
+ dp->dp_typ, dp->dp_start + base);
+ return (dp->dp_start + base);
} else if (dp->dp_typ == DOSPTYP_EXTEND ||
dp->dp_typ == DOSPTYP_EXTENDL) {
if (verbose)
fprintf(stderr,
- "extended partition %ld: type 0x%02X offset
%d\n",
- (long)(dp - mbr.dmbr_parts),
- dp->dp_typ, dp->dp_start);
- startoff = (off_t)dp->dp_start + mbroff;
- start = findopenbsd(devfd, dl, startoff, n);
+ "extended partition: type 0x%02X offset
%lld\n",
+ dp->dp_typ, dp->dp_start + base);
+ startoff = (off_t)dp->dp_start + base;
+ start = findopenbsd(devfd, dl, startoff,
+ base == DOSBBSECTOR ? startoff : base, n);
if (start != -1)
return (start);
}
@@ -539,7 +545,7 @@
wp = (u_int16_t *) vp;
*wp = (u_int16_t) sym->sym_value;
break;
- case 1: /* u_int16_t */
+ case 1: /* u_int8_t */
if (sym->sym_value >= 0x100) /* out of range */
errx(1, "%s: symbol out of range (%u)",
sym->sym_name, sym->sym_value);