From 0f15ab39ec1213567e2fd8dc254dd4cdaf82d380 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Mon, 8 May 1995 02:02:56 +0000 Subject: [PATCH] Make disk.c smart enough to handle disk with "OnTrack Disk manager". Make it complain if people try to boot from a partition which extends past 1024 cylinders. This is better than a random reset... --- sys/i386/boot/biosboot/disk.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/i386/boot/biosboot/disk.c b/sys/i386/boot/biosboot/disk.c index 0c7974c1ba39..f7c0fd507299 100644 --- a/sys/i386/boot/biosboot/disk.c +++ b/sys/i386/boot/biosboot/disk.c @@ -24,7 +24,7 @@ * the rights to redistribute these changes. * * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd - * $Id: disk.c,v 1.8 1995/02/16 15:06:09 bde Exp $ + * $Id: disk.c,v 1.9 1995/04/14 21:26:50 joerg Exp $ */ /* @@ -85,7 +85,8 @@ devopen(void) struct dos_partition *dptr; struct disklabel *dl; int dosdev = inode.i_dev; - int i, sector, di; + int i, sector = 0, di; + u_long bend; di = get_diskinfo(dosdev); spc = (spt = SPT(di)) * HEADS(di); @@ -101,15 +102,14 @@ devopen(void) #else EMBEDDED_DISKLABEL Bread(dosdev, 0); dptr = (struct dos_partition *)(((char *)0)+DOSPARTOFF); - sector = LABELSECTOR; slice = WHOLE_DISK_SLICE; for (i = 0; i < NDOSPART; i++, dptr++) if (dptr->dp_typ == DOSPTYP_386BSD) { slice = BASE_SLICE + i; - sector = dptr->dp_start + LABELSECTOR; + sector = dptr->dp_start; break; } - Bread(dosdev, sector++); + Bread(dosdev, sector + LABELSECTOR); dl=((struct disklabel *)0); disklabel = *dl; /* structure copy (maybe useful later)*/ #endif EMBEDDED_DISKLABEL @@ -128,9 +128,19 @@ devopen(void) maj = 0; /* must be ESDI/IDE */ } } - boff = dl->d_partitions[part].p_offset; -#ifdef DO_BAD144 + /* This little trick is for OnTrack DiskManager disks */ + boff = dl->d_partitions[part].p_offset - + dl->d_partitions[2].p_offset + sector; + + /* This is a good idea for all disks */ bsize = dl->d_partitions[part].p_size; + bend = boff + bsize - 1 ; + if (bend / spt > 1024) { + printf("partition is out of reach from the bios\n"); + return 1; + } + +#ifdef DO_BAD144 do_bad144 = 0; if (dl->d_flags & D_BADSECT) { /* this disk uses bad144 */