aboutsummaryrefslogtreecommitdiffstats
path: root/block/raw-win32.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2010-12-23 02:54:08 +0100
committerDavid 'Digit' Turner <digit@android.com>2011-01-02 22:31:27 +0100
commitcb42a1b1461e02efb034582ac5d8f71534723b92 (patch)
tree5dbd619671d4591d33834488f1c15690dabf50ba /block/raw-win32.c
parentca6a2e034bce665a08d9d748ac11d6a7cfcd7c48 (diff)
downloadexternal_qemu-cb42a1b1461e02efb034582ac5d8f71534723b92.zip
external_qemu-cb42a1b1461e02efb034582ac5d8f71534723b92.tar.gz
external_qemu-cb42a1b1461e02efb034582ac5d8f71534723b92.tar.bz2
upstream: integrate block changes
This large patch upgrades the block support code to the upstream version available in ba5e7f82169f32ab8163c707d97c799ca09f8924 dated 2010-08-08 Change-Id: I8b24df0c287e72f6620650a4d6a62e1bb315453e
Diffstat (limited to 'block/raw-win32.c')
-rw-r--r--block/raw-win32.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/block/raw-win32.c b/block/raw-win32.c
index 72acad5..503ed39 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -76,21 +76,17 @@ static int set_sparse(int fd)
static int raw_open(BlockDriverState *bs, const char *filename, int flags)
{
BDRVRawState *s = bs->opaque;
- int access_flags, create_flags;
+ int access_flags;
DWORD overlapped;
s->type = FTYPE_FILE;
- if ((flags & BDRV_O_ACCESS) == O_RDWR) {
+ if (flags & BDRV_O_RDWR) {
access_flags = GENERIC_READ | GENERIC_WRITE;
} else {
access_flags = GENERIC_READ;
}
- if (flags & BDRV_O_CREAT) {
- create_flags = CREATE_ALWAYS;
- } else {
- create_flags = OPEN_EXISTING;
- }
+
overlapped = FILE_ATTRIBUTE_NORMAL;
if ((flags & BDRV_O_NOCACHE))
overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH;
@@ -98,7 +94,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
overlapped |= FILE_FLAG_WRITE_THROUGH;
s->hfile = CreateFile(filename, access_flags,
FILE_SHARE_READ, NULL,
- create_flags, overlapped, NULL);
+ OPEN_EXISTING, overlapped, NULL);
if (s->hfile == INVALID_HANDLE_VALUE) {
int err = GetLastError();
@@ -242,10 +238,11 @@ static QEMUOptionParameter raw_create_options[] = {
{ NULL }
};
-static BlockDriver bdrv_raw = {
- .format_name = "raw",
+static BlockDriver bdrv_file = {
+ .format_name = "file",
+ .protocol_name = "file",
.instance_size = sizeof(BDRVRawState),
- .bdrv_open = raw_open,
+ .bdrv_file_open = raw_open,
.bdrv_close = raw_close,
.bdrv_create = raw_create,
.bdrv_flush = raw_flush,
@@ -337,7 +334,7 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
}
s->type = find_device_type(bs, filename);
- if ((flags & BDRV_O_ACCESS) == O_RDWR) {
+ if (flags & BDRV_O_RDWR) {
access_flags = GENERIC_READ | GENERIC_WRITE;
} else {
access_flags = GENERIC_READ;
@@ -397,23 +394,30 @@ static int raw_set_locked(BlockDriverState *bs, int locked)
}
#endif
+static int hdev_has_zero_init(BlockDriverState *bs)
+{
+ return 0;
+}
+
static BlockDriver bdrv_host_device = {
.format_name = "host_device",
+ .protocol_name = "host_device",
.instance_size = sizeof(BDRVRawState),
.bdrv_probe_device = hdev_probe_device,
- .bdrv_open = hdev_open,
+ .bdrv_file_open = hdev_open,
.bdrv_close = raw_close,
.bdrv_flush = raw_flush,
+ .bdrv_has_zero_init = hdev_has_zero_init,
.bdrv_read = raw_read,
.bdrv_write = raw_write,
.bdrv_getlength = raw_getlength,
};
-static void bdrv_raw_init(void)
+static void bdrv_file_init(void)
{
- bdrv_register(&bdrv_raw);
+ bdrv_register(&bdrv_file);
bdrv_register(&bdrv_host_device);
}
-block_init(bdrv_raw_init);
+block_init(bdrv_file_init);