#include "qemu/iov.h"
#include <windows.h>
#include <winioctl.h>
-#ifdef CONFIG_MARU
-#include <errno.h>
-#endif
#define FTYPE_FILE 0
#define FTYPE_CD 1
}
}
-#ifndef CONFIG_MARU
static void raw_parse_flags(int flags, int *access_flags, DWORD *overlapped)
{
assert(access_flags != NULL);
*overlapped |= FILE_FLAG_NO_BUFFERING;
}
}
-#endif
static void raw_parse_filename(const char *filename, QDict *options,
Error **errp)
Error *local_err = NULL;
const char *filename;
int ret;
-#ifndef CONFIG_MARU
DWORD overlapped;
int access_flags;
-#else
- int open_flags;
-#endif
s->type = FTYPE_FILE;
filename = qemu_opt_get(opts, "filename");
-#ifndef CONFIG_MARU
raw_parse_flags(flags, &access_flags, &overlapped);
if (filename[0] && filename[1] == ':') {
}
goto fail;
}
-#else
- // TODO: re-test and re-coding needed
- open_flags = O_BINARY & ~O_ACCMODE;
- if (flags & BDRV_O_RDWR) {
- open_flags |= O_RDWR;
- } else {
- open_flags |= O_RDONLY;
- }
-
- ret = qemu_open(filename, open_flags, 0644);
- if (ret < 0) {
- error_report("raw_open failed(%d) \n", ret);
- return -errno;
- }
- s->hfile = (HANDLE)_get_osfhandle(ret);
-#endif
if (flags & BDRV_O_NATIVE_AIO) {
s->aio = win32_aio_init();
Error **errp)
{
BDRVRawState *s = bs->opaque;
-#ifndef CONFIG_MARU
int access_flags, create_flags;
DWORD overlapped;
-#else
- int open_flags;
-#endif
int ret = 0;
char device_name[64];
}
s->type = find_device_type(bs, filename);
-#ifndef CONFIG_MARU
raw_parse_flags(flags, &access_flags, &overlapped);
create_flags = OPEN_EXISTING;
error_setg_errno(errp, -ret, "Could not open device");
goto done;
}
-#else
- /*
- s->hfile = CreateFile(g_win32_locale_filename_from_utf8(filename),
- access_flags,
- FILE_SHARE_READ, NULL,
- create_flags, overlapped, NULL);
- */
- open_flags = (O_BINARY & ~O_ACCMODE);
- if (flags & BDRV_O_RDWR) {
- open_flags |= O_RDWR;
- } else {
- open_flags |= O_RDONLY;
- }
-
- /* Use O_DSYNC for write-through caching, no flags for write-back caching,
- * and O_DIRECT for no caching. */
- /*
- if ((flags & BDRV_O_NOCACHE)) {
- open_flags |= O_DIRECT;
- }
- if (!(flags & BDRV_O_CACHE_WB)) {
- open_flags |= O_DSYNC;
- }
- */
-
- ret = qemu_open(filename, open_flags, 0644);
- if (ret < 0) {
- error_report("raw_open failed(%d) \n", ret);
- return -errno;
- }
- s->hfile = (HANDLE)_get_osfhandle(ret);
-#endif
return 0;
done: