[Title] change 'CreateFile' to 'qemu-open' for windows path error
authorjihye kim <jihye1128.kim@samsung.com>
Mon, 23 Jul 2012 02:32:21 +0000 (11:32 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Mon, 23 Jul 2012 02:32:21 +0000 (11:32 +0900)
[Type] work
[Module] qemu(emulator-x86)
[Priority] major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

block/raw-win32.c
package/pkginfo.manifest
qemu-char.c

index 3fa580c28d7f3d63d33fae952ae542681d8f7da4..03e9b76f439da26318779a258f0e8ba0268a330c 100644 (file)
@@ -85,6 +85,7 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
 
     s->type = FTYPE_FILE;
 
+#ifndef CONFIG_MARU
     if (flags & BDRV_O_RDWR) {
         access_flags = GENERIC_READ | GENERIC_WRITE;
     } else {
@@ -96,25 +97,55 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
         overlapped |= FILE_FLAG_NO_BUFFERING;
     if (!(flags & BDRV_O_CACHE_WB))
         overlapped |= FILE_FLAG_WRITE_THROUGH;
-#ifndef CONFIG_MARU
     s->hfile = CreateFile(filename,
                           access_flags,
                           FILE_SHARE_READ, NULL,
                           OPEN_EXISTING, overlapped, NULL);
-#else
-    s->hfile = CreateFile(g_win32_locale_filename_from_utf8(filename),
-                          access_flags,
-                          FILE_SHARE_READ, NULL,
-                          OPEN_EXISTING, overlapped, NULL);
-#endif
-    if (s->hfile == INVALID_HANDLE_VALUE) {
+       if (s->hfile == INVALID_HANDLE_VALUE) {
         int err = GetLastError();
 
         if (err == ERROR_ACCESS_DENIED)
             return -EACCES;
         return -1;
     }
-    return 0;
+
+#else
+       /*
+    s->hfile = CreateFile(g_win32_locale_filename_from_utf8(filename),
+                          access_flags,
+                          FILE_SHARE_READ, NULL,
+                          OPEN_EXISTING, overlapped, NULL);
+       */
+
+#include <errno.h>
+       int open_flags = O_BINARY;
+       open_flags &= ~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;
+       }
+       */
+
+       int 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;
 }
 
 static int raw_read(BlockDriverState *bs, int64_t sector_num,
@@ -382,7 +413,8 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
     }
     s->type = find_device_type(bs, filename);
 
-    if (flags & BDRV_O_RDWR) {
+#ifndef CONFIG_MARU
+       if (flags & BDRV_O_RDWR) {
         access_flags = GENERIC_READ | GENERIC_WRITE;
     } else {
         access_flags = GENERIC_READ;
@@ -394,25 +426,56 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
         overlapped |= FILE_FLAG_NO_BUFFERING;
     if (!(flags & BDRV_O_CACHE_WB))
         overlapped |= FILE_FLAG_WRITE_THROUGH;
-#ifndef CONFIG_MARU
+
     s->hfile = CreateFile(filename,
                           access_flags,
                           FILE_SHARE_READ, NULL,
                           create_flags, overlapped, NULL);
-#else
-    s->hfile = CreateFile(g_win32_locale_filename_from_utf8(filename),
-                          access_flags,
-                          FILE_SHARE_READ, NULL,
-                          create_flags, overlapped, NULL);
-#endif
-    if (s->hfile == INVALID_HANDLE_VALUE) {
+       if (s->hfile == INVALID_HANDLE_VALUE) {
         int err = GetLastError();
 
         if (err == ERROR_ACCESS_DENIED)
             return -EACCES;
         return -1;
     }
-    return 0;
+
+#else
+       /*
+    s->hfile = CreateFile(g_win32_locale_filename_from_utf8(filename),
+                          access_flags,
+                          FILE_SHARE_READ, NULL,
+                          create_flags, overlapped, NULL);
+       */
+#include <errno.h>
+
+       int open_flags = O_BINARY;
+       open_flags &= ~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;
+       }
+       */
+
+       int 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;
 }
 
 static int hdev_has_zero_init(BlockDriverState *bs)
index 1ef1a968a56d202b55ad1b3594a536b710f7287b..cae879346ff05c549b5419e53ac58c3c737f084b 100644 (file)
@@ -1,5 +1,5 @@
 Package: emulator-qemu-x86
-Version: 1.3.5
+Version: 1.3.6
 OS: ubuntu-32
 Build-host-os: ubuntu-32
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
@@ -9,7 +9,7 @@ Source: emulator
 Description: Tizen Emulator
 
 Package: emulator-qemu-x86
-Version: 1.3.5
+Version: 1.3.6
 OS: ubuntu-64
 Build-host-os: ubuntu-64
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
@@ -19,7 +19,7 @@ Source: emulator
 Description: Tizen Emulator
 
 Package: emulator-qemu-x86
-Version: 1.3.5
+Version: 1.3.6
 OS: windows-32
 Build-host-os: windows-32
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
index e191f73ed2075cb12c3281545b2c79ba018ae63c..554b12749131fc3d3e4ad357205cf79fa3090557 100644 (file)
@@ -1527,9 +1527,22 @@ static int win_chr_init(CharDriverState *chr, const char *filename)
                       GENERIC_READ|GENERIC_WRITE, 0, NULL,
                       OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
 #else
-    s->hcom = CreateFile(g_win32_locale_filename_from_utf8(filename),
+       /*
+       s->hcom = CreateFile(g_win32_locale_filename_from_utf8(filename),
                       GENERIC_READ|GENERIC_WRITE, 0, NULL,
                       OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
+       */
+       int open_flags = O_BINARY;
+       open_flags |= O_RDWR;
+       // TODO : FILE_FLAG_OVERLAPPED
+
+       int ret = qemu_open(filename, open_flags, 0644);
+       if (ret < 0) {
+               error_report("win_chr_init failed(%d) \n", ret);
+               return -errno;
+       }
+       s->hcom = (HANDLE)_get_osfhandle(ret);
+
 #endif
     if (s->hcom == INVALID_HANDLE_VALUE) {
         fprintf(stderr, "Failed CreateFile (%lu)\n", GetLastError());
@@ -1823,8 +1836,21 @@ static int qemu_chr_open_win_file_out(QemuOpts *opts, CharDriverState **_chr)
     fd_out = CreateFile(file_out, GENERIC_WRITE, FILE_SHARE_READ, NULL,
                         OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 #else
+       /*
     fd_out = CreateFile(g_win32_locale_filename_from_utf8(file_out), GENERIC_WRITE, FILE_SHARE_READ, NULL,
                         CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+       */
+       int open_flags = O_BINARY;
+       open_flags |= O_RDWR;
+       open_flags |= O_CREAT;
+
+       int ret = qemu_open(file_out, open_flags, 0644);
+       if (ret < 0) {
+               error_report("qemu_chr_open_win_file_out failed(%d) \n", ret);
+               return -errno;
+       }
+       fd_out = (HANDLE)_get_osfhandle(ret);
+
 #endif
 
     if (fd_out == INVALID_HANDLE_VALUE) {