qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Kazu" <kazoo@r3.dion.ne.jp>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] mingw compile error patch
Date: Tue, 22 Aug 2006 13:22:02 +0900	[thread overview]
Message-ID: <001401c6c5a2$84edab20$0464a8c0@athlon> (raw)
In-Reply-To: ecdirf$98a$1@sea.gmane.org

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

alex wrote:

> Hi,
> The patch below allows me to compile qemu on Windows, however it is still
> not working.
> The program exits immediately reporting that it can't open the hard disk
> image.
> GDB reports the offensive pies of code is in malloc(), which does not make
> sense to me.
> Am I doing something wrong?
>

An attached patch fixes compile error for win32.
It also fixes using /dev/cdrom and a file name with a drive letter.
Qcow is not fixed.

Regards,
Kazu

[-- Attachment #2: qemu-20060821-compile.patch --]
[-- Type: application/octet-stream, Size: 4301 bytes --]

Index: block-raw.c
===================================================================
RCS file: /sources/qemu/qemu/block-raw.c,v
retrieving revision 1.7
diff -u -r1.7 block-raw.c
--- block-raw.c	19 Aug 2006 11:45:59 -0000	1.7
+++ block-raw.c	21 Aug 2006 00:48:38 -0000
@@ -871,13 +871,15 @@
 				 NULL, 0, NULL, 0, &returned, NULL);
 }
 
+static int find_cdrom(char *cdrom_name, int cdrom_name_size);
+static int find_device_type(BlockDriverState *bs, const char *filename);
+
 static int raw_open(BlockDriverState *bs, const char *filename, int flags)
 {
     BDRVRawState *s = bs->opaque;
     int access_flags, create_flags;
     DWORD overlapped;
     char device_name[64];
-    const char *p;
 
     if (strstart(filename, "/dev/cdrom", NULL)) {
         if (find_cdrom(device_name, sizeof(device_name)) < 0)
@@ -892,7 +894,7 @@
             filename = device_name;
         }
     }
-    s->type = find_device_type(filename);
+    s->type = find_device_type(bs, filename);
 
     if ((flags & BDRV_O_ACCESS) == O_RDWR) {
         access_flags = GENERIC_READ | GENERIC_WRITE;
@@ -1095,7 +1097,7 @@
     LARGE_INTEGER l;
     ULARGE_INTEGER available, total, total_free; 
 
-    switch(s->ftype) {
+    switch(s->type) {
     case FTYPE_FILE:
         l.LowPart = GetFileSize(s->hfile, &l.HighPart);
         if (l.LowPart == 0xffffffffUL && GetLastError() != NO_ERROR)
@@ -1104,7 +1106,7 @@
     case FTYPE_CD:
         if (!GetDiskFreeSpaceEx(s->drive_letter, &available, &total, &total_free))
             return -EIO;
-        l = total;
+        l.QuadPart = total.QuadPart;
         break;
     default:
         return -EIO;
@@ -1182,7 +1184,7 @@
     char drives[256], *pdrv = drives;
     UINT type;
 
-    memset(drives, 0, sizeof(drivers));
+    memset(drives, 0, sizeof(drives));
     GetLogicalDriveStrings(sizeof(drives), drives);
     while(pdrv[0] != '\0') {
         type = GetDriveType(pdrv);
@@ -1197,16 +1199,19 @@
     return -1;
 }
 
-static int find_device_type(const char *filename)
+static int find_device_type(BlockDriverState *bs, const char *filename)
 {
+    BDRVRawState *s = bs->opaque;
     UINT type;
     const char *p;
+    char root_path[4];
 
     if (strstart(filename, "\\\\.\\", &p) ||
         strstart(filename, "//./", &p)) {
         s->drive_letter[0] = p[0];
         s->drive_letter[1] = '\0';
-        type = GetDriveType(s->drive_letter);
+        snprintf(root_path, sizeof(root_path), "%c:\\", p[0]);
+        type = GetDriveType(root_path);
         if (type == DRIVE_CDROM)
             return FTYPE_CD;
         else
@@ -1222,7 +1227,6 @@
     int access_flags, create_flags;
     DWORD overlapped;
     char device_name[64];
-    const char *p;
 
     if (strstart(filename, "/dev/cdrom", NULL)) {
         if (find_cdrom(device_name, sizeof(device_name)) < 0)
@@ -1237,7 +1241,7 @@
             filename = device_name;
         }
     }
-    s->type = find_device_type(filename);
+    s->type = find_device_type(bs, filename);
 
     if ((flags & BDRV_O_ACCESS) == O_RDWR) {
         access_flags = GENERIC_READ | GENERIC_WRITE;
Index: block.c
===================================================================
RCS file: /sources/qemu/qemu/block.c,v
retrieving revision 1.34
diff -u -r1.34 block.c
--- block.c	19 Aug 2006 11:45:59 -0000	1.34
+++ block.c	21 Aug 2006 00:48:41 -0000
@@ -182,11 +182,18 @@
 #endif
 
 #ifdef _WIN32
-static int is_windows_drive(const char *filename)
+static int is_windows_file(const char *filename)
 {
     if (((filename[0] >= 'a' && filename[0] <= 'z') ||
          (filename[0] >= 'A' && filename[0] <= 'Z')) &&
-        filename[1] == ':' && filename[2] == '\0')
+        filename[1] == ':')
+        return 1;
+    return 0;
+}
+
+static int is_windows_drive(const char *filename)
+{
+    if (is_windows_file(filename) && filename[2] == '\0')
         return 1;
     if (strstart(filename, "\\\\.\\", NULL) ||
         strstart(filename, "//./", NULL))
@@ -205,6 +212,8 @@
 #ifdef _WIN32
     if (is_windows_drive(filename))
         return &bdrv_raw;
+    if (is_windows_file(filename))
+        return &bdrv_raw;
 #endif
     p = strchr(filename, ':');
     if (!p)

  reply	other threads:[~2006-08-22  4:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-22  0:24 [Qemu-devel] mingw compile error patch alex
2006-08-22  4:22 ` Kazu [this message]
2006-08-22  5:18   ` [Qemu-devel] " Alex
2006-08-22  7:45     ` Kazu
2006-08-23 16:01       ` [Qemu-devel] " alex

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001401c6c5a2$84edab20$0464a8c0@athlon' \
    --to=kazoo@r3.dion.ne.jp \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).