mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Initialize d->bios_cyl. We know the media size in sectors, the number
of heads end the number of sectors per track. If there's an obvious insanity (heads and sectors are both zero or the media size is not an integral multiple of heads times sector) we set the number of cylinders to zero.
This commit is contained in:
parent
0d89ccd7d5
commit
62b693d7db
1 changed files with 10 additions and 4 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue