[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 2.4 install problem => looks like lseek or compiler bug



Michael Shalayeff wrote:

> [ WHS: ]
> > I also did this (from linux):
> > dd if=/dev/hda4 of=hda4.txt bs=8k count=1
> don't know what hda4 means, but i trust you (;
> 
> > to see if the PBR of the obsd partition is ok, but it gives all 0's for
> > the first 512 b, then:
> >
> > 0200  57 45 56 82 05 00 00 00   WEV.....
> > 0208  45 53 44 49 2F 49 44 45   ESDI/IDE
> > 0210  20 64 69 73 6B 00 00 00    disk...
> > 0218  51 55 41 4E 54 55 4D 20   QUANTUM
> > 0220  46 49 52 45 42 41 4C 4C   FIREBALL
> > 0228  00 02 00 00 3F 00 00 00   ....?...
> > 0230  0F 00 00 00 23 3E 00 00   ....#>..
> > 0238  B1 03 00 00 33 5F E5 00   ....3_..
> > 0240  00 00 00 00 00 00 00 00   ........
> > 0248  10 0E 01 00 00 00 00 00   ........
> > 0250  00 00 00 00 00 00 00 00   ........
> > 0258  00 00 00 00 00 00 00 00   ........
> > 0260  00 00 00 00 00 00 00 00   ........
> > 0268  00 00 00 00 00 00 00 00   ........
> > 0270  00 00 00 00 00 00 00 00   ........
> > 0278  00 00 00 00 00 00 00 00   ........
> > 0280  00 00 00 00 57 45 56 82   ....WEV.
> > 0288  44 82 10 00 00 20 00 00   D.... ..
> > 0290  00 00 01 00 73 41 4B 00   ....sAK.
> > 0298  A3 C6 95 00 00 04 00 00   ........
> > 02A0  07 08 10 00 10 EC 03 00   ........
> >
> > etc.
> yeah, that's disklabel...
> 
> > The first 512 b should be biosboot (with a few changes for the file
> > positions and minus the first 32 bytes and the rest at the end) right?
> it's finnaly coming times w/ smart openbsd users! (;

;-)

Ok, I checked the source for installboot:

#		/* Find OpenBSD partition. */
#		for (dp = mbr.dmbr_parts; dp < &mbr.dmbr_parts[NDOSPART]; dp++) {
#			if (dp->dp_size && dp->dp_typ == DOSPTYP_OPENBSD) {
#				startoff = dp->dp_start * dl.d_secsize;
#				fprintf(stderr, "using MBR partition %d: "
#					"type %d (0x%02x) offset %d (0x%x)\n",
#					dp - mbr.dmbr_parts,
#					dp->dp_typ, dp->dp_typ,
#					dp->dp_start, dp->dp_start);
#				break;
#			}
#		}
#		/* don't check for old part number, that is ;-p */
#		if (dp >= &mbr.dmbr_parts[NDOSPART])
#			errx(1, "no OpenBSD partition");
#	}

This looks Ok to me, but I would like to see the sector size shown along with the offset, e.g.:

				fprintf(stderr, "using MBR partition %d: "
					"type %d (0x%02x) sector offset %d (0x%x) [sector size %d]\n",
					dp - mbr.dmbr_parts,
					dp->dp_typ, dp->dp_typ,
					dp->dp_start, dp->dp_start
					dl.d_secsize);



#	if (!nowrite) {
#		if (lseek(devfd, startoff, SEEK_SET) < 0 ||
#		    write(devfd, protostore, protosize) != protosize)
#			err(1, "write bootstrap");
#	}


Note that the offset for my obsd partition is 611*255*63 = 9815715 sectors.
Now multiply this by 512 and  you get: 5025646080. This is larger than 2^32,
so I thought, lets see what's on the disk at position 5025646080 mod 2^32 = 730678784
(sector 1427107). (dd if=/dev/hda of=hda-dmp.txt skip=1427107 bs=512 count=10 from linux).

Surprise, surprise,

0000  EB 3C 90 4F 70 65 6E 42   .<.OpenB
0008  53 44 00 00 02 01 00 00   SD......
0010  00 00 00 00 00 F8 00 00   ........
0018  00 00 00 00 10 00 00 00   ........
0020  00 00 00 00 00 00 29 00   ......).
0028  00 00 00 55 4E 49 58 20   ...UNIX 
0030  4C 41 42 45 4C 00 55 46   LABEL.UF
0038  53 20 34 2E 34 00 66 EA   S 4.4.f.
0040  53 00 00 00 C0 07 72 65   S.....re
0048  61 64 69 6E 67 20 62 6F   ading bo
0050  6F 74 00 FA 31 C0 8E D0   ot..1...
0058  66 BC FC FF 00 00 FB B8   f.......
0060  C0 07 8E D8 8E C0 8E E0   ........
0068  8E E8 66 BE 46 00 00 00   ..f.F...
0070  E8 BD 00 B8 00 10 8E C0   ........
0078  66 31 DB 67 8A 0D 6E 01   f1.g..n.
0080  00 00 0F B6 C9 BE 6F 01   ......o.
0088  51 B0 2E E8 AF 00 FC AD   Q.......
0090  89 C1 AC 88 C6 AC B4 02   ........
0098  50 CD 13 73 1A 66 BE A8   P..s.f..
00A0  00 00 00 E8 8A 00 EB 3A   .......:
00A8  0D 0A 52 65 61 64 20 65   ..Read e

etc.

it's OBSD's PBR!

Thankfully that portion of the disk is empty so nothing is destroyed by installboot...

I checked sys/sys/types.h which has off_t as quad_t = int64_t so the offset calculation
should be ok). So this looks like a lseek or compiler bug to me.

various small changes:
======================
Btw, while going through some of the boot files, I saw this:
sys/arch/i386/stand/biosboot/biosboot.S, line 34:
#        .file   "bootbios.S"

should be 
#        .file   "biosboot.S"

of course.

Some more detail thingies:
man 8 boot, line 131:
#either of each maybe omitted (':' is not needed if both),

I think this should be reformulated to:
#each of which may be omitted (':' is not needed if both are omitted),


2.4/i386/INSTALL.linux, line 219:
#boot>machine diskconfig

should be:
#boot>machine diskinfo

-- 

Wouter