From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GFNm2-0000IA-Am for qemu-devel@nongnu.org; Tue, 22 Aug 2006 00:21:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GFNm1-0000Hq-EP for qemu-devel@nongnu.org; Tue, 22 Aug 2006 00:21:58 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFNm1-0000Hn-9O for qemu-devel@nongnu.org; Tue, 22 Aug 2006 00:21:57 -0400 Received: from [211.5.2.79] (helo=nm01omta01b.dion.ne.jp) by monty-python.gnu.org with smtp (Exim 4.52) id 1GFNtX-0000nt-HR for qemu-devel@nongnu.org; Tue, 22 Aug 2006 00:29:44 -0400 Message-ID: <001401c6c5a2$84edab20$0464a8c0@athlon> From: "Kazu" References: Subject: Re: [Qemu-devel] mingw compile error patch Date: Tue, 22 Aug 2006 13:22:02 +0900 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0011_01C6C5ED.F47D2100" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. ------=_NextPart_000_0011_01C6C5ED.F47D2100 Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_0011_01C6C5ED.F47D2100 Content-Type: application/octet-stream; name="qemu-20060821-compile.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="qemu-20060821-compile.patch" Index: block-raw.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /sources/qemu/qemu/block-raw.c,v=0A= retrieving revision 1.7=0A= diff -u -r1.7 block-raw.c=0A= --- block-raw.c 19 Aug 2006 11:45:59 -0000 1.7=0A= +++ block-raw.c 21 Aug 2006 00:48:38 -0000=0A= @@ -871,13 +871,15 @@=0A= NULL, 0, NULL, 0, &returned, NULL);=0A= }=0A= =0A= +static int find_cdrom(char *cdrom_name, int cdrom_name_size);=0A= +static int find_device_type(BlockDriverState *bs, const char *filename);=0A= +=0A= static int raw_open(BlockDriverState *bs, const char *filename, int = flags)=0A= {=0A= BDRVRawState *s =3D bs->opaque;=0A= int access_flags, create_flags;=0A= DWORD overlapped;=0A= char device_name[64];=0A= - const char *p;=0A= =0A= if (strstart(filename, "/dev/cdrom", NULL)) {=0A= if (find_cdrom(device_name, sizeof(device_name)) < 0)=0A= @@ -892,7 +894,7 @@=0A= filename =3D device_name;=0A= }=0A= }=0A= - s->type =3D find_device_type(filename);=0A= + s->type =3D find_device_type(bs, filename);=0A= =0A= if ((flags & BDRV_O_ACCESS) =3D=3D O_RDWR) {=0A= access_flags =3D GENERIC_READ | GENERIC_WRITE;=0A= @@ -1095,7 +1097,7 @@=0A= LARGE_INTEGER l;=0A= ULARGE_INTEGER available, total, total_free; =0A= =0A= - switch(s->ftype) {=0A= + switch(s->type) {=0A= case FTYPE_FILE:=0A= l.LowPart =3D GetFileSize(s->hfile, &l.HighPart);=0A= if (l.LowPart =3D=3D 0xffffffffUL && GetLastError() !=3D = NO_ERROR)=0A= @@ -1104,7 +1106,7 @@=0A= case FTYPE_CD:=0A= if (!GetDiskFreeSpaceEx(s->drive_letter, &available, &total, = &total_free))=0A= return -EIO;=0A= - l =3D total;=0A= + l.QuadPart =3D total.QuadPart;=0A= break;=0A= default:=0A= return -EIO;=0A= @@ -1182,7 +1184,7 @@=0A= char drives[256], *pdrv =3D drives;=0A= UINT type;=0A= =0A= - memset(drives, 0, sizeof(drivers));=0A= + memset(drives, 0, sizeof(drives));=0A= GetLogicalDriveStrings(sizeof(drives), drives);=0A= while(pdrv[0] !=3D '\0') {=0A= type =3D GetDriveType(pdrv);=0A= @@ -1197,16 +1199,19 @@=0A= return -1;=0A= }=0A= =0A= -static int find_device_type(const char *filename)=0A= +static int find_device_type(BlockDriverState *bs, const char *filename)=0A= {=0A= + BDRVRawState *s =3D bs->opaque;=0A= UINT type;=0A= const char *p;=0A= + char root_path[4];=0A= =0A= if (strstart(filename, "\\\\.\\", &p) ||=0A= strstart(filename, "//./", &p)) {=0A= s->drive_letter[0] =3D p[0];=0A= s->drive_letter[1] =3D '\0';=0A= - type =3D GetDriveType(s->drive_letter);=0A= + snprintf(root_path, sizeof(root_path), "%c:\\", p[0]);=0A= + type =3D GetDriveType(root_path);=0A= if (type =3D=3D DRIVE_CDROM)=0A= return FTYPE_CD;=0A= else=0A= @@ -1222,7 +1227,6 @@=0A= int access_flags, create_flags;=0A= DWORD overlapped;=0A= char device_name[64];=0A= - const char *p;=0A= =0A= if (strstart(filename, "/dev/cdrom", NULL)) {=0A= if (find_cdrom(device_name, sizeof(device_name)) < 0)=0A= @@ -1237,7 +1241,7 @@=0A= filename =3D device_name;=0A= }=0A= }=0A= - s->type =3D find_device_type(filename);=0A= + s->type =3D find_device_type(bs, filename);=0A= =0A= if ((flags & BDRV_O_ACCESS) =3D=3D O_RDWR) {=0A= access_flags =3D GENERIC_READ | GENERIC_WRITE;=0A= Index: block.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /sources/qemu/qemu/block.c,v=0A= retrieving revision 1.34=0A= diff -u -r1.34 block.c=0A= --- block.c 19 Aug 2006 11:45:59 -0000 1.34=0A= +++ block.c 21 Aug 2006 00:48:41 -0000=0A= @@ -182,11 +182,18 @@=0A= #endif=0A= =0A= #ifdef _WIN32=0A= -static int is_windows_drive(const char *filename)=0A= +static int is_windows_file(const char *filename)=0A= {=0A= if (((filename[0] >=3D 'a' && filename[0] <=3D 'z') ||=0A= (filename[0] >=3D 'A' && filename[0] <=3D 'Z')) &&=0A= - filename[1] =3D=3D ':' && filename[2] =3D=3D '\0')=0A= + filename[1] =3D=3D ':')=0A= + return 1;=0A= + return 0;=0A= +}=0A= +=0A= +static int is_windows_drive(const char *filename)=0A= +{=0A= + if (is_windows_file(filename) && filename[2] =3D=3D '\0')=0A= return 1;=0A= if (strstart(filename, "\\\\.\\", NULL) ||=0A= strstart(filename, "//./", NULL))=0A= @@ -205,6 +212,8 @@=0A= #ifdef _WIN32=0A= if (is_windows_drive(filename))=0A= return &bdrv_raw;=0A= + if (is_windows_file(filename))=0A= + return &bdrv_raw;=0A= #endif=0A= p =3D strchr(filename, ':');=0A= if (!p)=0A= ------=_NextPart_000_0011_01C6C5ED.F47D2100--