summaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/libdisk/change.c60
-rw-r--r--lib/libdisk/disk.c6
-rw-r--r--lib/libdisk/libdisk.h22
-rw-r--r--lib/libdisk/tst01.c26
-rw-r--r--lib/libdisk/write_disk.c8
5 files changed, 57 insertions, 65 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);
+ }
}
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index 5f2e695..0565d2c 100644
--- a/lib/libdisk/disk.c
+++ b/lib/libdisk/disk.c
@@ -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);
diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h
index fd8607c..c133cab 100644
--- a/lib/libdisk/libdisk.h
+++ b/lib/libdisk/libdisk.h
@@ -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
diff --git a/lib/libdisk/tst01.c b/lib/libdisk/tst01.c
index b9911c4..65b1cf6 100644
--- a/lib/libdisk/tst01.c
+++ b/lib/libdisk/tst01.c
@@ -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,33 +196,17 @@ main(int argc, char **argv)
All_FreeBSD(d, 1);
continue;
}
- if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
- Set_Bios_Geom(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0));
+ if (!strcasecmp(*cmds,"sanitize")) {
+ Sanitize_Bios_Geom(d);
continue;
}
-#if 0
- if (!strcasecmp(*cmds,"phys") && ncmd == 4) {
- d = Set_Phys_Geom(d,
+ if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
+ Set_Bios_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:");
diff --git a/lib/libdisk/write_disk.c b/lib/libdisk/write_disk.c
index dceab4d..e0c3286 100644
--- a/lib/libdisk/write_disk.c
+++ b/lib/libdisk/write_disk.c
@@ -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;
OpenPOWER on IntegriCloud