* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "vl.h"
+#include "qemu-common.h"
+#ifndef QEMU_IMG
+#include "qemu-timer.h"
+#include "exec-all.h"
+#endif
#include "block_int.h"
#include <assert.h>
#ifndef _WIN32
#include <aio.h>
-#ifndef QEMU_TOOL
-#include "exec-all.h"
-#endif
-
#ifdef CONFIG_COCOA
#include <paths.h>
#include <sys/param.h>
//#define DEBUG_FLOPPY
-#define DEBUG_BLOCK
-#if defined(DEBUG_BLOCK) && !defined(QEMU_TOOL)
+//#define DEBUG_BLOCK
+#if defined(DEBUG_BLOCK) && !defined(QEMU_IMG)
#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \
{ fprintf(logfile, formatCstr, ##args); fflush(logfile); } } while (0)
#else
if (lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
++(s->lseek_err_cnt);
if(s->lseek_err_cnt <= 10) {
- DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %lld, %p, %d) [%lld] lseek failed : %d = %s\n",
+ DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
+ "] lseek failed : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, errno, strerror(errno));
}
if (ret == count)
goto label__raw_read__success;
- DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %lld, %p, %d) [%lld] read failed %d : %d = %s\n",
+ DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
+ "] read failed %d : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, ret, errno, strerror(errno));
if (ret == count)
goto label__raw_read__success;
- DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %lld, %p, %d) [%lld] retry read failed %d : %d = %s\n",
+ DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
+ "] retry read failed %d : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, ret, errno, strerror(errno));
}
if (lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
++(s->lseek_err_cnt);
if(s->lseek_err_cnt) {
- DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %lld, %p, %d) [%lld] lseek failed : %d = %s\n",
+ DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%"
+ PRId64 "] lseek failed : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, errno, strerror(errno));
}
if (ret == count)
goto label__raw_write__success;
- DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %lld, %p, %d) [%lld] write failed %d : %d = %s\n",
+ DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
+ "] write failed %d : %d = %s\n",
s->fd, bs->filename, offset, buf, count,
bs->total_sectors, ret, errno, strerror(errno));
static void aio_signal_handler(int signum)
{
-#ifndef QEMU_TOOL
+#ifndef QEMU_IMG
CPUState *env = cpu_single_env;
if (env) {
/* stop the currently executing cpu because a timer occured */
sigset_t set;
int nb_sigs;
-#ifndef QEMU_TOOL
+#ifndef QEMU_IMG
if (qemu_bh_poll())
return;
#endif
return 0;
}
-#if defined(__linux__) && !defined(QEMU_TOOL)
+#if defined(__linux__) && !defined(QEMU_IMG)
/* Note: we do not have a reliable method to detect if the floppy is
present. The current method is to try to open the floppy at every
} else {
create_flags = OPEN_EXISTING;
}
-#ifdef QEMU_TOOL
+#ifdef QEMU_IMG
overlapped = FILE_ATTRIBUTE_NORMAL;
#else
overlapped = FILE_FLAG_OVERLAPPED;
}
#if 0
-#ifndef QEMU_TOOL
+#ifndef QEMU_IMG
static void raw_aio_cb(void *opaque)
{
RawAIOCB *acb = opaque;
acb->ov.OffsetHigh = offset >> 32;
acb->ov.hEvent = acb->hEvent;
acb->count = nb_sectors * 512;
-#ifndef QEMU_TOOL
+#ifndef QEMU_IMG
qemu_add_wait_object(acb->ov.hEvent, raw_aio_cb, acb);
#endif
return acb;
qemu_aio_release(acb);
return NULL;
}
-#ifdef QEMU_TOOL
+#ifdef QEMU_IMG
qemu_aio_release(acb);
#endif
return (BlockDriverAIOCB *)acb;
qemu_aio_release(acb);
return NULL;
}
-#ifdef QEMU_TOOL
+#ifdef QEMU_IMG
qemu_aio_release(acb);
#endif
return (BlockDriverAIOCB *)acb;
static void raw_aio_cancel(BlockDriverAIOCB *blockacb)
{
-#ifndef QEMU_TOOL
+#ifndef QEMU_IMG
RawAIOCB *acb = (RawAIOCB *)blockacb;
BlockDriverState *bs = acb->common.bs;
BDRVRawState *s = bs->opaque;
BDRVRawState *s = bs->opaque;
LARGE_INTEGER l;
ULARGE_INTEGER available, total, total_free;
- DISK_GEOMETRY dg;
+ DISK_GEOMETRY_EX dg;
DWORD count;
BOOL status;
l.QuadPart = total.QuadPart;
break;
case FTYPE_HARDDISK:
- status = DeviceIoControl(s->hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY,
+ status = DeviceIoControl(s->hfile, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, &dg, sizeof(dg), &count, NULL);
- if (status != FALSE) {
- l.QuadPart = dg.Cylinders.QuadPart * dg.TracksPerCylinder
- * dg.SectorsPerTrack * dg.BytesPerSector;
+ if (status != 0) {
+ l = dg.DiskSize;
}
break;
default:
void qemu_aio_wait(void)
{
-#ifndef QEMU_TOOL
+#ifndef QEMU_IMG
qemu_bh_poll();
#endif
}
}
create_flags = OPEN_EXISTING;
-#ifdef QEMU_TOOL
+#ifdef QEMU_IMG
overlapped = FILE_ATTRIBUTE_NORMAL;
#else
overlapped = FILE_FLAG_OVERLAPPED;