summaryrefslogtreecommitdiffstats
path: root/lib/libdisk/change.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-11-27 22:44:43 +0000
committerphk <phk@FreeBSD.org>1996-11-27 22:44:43 +0000
commited9e01dfb5dcdde4d033014058e9fc7df04ca038 (patch)
tree9fb1cc016b623756583741a10d1daed8ab959595 /lib/libdisk/change.c
parente27f332f23f4413cbe7306cd3449f92797a5df1e (diff)
downloadFreeBSD-src-ed9e01dfb5dcdde4d033014058e9fc7df04ca038.zip
FreeBSD-src-ed9e01dfb5dcdde4d033014058e9fc7df04ca038.tar.gz
Improve the Dangerously Dedidcated mode a bit. Not much, but a bit better.
Diffstat (limited to 'lib/libdisk/change.c')
-rw-r--r--lib/libdisk/change.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/lib/libdisk/change.c b/lib/libdisk/change.c
index 7d7f811..cc26020 100644
--- a/lib/libdisk/change.c
+++ b/lib/libdisk/change.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: change.c,v 1.9.2.1 1995/09/20 10:43:01 jkh Exp $
+ * $Id: change.c,v 1.10 1995/12/07 10:33:18 peter Exp $
*
*/
@@ -19,23 +19,6 @@
#include <sys/types.h>
#include "libdisk.h"
-#if 0
-struct disk *
-Set_Phys_Geom(struct disk *disk, u_long cyl, u_long hd, u_long sect)
-{
- struct disk *d = Int_Open_Disk(disk->name,cyl*hd*sect);
- d->real_cyl = cyl;
- d->real_hd = hd;
- d->real_sect = sect;
- d->bios_cyl = disk->bios_cyl;
- d->bios_hd = disk->bios_hd;
- d->bios_sect = disk->bios_sect;
- d->flags = disk->flags;
- Free_Disk(disk);
- return d;
-}
-#endif
-
void
Set_Bios_Geom(struct disk *disk, u_long cyl, u_long hd, u_long sect)
{
@@ -46,6 +29,38 @@ Set_Bios_Geom(struct disk *disk, u_long cyl, u_long hd, u_long sect)
}
void
+Sanitize_Bios_Geom(struct disk *disk)
+{
+ int sane = 1;
+
+ if (disk->bios_cyl > 1024)
+ sane = 0;
+ if (disk->bios_hd > 16)
+ sane = 0;
+ if (disk->bios_sect > 63)
+ sane = 0;
+ if (disk->bios_cyl*disk->bios_hd*disk->bios_sect !=
+ disk->chunks->size)
+ sane = 0;
+ if (sane)
+ return;
+
+ /* First try something that IDE can handle */
+ disk->bios_sect = 63;
+ disk->bios_hd = 16;
+ disk->bios_cyl = disk->chunks->size/(disk->bios_sect*disk->bios_hd);
+
+ if (disk->bios_cyl < 1024)
+ return;
+
+ /* Hmm, try harder... */
+ disk->bios_hd = 255;
+ disk->bios_cyl = disk->chunks->size/(disk->bios_sect*disk->bios_hd);
+
+ return;
+}
+
+void
All_FreeBSD(struct disk *d, int force_all)
{
struct chunk *c;
@@ -57,6 +72,11 @@ All_FreeBSD(struct disk *d, int force_all)
goto again;
}
c=d->chunks;
- Create_Chunk(d,c->offset,c->size,freebsd,0xa5,
- force_all? CHUNK_FORCE_ALL: 0);
+ if (force_all) {
+ Sanitize_Bios_Geom(d);
+ Create_Chunk(d,c->offset,c->size,freebsd,0xa5,
+ CHUNK_FORCE_ALL);
+ } else {
+ Create_Chunk(d,c->offset,c->size,freebsd,0xa5, 0);
+ }
}
OpenPOWER on IntegriCloud