Improve the Dangerously Dedidcated mode a bit. Not much, but a bit better.

This commit is contained in:
Poul-Henning Kamp
1996-11-27 22:44:43 +00:00
parent e2900279d2
commit 00f723bf6b
5 changed files with 57 additions and 65 deletions
+40 -20
View File
@@ -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)
{
@@ -45,6 +28,38 @@ Set_Bios_Geom(struct disk *disk, u_long cyl, u_long hd, u_long sect)
Bios_Limit_Chunk(disk->chunks,1024*hd*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)
{
@@ -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);
}
}
+4 -2
View File
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: disk.c,v 1.21 1996/03/24 18:55:37 joerg Exp $
* $Id: disk.c,v 1.22 1996/04/29 05:03:02 jkh Exp $
*
*/
@@ -231,7 +231,9 @@ Debug_Disk(struct disk *d)
#if 0
printf(" real_geom=%lu/%lu/%lu",d->real_cyl,d->real_hd,d->real_sect);
#endif
printf(" bios_geom=%lu/%lu/%lu\n",d->bios_cyl,d->bios_hd,d->bios_sect);
printf(" bios_geom=%lu/%lu/%lu = %lu\n",
d->bios_cyl,d->bios_hd,d->bios_sect,
d->bios_cyl*d->bios_hd*d->bios_sect);
printf(" boot1=%p, boot2=%p, bootmgr=%p\n",
d->boot1,d->boot2,d->bootmgr);
Debug_Chunk(d->chunks);
+7 -15
View File
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: libdisk.h,v 1.21 1996/03/24 18:55:39 joerg Exp $
* $Id: libdisk.h,v 1.22 1996/04/29 06:45:33 jkh Exp $
*
*/
@@ -28,11 +28,6 @@ struct disk {
char *name;
u_long flags;
# define DISK_ON_TRACK 1
#if 0
u_long real_cyl;
u_long real_hd;
u_long real_sect;
#endif
u_long bios_cyl;
u_long bios_hd;
u_long bios_sect;
@@ -111,19 +106,16 @@ Debug_Disk(struct disk *disk);
/* Print the content of the tree to stdout
*/
#if 0
struct disk *
Set_Phys_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects);
/* Use a different physical geometry. Makes sense for ST506 disks only.
* The tree returned is read from the disk, using this geometry.
*/
#endif
void
Set_Bios_Geom(struct disk *disk, u_long cyl, u_long heads, u_long sects);
/* Set the geometry the bios uses.
*/
void
Sanitize_Bios_Geom(struct disk *disk);
/* Set the bios geometry to something sane
*/
int
Delete_Chunk(struct disk *disk, struct chunk *);
/* Free a chunk of disk_space
@@ -278,7 +270,7 @@ __END_DECLS
*
*Sample output from tst01:
*
* Debug_Disk(wd0) flags=0 real_geom=0/0/0 bios_geom=0/0/0
* Debug_Disk(wd0) flags=0 bios_geom=0/0/0
* >> 0x3d040 0 1411200 1411199 wd0 0 whole 0 0
* >>>> 0x3d080 0 960120 960119 wd0s1 3 freebsd 0 8
* >>>>>> 0x3d100 0 40960 40959 wd0s1a 5 part 0 0
+5 -21
View File
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: tst01.c,v 1.17 1996/03/24 18:55:39 joerg Exp $
* $Id: tst01.c,v 1.18 1996/07/09 12:17:46 jkh Exp $
*
*/
@@ -196,6 +196,10 @@ main(int argc, char **argv)
All_FreeBSD(d, 1);
continue;
}
if (!strcasecmp(*cmds,"sanitize")) {
Sanitize_Bios_Geom(d);
continue;
}
if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
Set_Bios_Geom(d,
strtol(cmds[1],0,0),
@@ -203,26 +207,6 @@ main(int argc, char **argv)
strtol(cmds[3],0,0));
continue;
}
#if 0
if (!strcasecmp(*cmds,"phys") && ncmd == 4) {
d = Set_Phys_Geom(d,
strtol(cmds[1],0,0),
strtol(cmds[2],0,0),
strtol(cmds[3],0,0));
continue;
}
#endif
#if 0
if (!strcasecmp(*cmds,"collapse")) {
if (cmds[1])
while (Collapse_Chunk(d,
(struct chunk *)strtol(cmds[1],0,0)))
;
else
Collapse_Disk(d);
continue;
}
#endif
if (!strcasecmp(*cmds,"list")) {
cp = Disk_Names();
printf("Disks:");
+1 -7
View File
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
* $Id: write_disk.c,v 1.16 1995/12/07 10:33:27 peter Exp $
* $Id: write_disk.c,v 1.17 1996/04/29 05:03:02 jkh Exp $
*
*/
@@ -80,15 +80,9 @@ Write_FreeBSD(int fd, struct disk *new, struct disk *old, struct chunk *c1)
dl->d_secsize = 512;
dl->d_secperunit = new->chunks->size;
#if 0
dl->d_ncylinders = new->real_cyl ? new->real_cyl : new->bios_cyl;
dl->d_ntracks = new->real_hd ? new->real_hd : new->bios_hd;
dl->d_nsectors = new->real_sect ? new->real_sect : new->bios_sect;
#else
dl->d_ncylinders = new->bios_cyl;
dl->d_ntracks = new->bios_hd;
dl->d_nsectors = new->bios_sect;
#endif
dl->d_secpercyl = dl->d_ntracks * dl->d_nsectors;
dl->d_npartitions = MAXPARTITIONS;