Revision c717d8bf hw/ide.c

b/hw/ide.c
2474 2474
static int guess_disk_lchs(IDEState *s,
2475 2475
                           int *pcylinders, int *pheads, int *psectors)
2476 2476
{
2477
    uint8_t *buf;
2477
    uint8_t *buf = s->io_buffer;
2478 2478
    int ret, i, heads, sectors, cylinders;
2479 2479
    struct partition *p;
2480 2480
    uint32_t nr_sects;
2481 2481

  
2482
    buf = qemu_memalign(512, 512);
2483
    if (buf == NULL)
2484
        return -1;
2485 2482
    ret = bdrv_read(s->bs, 0, buf, 1);
2486 2483
    if (ret < 0) {
2487
        qemu_free(buf);
2488 2484
        return -1;
2489 2485
    }
2490 2486
    /* test msdos magic */
2491 2487
    if (buf[510] != 0x55 || buf[511] != 0xaa) {
2492
        qemu_free(buf);
2493 2488
        return -1;
2494 2489
    }
2495 2490
    for(i = 0; i < 4; i++) {
......
2512 2507
            printf("guessed geometry: LCHS=%d %d %d\n",
2513 2508
                   cylinders, heads, sectors);
2514 2509
#endif
2515
            qemu_free(buf);
2516 2510
            return 0;
2517 2511
        }
2518 2512
    }
2519
    qemu_free(buf);
2520 2513
    return -1;
2521 2514
}
2522 2515

  

Also available in: Unified diff