summaryrefslogtreecommitdiff
path: root/lib/libdisk/disk.c
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2002-11-03 01:37:08 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2002-11-03 01:37:08 +0000
commit62b693d7db46a2f0de2e00bcc733ee729ae37a20 (patch)
tree248aa00e829c7a9df6ab76a630fb26cf12c0e440 /lib/libdisk/disk.c
parent0d89ccd7d5479825fa1ec98eb34b446f188e6332 (diff)
Notes
Diffstat (limited to 'lib/libdisk/disk.c')
-rw-r--r--lib/libdisk/disk.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index fe73d3e7d6ef..2a1b6aa2ecda 100644
--- a/lib/libdisk/disk.c
+++ b/lib/libdisk/disk.c
@@ -153,7 +153,7 @@ Int_Open_Disk(const char *name)
d->name = strdup(name);
a = strsep(&p, " "); /* length in bytes */
- o = strtoimax(a, &r, 0);
+ len = strtoimax(a, &r, 0);
if (*r) { printf("BARF %d <%d>\n", __LINE__, *r); exit (0); }
a = strsep(&p, " "); /* sectorsize */
@@ -161,12 +161,11 @@ Int_Open_Disk(const char *name)
if (*r) { printf("BARF %d <%d>\n", __LINE__, *r); exit (0); }
d->sector_size = s;
+ len /= s; /* media size in number of sectors. */
- if (Add_Chunk(d, 0, o / s, name, whole, 0, 0, "-"))
+ if (Add_Chunk(d, 0, len, name, whole, 0, 0, "-"))
DPRINT(("Failed to add 'whole' chunk"));
- len = o / s;
-
for (;;) {
a = strsep(&p, " ");
if (a == NULL)
@@ -182,6 +181,13 @@ Int_Open_Disk(const char *name)
printf("HUH ? <%s> <%s>\n", a, b);
}
+ /*
+ * Calculate the number of cylinders this disk must have. If we have
+ * an obvious insanity, we set the number of cyclinders to zero.
+ */
+ o = d->bios_hd * d->bios_sect;
+ d->bios_cyl = (o != 0 && (len % o) == 0) ? len / o : 0;
+
p = q;
lo[0] = 0;