fdc: Drop broken code for user-defined floppy geometry
bdrv_get_floppy_geometry_hint() fails to store through its parameter drive when bs has a geometry hint. Makes fd_revalidate() assign random crap to drv->drive. Has been broken that way for ages. Harmless, because: * The only way to set a geometry hint is -drive if=none,cyls=... Since commitc219331e
, probably unintentional. * The only use of drv->drive is as argument to another bdrv_get_floppy_geometry_hint(). Which doesn't use it, since the geometry hint is still there. Drop the broken code, ignore -drive parameter cyls, heads and secs for floppies even with if=none, just like before commitc219331e
. Matches -help, which explains cyls, heads, secs as "hard disk physical geometry". Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
b3ce604eea
commit
1f69c2b022
62
block.c
62
block.c
@ -2337,46 +2337,40 @@ void bdrv_get_floppy_geometry_hint(BlockDriverState *bs, int *nb_heads,
|
|||||||
uint64_t nb_sectors, size;
|
uint64_t nb_sectors, size;
|
||||||
int i, first_match, match;
|
int i, first_match, match;
|
||||||
|
|
||||||
bdrv_get_geometry_hint(bs, nb_heads, max_track, last_sect);
|
bdrv_get_geometry(bs, &nb_sectors);
|
||||||
if (*nb_heads != 0 && *max_track != 0 && *last_sect != 0) {
|
match = -1;
|
||||||
/* User defined disk */
|
first_match = -1;
|
||||||
*rate = FDRIVE_RATE_500K;
|
for (i = 0; ; i++) {
|
||||||
} else {
|
parse = &fd_formats[i];
|
||||||
bdrv_get_geometry(bs, &nb_sectors);
|
if (parse->drive == FDRIVE_DRV_NONE) {
|
||||||
match = -1;
|
break;
|
||||||
first_match = -1;
|
}
|
||||||
for (i = 0; ; i++) {
|
if (drive_in == parse->drive ||
|
||||||
parse = &fd_formats[i];
|
drive_in == FDRIVE_DRV_NONE) {
|
||||||
if (parse->drive == FDRIVE_DRV_NONE) {
|
size = (parse->max_head + 1) * parse->max_track *
|
||||||
|
parse->last_sect;
|
||||||
|
if (nb_sectors == size) {
|
||||||
|
match = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (drive_in == parse->drive ||
|
|
||||||
drive_in == FDRIVE_DRV_NONE) {
|
|
||||||
size = (parse->max_head + 1) * parse->max_track *
|
|
||||||
parse->last_sect;
|
|
||||||
if (nb_sectors == size) {
|
|
||||||
match = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (first_match == -1) {
|
|
||||||
first_match = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (match == -1) {
|
|
||||||
if (first_match == -1) {
|
if (first_match == -1) {
|
||||||
match = 1;
|
first_match = i;
|
||||||
} else {
|
|
||||||
match = first_match;
|
|
||||||
}
|
}
|
||||||
parse = &fd_formats[match];
|
|
||||||
}
|
}
|
||||||
*nb_heads = parse->max_head + 1;
|
|
||||||
*max_track = parse->max_track;
|
|
||||||
*last_sect = parse->last_sect;
|
|
||||||
*drive = parse->drive;
|
|
||||||
*rate = parse->rate;
|
|
||||||
}
|
}
|
||||||
|
if (match == -1) {
|
||||||
|
if (first_match == -1) {
|
||||||
|
match = 1;
|
||||||
|
} else {
|
||||||
|
match = first_match;
|
||||||
|
}
|
||||||
|
parse = &fd_formats[match];
|
||||||
|
}
|
||||||
|
*nb_heads = parse->max_head + 1;
|
||||||
|
*max_track = parse->max_track;
|
||||||
|
*last_sect = parse->last_sect;
|
||||||
|
*drive = parse->drive;
|
||||||
|
*rate = parse->rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bdrv_get_translation_hint(BlockDriverState *bs)
|
int bdrv_get_translation_hint(BlockDriverState *bs)
|
||||||
|
3
hw/fdc.c
3
hw/fdc.c
@ -191,9 +191,6 @@ static void fd_revalidate(FDrive *drv)
|
|||||||
&last_sect, drv->drive, &drive, &rate);
|
&last_sect, drv->drive, &drive, &rate);
|
||||||
if (!bdrv_is_inserted(drv->bs)) {
|
if (!bdrv_is_inserted(drv->bs)) {
|
||||||
FLOPPY_DPRINTF("No disk in drive\n");
|
FLOPPY_DPRINTF("No disk in drive\n");
|
||||||
} else if (nb_heads != 0 && max_track != 0 && last_sect != 0) {
|
|
||||||
FLOPPY_DPRINTF("User defined disk (%d %d %d)\n",
|
|
||||||
nb_heads - 1, max_track, last_sect);
|
|
||||||
} else {
|
} else {
|
||||||
FLOPPY_DPRINTF("Floppy disk (%d h %d t %d s) %s\n", nb_heads,
|
FLOPPY_DPRINTF("Floppy disk (%d h %d t %d s) %s\n", nb_heads,
|
||||||
max_track, last_sect, ro ? "ro" : "rw");
|
max_track, last_sect, ro ? "ro" : "rw");
|
||||||
|
Loading…
Reference in New Issue
Block a user