[Title]add windows file share and fix kernel panic when use file share on linux
authormunkyu.im <munkyu.im@samsung.com>
Wed, 29 Feb 2012 11:12:27 +0000 (20:12 +0900)
committermunkyu.im <munkyu.im@samsung.com>
Wed, 29 Feb 2012 11:12:27 +0000 (20:12 +0900)
[Type]
[Module]
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Conflicts:

package/pkginfo.manifest

package/pkginfo.manifest
tizen/src/configuration.c
tizen/src/emulator.c
tizen/src/emulator.h

index bd6a1fa..1a080c9 100644 (file)
@@ -1,5 +1,5 @@
 Package: emulator
-Version: 1.2.21
+Version: 1.2.30
 OS: linux
 Build-host-os: linux
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
@@ -8,7 +8,7 @@ Source: emulator
 Description: Tizen Emulator
 
 Package: emulator
-Version: 1.2.21
+Version: 1.2.30
 OS: windows
 Build-host-os: windows
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
index 15a0055..40229ff 100644 (file)
@@ -746,7 +746,57 @@ void qemu_option_set_to_config(arglist *al)
        else
                sprintf(&kernel_kappend[strlen(kernel_kappend)], "ip=" GUEST_IP_ADDRESS "::" HOST_QEMU_ADDRESS ":255.255.255.0::eth0:none ");
 
-       sprintf(&kernel_kappend[strlen(kernel_kappend)], "%d", startup_option.run_level);
+       sprintf(&kernel_kappend[strlen(kernel_kappend)], "%d ", startup_option.run_level);
+    
+    /*To prevent kernel panic, add kernel command below */
+    
+    if (!qemu_arch_is_arm()) {         
+               if(startup_option.file_share != NULL) {
+            sprintf(&kernel_kappend[strlen(kernel_kappend)], "virtio-9p");
+        }
+    }
+
+    /* file sharing for windows */
+
+#ifdef  _WIN32
+       if (!qemu_arch_is_arm()) {              
+               if(startup_option.file_share != NULL) {
+            OSVERSIONINFO osvi;
+            ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+            osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+            GetVersionEx(&osvi);
+
+            if (osvi.dwMajorVersion == 5) {
+                char *title = g_strdup_printf("emulator-%d", get_sdb_base_port());
+                char *cmd1 = g_strdup_printf("net share %s /delete", title);
+                char *cmd2 = g_strdup_printf("net share %s=\"%s\"", title, startup_option.file_share);
+                char *cmd3 = g_strdup_printf("cacls \"%s\", /E /G everyone:F", startup_option.file_share);
+                DWORD  bufCharCount = MAXPATH;
+                TCHAR  username[MAXPATH];
+                GetUserName(username, &bufCharCount);
+                INFO("Host user name is %s\n", username);
+                INFO("cmd1: %s, cmd2: %s, cmd3: %s \n", cmd1, cmd2, cmd3);
+                if (WinExec(cmd1, SW_HIDE) < 31) {
+                    ERR("Error occured when launch command: %s, GetLastError: %d\n", cmd1, GetLastError());
+                }
+                if (WinExec(cmd2, SW_HIDE) < 31) {
+                    ERR("Error occured when launch command: %s, GetLastError: %d\n", cmd2, GetLastError());
+                }
+                if (WinExec(cmd3, SW_HIDE) < 31) {
+                    ERR("Error occured when launch command: %s, GetLastError: %d\n", cmd3, GetLastError());
+                }
+                sprintf(&kernel_kappend[strlen(kernel_kappend)], "cifs=%s,username=%s", title, username);
+              
+                free(cmd1);
+                free(cmd2);
+                free(cmd3);
+                free(title);
+            }
+
+        }
+    }
+#endif
+
 
        append_argvlist(al, "%s", exec_path);
        if (qemu_arch_is_arm()) {
index 352b34b..1c0defc 100644 (file)
@@ -332,6 +332,28 @@ int socket_init(void)
        return 0;
 }
 
+void cleanup_file_share(void)
+{
+#ifdef _WIN32
+       if (!qemu_arch_is_arm()) {              
+               if(startup_option.file_share != NULL) {
+            OSVERSIONINFO osvi;
+            ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+            osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+            GetVersionEx(&osvi);
+            char *cmd = g_strdup_printf("net share %s /delete", gtk_window_get_title(GTK_WINDOW(g_main_window)));
+            if (osvi.dwMajorVersion == 5) {
+                if(WinExec(cmd, SW_HIDE) < 31) {
+                    ERR("Error occured when launch command: %s, GetLastError: %d\n", cmd, GetLastError());
+                }else
+                    INFO("Delete file share successfully\n");
+          }
+          free(cmd);
+        }
+    }
+#endif
+}
+
 void exit_emulator_post_process( void ) {
 
        set_emulator_condition(EMUL_SHUTTING_DOWN);
@@ -361,6 +383,9 @@ void exit_emulator_post_process( void ) {
        fclose(g_out_fp);
        fclose(g_err_fp);
        INFO( "Close fp which is opened when redirect_log()\n");        
+    
+    /*7. cleanup file share */
+    cleanup_file_share();
 
 #ifdef ENABLE_OPENGL_SERVER
        pthread_cancel(thread_opengl_id);
index 2e6bc88..ddd69eb 100644 (file)
@@ -117,4 +117,5 @@ int device_set_rotation(int rotation);
 int socket_init(void);
 void exit_emulator_post_process( void );
 int make_shdmem(void);
+void cleanup_file_share(void);
 #endif