}
/* return 0 as number of sectors if no device present or error */
-void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr)
+void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr)
{
int64_t length;
length = bdrv_getlength(bs);
const void *buf, int count);
int bdrv_truncate(BlockDriverState *bs, int64_t offset);
int64_t bdrv_getlength(BlockDriverState *bs);
-void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
+void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
int bdrv_commit(BlockDriverState *bs);
void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
/* async block I/O */
static void fd_revalidate (fdrive_t *drv)
{
const fd_format_t *parse;
- int64_t nb_sectors, size;
+ uint64_t nb_sectors, size;
int i, first_match, match;
int nb_heads, max_track, last_sect, ro;
break;
case GPCMD_SEEK:
{
- int lba;
- int64_t total_sectors;
+ unsigned int lba;
+ uint64_t total_sectors;
bdrv_get_geometry(s->bs, &total_sectors);
total_sectors >>= 2;
- if (total_sectors <= 0) {
+ if (total_sectors == 0) {
ide_atapi_cmd_error(s, SENSE_NOT_READY,
ASC_MEDIUM_NOT_PRESENT);
break;
case GPCMD_READ_TOC_PMA_ATIP:
{
int format, msf, start_track, len;
- int64_t total_sectors;
+ uint64_t total_sectors;
bdrv_get_geometry(s->bs, &total_sectors);
total_sectors >>= 2;
- if (total_sectors <= 0) {
+ if (total_sectors == 0) {
ide_atapi_cmd_error(s, SENSE_NOT_READY,
ASC_MEDIUM_NOT_PRESENT);
break;
break;
case GPCMD_READ_CDVD_CAPACITY:
{
- int64_t total_sectors;
+ uint64_t total_sectors;
bdrv_get_geometry(s->bs, &total_sectors);
total_sectors >>= 2;
- if (total_sectors <= 0) {
+ if (total_sectors == 0) {
ide_atapi_cmd_error(s, SENSE_NOT_READY,
ASC_MEDIUM_NOT_PRESENT);
break;
int media = packet[1];
int layer = packet[6];
int format = packet[2];
- int64_t total_sectors;
+ uint64_t total_sectors;
if (media != 0 || layer != 0)
{
case 0:
bdrv_get_geometry(s->bs, &total_sectors);
total_sectors >>= 2;
+ if (total_sectors == 0) {
+ ide_atapi_cmd_error(s, SENSE_NOT_READY,
+ ASC_MEDIUM_NOT_PRESENT);
+ break;
+ }
memset(buf, 0, 2052);
break;
case GPCMD_GET_CONFIGURATION:
{
- int64_t total_sectors;
+ uint64_t total_sectors;
/* only feature 0 is supported */
if (packet[2] != 0 || packet[3] != 0) {
static void cdrom_change_cb(void *opaque)
{
IDEState *s = opaque;
- int64_t nb_sectors;
+ uint64_t nb_sectors;
/* XXX: send interrupt too */
bdrv_get_geometry(s->bs, &nb_sectors);
IDEState *s;
static int drive_serial = 1;
int i, cylinders, heads, secs, translation, lba_detected = 0;
- int64_t nb_sectors;
+ uint64_t nb_sectors;
for(i = 0; i < 2; i++) {
s = ide_state + i;
uint8_t *buf, int lun)
{
SCSIDeviceState *s = d->state;
- int64_t nb_sectors;
+ uint64_t nb_sectors;
uint32_t lba;
uint32_t len;
int cmdlen;
const char *fmt = "raw";
const char *filename;
const char *base_filename = NULL;
- int64_t size;
+ uint64_t size;
const char *p;
BlockDriver *drv;
printf(", backing_file=%s",
base_filename);
}
- printf(", size=%" PRId64 " kB\n", (int64_t) (size / 1024));
+ printf(", size=%" PRIu64 " kB\n", size / 1024);
ret = bdrv_create(drv, filename, size / 512, base_filename, flags);
if (ret < 0) {
if (ret == -ENOTSUP) {
const char *fmt, *out_fmt, *out_filename;
BlockDriver *drv;
BlockDriverState **bs, *out_bs;
- int64_t total_sectors, nb_sectors, sector_num, bs_offset, bs_sectors;
+ int64_t total_sectors, nb_sectors, sector_num, bs_offset;
+ uint64_t bs_sectors;
uint8_t buf[IO_BUF_SIZE];
const uint8_t *buf1;
BlockDriverInfo bdi;
BlockDriver *drv;
BlockDriverState *bs;
char fmt_name[128], size_buf[128], dsize_buf[128];
- int64_t total_sectors, allocated_size;
+ uint64_t total_sectors;
+ int64_t allocated_size;
char backing_filename[1024];
char backing_filename2[1024];
BlockDriverInfo bdi;